forked from square/retrofit
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.xml
215 lines (186 loc) · 6.82 KB
/
build.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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 2010 Square, Inc. -->
<!--
- Builds the Retrofit project, relying on Apache Ivy to download external
- dependencies.
-
- Retrofit is divided into modules, all of which are built from this single
- Ant buildfile. The directory structure is as follows:
-
- [project root]
- modules
- [module]
- src
- src-tests
-->
<project
xmlns:ivy="antlib:org.apache.ivy.ant"
name="Retrofit" basedir="." default="dist">
<!--
- The Retrofit version number, becomes part of the JAR file names.
-->
<property file="revision.properties"/>
<!-- Import boilerplate Ivy build steps. -->
<import file="ivy-build.xml"/>
<property name="build.dir" location="build"/>
<property name="lib.dir" location="lib"/>
<property name="testreports.dir" location="${build.dir}/testreports"/>
<target name="prepare" depends="init-ivy">
<tstamp>
<!-- ISO 8601 format: 2010-06-02T15:25:45Z -->
<format property="build.time" timezone="GMT"
pattern="yyyy-MM-dd'T'HH:mm:ss'Z'"/>
<format property="build.year" timezone="GMT"
pattern="yyyy"/>
</tstamp>
<!--
- Assigns the git commit hash to the 'commit.hash' property, sending
- errors to the Ant log.
-->
<exec executable="git"
outputproperty="commit.hash"
failifexecutionfails="false"
logerror="true">
<arg value="log"/>
<arg value="-n1"/>
<arg value="--pretty=format:%H"/>
</exec>
<!-- Downloads dependencies and places JARs under lib. -->
<ivy:retrieve/>
</target>
<target name="clean">
<delete dir="${build.dir}"/>
</target>
<target name="clean-libs" depends="clean"
description="Removes the 'lib' directory.">
<delete dir="${lib.dir}"/>
</target>
<import file="build-macros.xml"/>
<target name="repackage-gson" depends="prepare">
<taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask">
<classpath>
<fileset dir="lib" includes="jarjar*.jar"/>
</classpath>
</taskdef>
<jarjar jarfile="${build.dir}/retrofit-gson-2.1.jar">
<zipfileset src="lib/gson-2.1.jar"/>
<rule pattern="com.google.gson.**" result="retrofit.internal.gson.@1"/>
</jarjar>
<jarjar jarfile="${build.dir}/retrofit-gson-2.1-sources.jar">
<zipfileset src="lib/gson-2.1-sources.jar"/>
<rule pattern="com.google.gson.**" result="retrofit.internal.gson.@1"/>
</jarjar>
</target>
<target name="compile" depends="repackage-gson">
<!-- Build these in this particular order. -->
<compile.module module="core"/>
<compile.module module="io">
<compile.main.classpath>
<pathelement location="${build.dir}/core/main"/>
</compile.main.classpath>
</compile.module>
<compile.module module="http">
<compile.main.classpath>
<pathelement location="${build.dir}/core/main"/>
<pathelement location="${build.dir}/io/main"/>
<pathelement location="${build.dir}/retrofit-gson-2.1.jar"/>
</compile.main.classpath>
<compile.tests.classpath>
<pathelement location="${build.dir}/core/main"/>
<pathelement location="${build.dir}/io/main"/>
<pathelement location="${build.dir}/retrofit-gson-2.1.jar"/>
</compile.tests.classpath>
</compile.module>
<compile.module module="android"/>
</target>
<target name="jar" depends="compile">
<jar.module module="android"/>
<jar.module module="core"/>
<jar.module module="http"/>
<jar.module module="io"/>
</target>
<target name="require.tests"
description="Sets a property so test failures abort the build.">
<property name="require.tests" value="true"/>
</target>
<target name="test" depends="compile" description="Runs tests.">
<mkdir dir="${testreports.dir}"/>
<!--
- If this property isn't already set, assume broken tests should not
- abort the build.
-->
<property name="require.tests" value="false"/>
<junit printsummary="true" haltonfailure="${require.tests}">
<classpath>
<pathelement location="${build.dir}/android/main"/>
<pathelement location="${build.dir}/android/tests"/>
<pathelement location="${build.dir}/core/main"/>
<pathelement location="${build.dir}/core/tests"/>
<pathelement location="${build.dir}/http/main"/>
<pathelement location="${build.dir}/http/tests"/>
<pathelement location="${build.dir}/io/main"/>
<pathelement location="${build.dir}/io/tests"/>
<fileset dir="${build.dir}" includes="retrofit-gson*.jar"/>
<fileset dir="${lib.dir}" includes="*.jar"/>
</classpath>
<formatter type="xml"/>
<batchtest todir="${testreports.dir}">
<fileset dir="modules/android/src-tests">
<include name="**/*Test.java"/>
</fileset>
<fileset dir="modules/core/src-tests">
<include name="**/*Test.java"/>
</fileset>
<fileset dir="modules/io/src-tests">
<include name="**/*Test.java"/>
</fileset>
<fileset dir="modules/http/src-tests">
<include name="**/*Test.java"/>
</fileset>
</batchtest>
</junit>
<junitreport todir="${testreports.dir}">
<fileset dir="${testreports.dir}" includes="TEST-*.xml"/>
<report todir="${testreports.dir}"/>
</junitreport>
<echo
message="${line.separator}Test report written to:${line.separator}${testreports.dir}/index.html"/>
</target>
<!--
- Publishes to the Ivy repository using the resolver named
- 'retrofit-resolver'.
-->
<target name="publish" depends="dist">
<ivy:publish
pubrevision="${retrofit.revision}"
resolver="retrofit-resolver"
forcedeliver="true"
update="true"
overwrite="true"
publishivy="true">
<!--
- This pattern selects which files will be published. The artifact
- pattern in ivy-settings.xml controls how the names matched here are
- published in the Ivy repository.
-->
<artifacts pattern="${build.dir}/[artifact]-[revision](-[classifier]).[ext]"/>
</ivy:publish>
</target>
<target name="dist" depends="clean,require.tests,test,jar"
description="Compiles, ensures tests pass, and creates all deliverables.">
<zip zipfile="${build.dir}/retrofit-${retrofit.revision}.zip">
<zipfileset prefix="retrofit" dir=".">
<exclude name="build/**"/>
<exclude name="out/**"/>
<exclude name="lib/**"/>
<exclude name="**/.git/**"/>
<exclude name=".gitignore"/>
<exclude name=".idea/**"/>
<exclude name="*.iml"/>
</zipfileset>
<zipfileset prefix="retrofit/bin" dir="${build.dir}">
<include name="retrofit-*.jar"/>
</zipfileset>
</zip>
</target>
</project>