forked from goldmansachs/gs-collections
-
Notifications
You must be signed in to change notification settings - Fork 0
/
common-build.xml
351 lines (298 loc) · 12.3 KB
/
common-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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
<!--
~ Copyright 2013 Goldman Sachs.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<project
name="common-build"
xmlns:ivy="antlib:org.apache.ivy.ant">
<property file="../version.properties" />
<target name="clean" description="Clean the output directory">
<delete dir="target" />
</target>
<target name="-test-is-production">
<condition property="isProduction">
<and>
<isset property="build.major" />
<isset property="build.minor" />
<isset property="build.fix" />
</and>
</condition>
</target>
<target name="-test-set-prod-dev-properties" depends="-test-is-production">
<condition property="isProduction">
<isset property="isProduction" />
</condition>
<condition property="isDevelopment">
<not>
<isset property="isProduction" />
</not>
</condition>
</target>
<target name="-deploy-init">
<tstamp>
<format property="NOW" pattern="yyyy/MM/dd HH:mm" />
</tstamp>
</target>
<target name="-deploy-properties-prod" depends="-deploy-init, -test-set-prod-dev-properties" if="isProduction">
<property name="deploy.suffix" value="" />
<propertyfile file="../deploy.properties">
<entry key="build.major" type="string" value="${build.major}" />
<entry key="build.minor" type="string" value="${build.minor}" />
<entry key="build.fix" type="string" value="${build.fix}" />
<entry key="deploy.development" type="int" value="0" />
<entry key="deploy.date" type="date" value="${NOW}" />
</propertyfile>
<copy file="../deploy.properties" tofile="target/deploy.properties" overwrite="true" />
<property file="target/deploy.properties" />
<property name="remotedir"
value="${ant.project.name}/release/production/${ant.project.name}/${build.major}_${build.minor}_${build.fix}" />
</target>
<target name="-deploy-properties-dev" depends="-deploy-init, -test-set-prod-dev-properties" if="isDevelopment">
<copy file="../deploy.properties" tofile="target/deploy.properties" overwrite="true" />
<property name="deploy.suffix" value="-SNAPSHOT" />
<propertyfile file="target/deploy.properties">
<entry key="build.fix" type="int" default="0" operation="+" />
<entry key="deploy.development" type="string" value="X" />
<entry key="deploy.date" type="date" value="${NOW}" />
</propertyfile>
<property file="target/deploy.properties" />
<property name="remotedir" value="${ant.project.name}/release/development" />
</target>
<target
name="-deploy-properties"
depends="-deploy-properties-prod, -deploy-properties-dev">
</target>
<target name="-ivy-init"
depends="-deploy-properties">
<property name="ivy.dep.file" location="ivy.xml" />
<property name="ivy.settings.file" location="../ivysettings.xml" />
<property name="ivy.jar.file" value="${basedir}/../ivy-${ivy.version}.jar" />
<path id="ivy.lib.path">
<pathelement location="${ivy.jar.file}" />
</path>
<taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path" />
</target>
<target name="-compile-init">
<uptodate property="compile.uptodate" targetfile="target/compile.uptodate">
<srcfiles dir="${src.dir}" includes="**/*.java" />
</uptodate>
</target>
<target
name="compile"
depends="-ivy-init, generate-sources, -compile-init"
unless="compile.uptodate"
description="Compile the code">
<ivy:cachepath pathid="compile.classpath" conf="compile, optional" />
<property name="generatedsrc.dir" location="${src.dir}" />
<mkdir dir="${src.dir}" />
<mkdir dir="${generatedsrc.dir}" />
<mkdir dir="target/classes" />
<javac
destdir="target/classes"
fork="true"
source="${source.level}"
target="${target.level}"
debug="on">
<src>
<pathelement location="${src.dir}" />
<pathelement location="${generatedsrc.dir}" />
</src>
<classpath refid="compile.classpath" />
</javac>
<copy todir="target/classes" failonerror="false">
<fileset dir="src/main/resources" />
</copy>
<touch file="target/compile.uptodate" />
</target>
<target name="jar"
depends="compile, -deploy-properties"
description="Builds the jar for the application">
<jar
jarfile="${jar.name}"
compress="true"
index="false"
basedir="target/classes" />
</target>
<target name="-compile-tests-init">
<mkdir dir="${testsrc.dir}" />
<uptodate property="compile-tests.uptodate" targetfile="target/compile-tests.uptodate">
<srcfiles dir="${testsrc.dir}" includes="**/*.java" />
</uptodate>
</target>
<target
name="compile-tests"
depends="jar, -compile-tests-init, -ivy-init"
unless="compile-tests.uptodate"
description="Compile the test code">
<ivy:cachepath pathid="compile-test.classpath" conf="compile-test" />
<mkdir dir="${testsrc.dir}" />
<mkdir dir="${generatedtestsrc.dir}" />
<mkdir dir="target/test-classes" />
<javac
destdir="target/test-classes"
fork="false"
source="1.5"
target="1.5"
debug="on"
updatedproperty="compile-tests.success">
<src>
<pathelement location="${testsrc.dir}" />
<pathelement location="${generatedtestsrc.dir}" />
</src>
<classpath>
<path refid="compile-test.classpath" />
<pathelement location="${jar.name}" />
</classpath>
</javac>
<copy todir="target/test-classes" failonerror="false">
<fileset dir="src/test/resources" />
</copy>
<touch file="target/compile-tests.uptodate" />
</target>
<target name="-test-skip-test">
<condition property="skip.test">
<or>
<istrue value="${skipTests}" />
<uptodate targetfile="target/tests.uptodate">
<srcfiles dir="target">
<include name="compile.uptodate" />
<include name="compile-tests.uptodate" />
</srcfiles>
</uptodate>
</or>
</condition>
</target>
<target
name="test"
depends="-test-skip-test, compile-tests, install"
unless="skip.test"
description="Run the test cases">
<ivy:cachepath pathid="test.classpath" conf="test" />
<mkdir dir="target/test-reports" />
<junit haltonerror="true" haltonfailure="true" fork="true" forkmode="once" dir="target/test-reports">
<formatter type="xml" />
<formatter type="plain" usefile="false" />
<classpath>
<path refid="test.classpath" />
<pathelement location="${jar.name}" />
<pathelement location="target/test-classes" />
</classpath>
<batchtest todir="target/test-reports">
<fileset dir="${testsrc.dir}">
<include name="**/Test*.java" />
<include name="**/*Test.java" />
<include name="**/*TestSuite.java" />
<exclude name="**/Abstract*.java" />
<exclude name="**/*TestCase.java" />
<exclude name="**/*$*" />
</fileset>
</batchtest>
</junit>
<touch file="target/tests.uptodate" />
</target>
<path id="all-sources">
<fileset dir="${src.dir}" />
</path>
<target name="source-jar" depends="-deploy-properties" description="Builds the source jar for the application">
<jar
jarfile="${source.jar.name}"
compress="true"
index="false">
<resources refid="all-sources" />
</jar>
</target>
<target name="javadoc" depends="-deploy-properties, -ivy-init">
<ivy:cachepath pathid="runtime.classpath" conf="runtime" />
<javadoc
destdir="target/javadoc"
author="true"
version="true"
use="true"
useexternalfile="true"
windowtitle="${javadoc.title} - ${build.version.full}">
<sourcefiles>
<resources refid="all-sources" />
</sourcefiles>
<classpath refid="runtime.classpath" />
<doctitle>${javadoc.title} - ${build.version.full}</doctitle>
<link href="http://java.sun.com/j2se/1.5.0/docs/api/" />
</javadoc>
</target>
<target name="javadoc-jar"
depends="-deploy-properties, javadoc"
description="Builds the javadoc jar for the application">
<jar
jarfile="${javadoc.jar.name}"
compress="true"
index="false"
basedir="target/javadoc" />
</target>
<target
name="zip"
depends="jar, source-jar"
description="Builds a zip file containing the jar and all dependencies">
<property name="zip.name"
value="target/${ant.project.name}-${build.version.full}-${DSTAMP}-${TSTAMP}.zip" />
<ivy:retrieve
type="jar,bundle"
pattern="managed-lib/[conf]/[artifact]-[revision].[ext]"
sync="true"
conf="compile" />
<ivy:retrieve
type="jar,bundle"
pattern="managed-lib/compile/[artifact]-[revision].[ext]"
conf="optional" />
<zip destfile="${zip.name}">
<fileset file="${jar.name}" />
<fileset file="${source.jar.name}" />
<fileset file="${javadoc.jar.name}" />
<zipfileset dir="managed-lib/compile" prefix="lib" />
</zip>
</target>
<target name="help">
<echo message="Please run: $ant -projecthelp" />
</target>
<target name="ivy-report" depends="-ivy-init" description="Create Ivy report">
<ivy:resolve />
<ivy:report todir="target/ivy" graph="false" xml="false" />
</target>
<target name="ivy-clean" depends="-ivy-init" description="clean the ivy cache">
<ivy:cleancache />
</target>
<target name="ivy-make-pom" depends="-ivy-init, -deploy-properties" description="Generate Maven pom file">
<property name="ivy.pom.version" value="${build.version.full}" />
<ivy:makepom ivyfile="ivy.xml" templatefile="../pom-template" pomfile="${pom.name}" conf="compile, optional">
<mapping conf="compile" scope="compile" />
</ivy:makepom>
</target>
<target name="ivy-deploy"
depends="ivy-make-pom, test, jar, source-jar, javadoc-jar"
description="Deploy to the Maven Repository">
<ivy:resolve />
<ivy:publish resolver="deploy"
pubrevision="${build.version.full}"
overwrite="true"
publishivy="false">
<artifacts pattern="target/[artifact]-${build.version.full}(-[classifier]).[ext]" />
</ivy:publish>
</target>
<target name="install" depends="-ivy-init, jar, source-jar, javadoc-jar, ivy-make-pom"
description="installs the module to the local ivy cache">
<ivy:resolve />
<ivy:publish resolver="local" overwrite="true" pubrevision="${build.version.full}">
<artifacts pattern="target/[artifact]-${build.version.full}(-[classifier]).[ext]" />
</ivy:publish>
</target>
<target name="generate-sources" />
</project>