/
custom_rules.xml
81 lines (69 loc) · 3.12 KB
/
custom_rules.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?xml version="1.0" encoding="UTF-8"?>
<project name="custom_rules">
<property file="build.properties" />
<property name="src.dir" value="src/"/>
<property name="tests.dir" value="./tests"/>
<property name="tests.src.dir" value="${tests.dir}/src"/>
<property name="junit.reports.dir" value="${tests.dir}/junit-reports"/>
<path id="pmd.classpath">
<pathelement location="."/>
<fileset dir="pmd">
<include name="**/*.jar"/>
</fileset>
</path>
<target name="-set-release-mode" depends="android_rules.-set-release-mode">
<property name="isReleaseTarget" value="true"/>
</target>
<target name="checkstyle">
<taskdef resource="checkstyletask.properties" classpath="checkstyle/checkstyle-5.6-all.jar"/>
<checkstyle config="checkstyle.xml" failOnViolation="true" maxWarnings="0">
<fileset dir="${src.dir}" includes="**/*.java"/>
<fileset dir="${tests.src.dir}" includes="**/*.java"/>
<formatter type="xml" toFile="${out.dir}/checkstyle_report.xml"/>
</checkstyle>
</target>
<target name="pmd">
<taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask" classpathref="pmd.classpath"/>
<pmd failOnRuleViolation="true" failonerror="true">
<ruleset>pmd.xml</ruleset>
<fileset dir="${src.dir}" includes="**/*.java"/>
<fileset dir="${tests.src.dir}" includes="**/*.java"/>
<formatter type="xml" toFile="${out.dir}/pmd_report.xml"/>
</pmd>
</target>
<target name="-pre-build" depends="-get-git-commit,-set-build-version" />
<target name="-get-git-commit">
<exec executable="sh" outputproperty="git.commits">
<arg value="-c" />
<arg value="git log --pretty=format:'' | wc -l" />
</exec>
<echo>git.commits: ${git.commits}</echo>
</target>
<target name="-set-build-version" if="isReleaseTarget">
<replaceregexp
file="AndroidManifest.xml"
match='android:name="buildVersion" android:value="(\d+)"'
replace='android:name="buildVersion" android:value="${git.commits}"' />
</target>
<target name="-pre-compile" depends="checkstyle, pmd"/>
<target name="get-junit-reports">
<mkdir dir="${junit.reports.dir}" />
<exec executable="${adb}" failonerror="true" dir="${junit.reports.dir}">
<arg value="pull" />
<arg value="/data/data/org.openmrs.mobile/files/junit/" />
</exec>
</target>
<target name="run-tests">
<exec dir="${tests.dir}" executable="ant">
<arg value="clean"/>
<arg value="debug"/>
<arg value="install"/>
<arg value="test"/>
</exec>
<antcall target="get-junit-reports" />
</target>
<target name="demoVersion">
<replaceregexp file="${src.dir}/org/openmrs/mobile/utilities/ApplicationConstants.java" match='DEFAULT_OPEN_MRS_URL = EMPTY_STRING'
replace='DEFAULT_OPEN_MRS_URL = "http://devtest04.openmrs.org:8080/openmrs"' />
</target>
</project>