-
-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathcustom_rules.xml
134 lines (114 loc) · 5.37 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?xml version="1.0" encoding="UTF-8"?>
<project>
<property file="${file.key.properties}"/>
<property file="${file.remote.properties}"/>
<!-- quick check on sdk.dir -->
<fail
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through an env var"
unless="sdk.dir"
/>
<target name="cc-setup" depends="build-from-source, addversionnumber">
<!-- update resources -->
<tstamp>
<format property="TODAY_TIMESTAMP"
pattern="MMMM-dd-yyyy"/>
</tstamp>
<mkdir dir="${custom.dir.resource}"/>
<copy todir="${custom.dir.resource}">
<fileset dir="res"/>
</copy>
<echo>Today: ${TODAY_TIMESTAMP}</echo>
<echo>Version: ${version.code}</echo>
<replace file="${custom.dir.resource}/values/external_strings.xml" token="UNKNOWN_DATE"
value="${TODAY_TIMESTAMP}"/>
<replace file="${custom.dir.resource}/values/external_strings.xml" token="CUSTOM_BUILD"
value="${version.code}"/>
</target>
<target name="build-from-source" if="build.source">
<!-- todo: that -->
<copy todir="${jar.libs.dir}">
<fileset dir="${javarosa.libs}" includes="*.jar"/>
<fileset dir="${commcare.libs}" includes="*.jar"/>
</copy>
</target>
<target name="addversionnumber" if="build.server">
<property name="android.version.code" value="android:versionCode="/>
<replaceregexp file="AndroidManifest.xml"
match='android:versionCode="(.*)"'
replace='${android.version.code}"${version.code}"'/>
</target>
<target name="prepare" depends="cc-setup"/>
<target name="cc-release" depends="prepare, release"/>
<target name="test-and-release" depends="prepare, unit-test, generate-report, cc-release"/>
<!-- Begin unit testing code -->
<property name="test.dir" value="test"/>
<property name="test.source.dir" location="${test.dir}/src"/>
<property name="test.jar.libs.dir" location="${test.dir}/lib"/>
<property name="test.out.dir" location="${test.dir}/bin"/>
<property name="test.out.classes.dir" location="${test.out.dir}/classes"/>
<property name="test.out.reports.dir" location="${test.out.dir}/reports"/>
<target name="-pre-clean">
<delete dir="${test.out.dir}" verbose="${verbose}"/>
</target>
<target name="-pre-compile-tests">
<mkdir dir="${test.out.dir}"/>
<mkdir dir="${test.out.classes.dir}"/>
</target>
<target name="-compile-tests"
depends="-pre-compile-tests, -set-debug-files, -set-debug-mode, -compile">
<copy todir="${test.out.classes.dir}">
<fileset dir="${test.source.dir}" includes="org.robolectric.Config.properties"/>
</copy>
<!-- Move resources used by the tests -->
<copy todir="${test.out.classes.dir}" verbose="true">
<fileset dir="${test.source.dir}" includes="resources/**"/>
</copy>
<path id="test.project.javac.classpath">
<path refid="project.all.jars.path"/>
<path refid="tested.project.classpath"/>
<path path="${java.compiler.classpath}"/>
<path path="${out.classes.absolute.dir}"/>
<fileset dir="${jar.libs.dir}" includes="**/*.jar"/>
<fileset dir="${test.jar.libs.dir}" includes="**/*.jar"/>
</path>
<javac encoding="${java.encoding}"
source="${java.source}" target="${java.target}"
debug="true" extdirs="" includeantruntime="false"
destdir="${test.out.classes.dir}"
bootclasspathref="project.target.class.path"
verbose="${verbose}"
classpathref="test.project.javac.classpath"
fork="${need.javac.fork}">
<src path="${source.absolute.dir}"/>
<src path="${gen.absolute.dir}"/>
<src path="${test.source.dir}"/>
</javac>
</target>
<target name="unit-test" depends="prepare, -compile-tests"
description="Runs all Robolectric unit tests.">
<mkdir dir="${test.out.reports.dir}"/>
<path id="junit.classpath">
<!-- have to start the classpath with the test outputs, otherwise we'll miss resource files -->
<path path="${test.out.classes.dir}"/>
<path refid="test.project.javac.classpath"/>
<path refid="project.target.class.path"/>
</path>
<junit showoutput="true" failureproperty="junit.failure" printsummary="yes">
<classpath refid="junit.classpath"/>
<formatter type="plain"/>
<formatter type="xml"/>
<batchtest todir="${test.out.reports.dir}">
<fileset dir="${test.source.dir}" includes="**/*Test.java"/>
</batchtest>
</junit>
<fail if="junit.failure" message="Unit test(s) failed. See reports!"/>
</target>
<target name="generate-report"
description="Generates an HTML report from existing test results.">
<mkdir dir="${test.out.reports.dir}/html"/>
<junitreport todir="${test.out.reports.dir}/html">
<fileset dir="${test.out.reports.dir}" includes="TEST-*.xml"/>
<report todir="${test.out.reports.dir}/html"/>
</junitreport>
</target>
</project>