-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuild.xml
More file actions
executable file
·430 lines (368 loc) · 15.1 KB
/
build.xml
File metadata and controls
executable file
·430 lines (368 loc) · 15.1 KB
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
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
<project name="picoded.JavaCommons" default="source" xmlns:jacoco="antlib:org.jacoco.ant">
<property name="ant.build.javac.source" value="1.8"/>
<property name="ant.build.javac.target" value="1.8"/>
<property name='lib.dir' value='${basedir}/bin/lib' />
<!-- Sets the property variables to point to respective directories -->
<property name="junit-reports" value="${basedir}/test-files/junit-reports"/>
<property name="junit-html" value="${basedir}/test-files/junit-html" />
<property name="build-classes" value="${basedir}/bin/classes" />
<property name="build-docs" value="${basedir}/bin/docs" />
<property name="build-temp" value="${basedir}/bin/tmp/build-tmp" />
<property name="test-temp" value="${basedir}/test-files/tmp" />
<property name="src-path" value="src/picoded" />
<property name="src-test" value="test/picoded" />
<property name="src-test-old" value="src/picodedTests" />
<property name="src-experimental" value="src/picodedX" />
<property name="lib-organized-dir" value="lib-organized" />
<property name="build-libOnly" value="${basedir}/bin/build/picodedJavaCommons-libsOnly.jar" />
<!-- ant contrib add ons -->
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="${basedir}/build-tools/ant-contrib/ant-contrib-1.0b3.jar"/>
</classpath>
</taskdef>
<!-- jUnit declearation over-ride, see: 'http://stackoverflow.com/questions/9774264/junit-ant-task-junittask-was-not-found' -->
<path id="junit-path">
<fileset dir="build-tools/junit" includes="**/*.jar" />
</path>
<taskdef name="junit" classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask">
<classpath refid="junit-path"/>
</taskdef>
<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
<classpath refid="junit-path"/>
</taskdef>
<!-- One-JAR -->
<taskdef name="one-jar" classname="com.simontuffs.onejar.ant.OneJarTask"
classpath="./build-tools/one-jar/one-jar-ant-task-0.97.jar" onerror="report"/>
<!-- **************************************************
The following lists the target sets supported by ant
+ setup - Setup any precommit hooks used by the project
+ clean - Clean out all build / temporary files
+ src-beautify - Applies a standardised code mint to java files
+ build-lib - ReBuild the library only jar
+ build-lib-ifneeded - Varient of build-lib, only build if not exists
+ compile-src - Compile the source code
+ compile-tests - Compile test codes
+ build - Build all 3 jar varients
+ javadoc - Generate the javadoc and its jar
+ junit-all - Runs the full JUnit suite, with jacoco
************************************************** -->
<!-- **************************************************
* Setup / Cleanup Functions
************************************************** -->
<!-- setup pre-commit git hook, if needed -->
<target name="setup">
<mkdir dir=".git/hooks"/>
<symlink link=".git/hooks/pre-commit" resource="./pre-commit.sh" failonerror="false"/>
</target>
<!-- clean and remove all build files / test temp files -->
<target name="clean">
<delete includeemptydirs="true" failonerror="false">
<fileset dir="${basedir}/bin" includes="**/*"/>
<fileset dir="${basedir}/html-docs" includes="**/*"/>
<fileset dir="${basedir}/test-files/tmp" includes="**/*"/>
</delete>
<mkdir dir="${basedir}/bin"/>
<mkdir dir="${basedir}/bin/build"/>
<mkdir dir="${basedir}/bin/docs"/>
<mkdir dir="${basedir}/bin/classes"/>
<mkdir dir="${basedir}/bin/tmp"/>
<mkdir dir="${basedir}/test-files/tmp"/>
</target>
<!-- Code Beautifier, used for pre-commit hook -->
<target name="src-beautify">
<!-- Scan and beautify the code : spaces only -->
<exec executable="java">
<arg value="-cp"/>
<arg value="./build-tools/java-formatter/java-formatter-with-dependencies.jar"/>
<arg value="Formatter"/>
<arg value="./build-config/code-format.opts"/>
<arg value="./src"/>
</exec>
<!-- Scan and beautify the code : spaces only -->
<exec executable="java">
<arg value="-cp"/>
<arg value="./build-tools/java-formatter/java-formatter-with-dependencies.jar"/>
<arg value="Formatter"/>
<arg value="./build-config/code-format.opts"/>
<arg value="./test"/>
</exec>
</target>
<!-- **************************************************
* Dependency Library management
************************************************** -->
<!-- Extract and organize all the depency lib-organized files -->
<target name="build-lib-tempWorkspace">
<!-- resets the temporary lib building folder -->
<delete dir="${build-temp}" failonerror="false" />
<mkdir dir="${build-temp}"/>
<mkdir dir="${build-temp}/UBER"/>
<!-- iterate over the dependencies -->
<for param="file">
<path>
<!-- scan against every file found on lib-organized -->
<fileset dir="${lib-organized-dir}">
<include name="**/*.jar"/>
</fileset>
</path>
<sequential>
<!-- Get the library jar name to organize files under -->
<propertyregex override="yes"
property="jarname" input="@{file}"
regexp=".*/([^/]*)\.jar" replace="\1"/>
<!-- put the spring.* special stuff into sub-directories -->
<mkdir dir="${build-temp}/SPRING/${jarname}"/>
<unzip dest="${build-temp}/SPRING/${jarname}" src="@{file}">
<patternset>
<include name="**/META-INF/spring.*"/>
</patternset>
</unzip>
<!-- Handle license files seperately -->
<mkdir dir="${build-temp}/LICENSE/${jarname}"/>
<unzip dest="${build-temp}/LICENSE/${jarname}" src="@{file}">
<patternset>
<include name="**/LICENSE.*"/>
<include name="**/license.*"/>
<include name="**/NOTICE.*"/>
<include name="**/notice.*"/>
<include name="**/LICENSE"/>
<include name="**/NOTICE"/>
<include name="**/DEPENDENCIES"/>
<include name="**/INDEX.LIST"/>
</patternset>
</unzip>
<!-- Handle excluded items seperately -->
<mkdir dir="${build-temp}/EXCLUDES/${jarname}"/>
<unzip dest="${build-temp}/EXCLUDES/${jarname}" src="@{file}">
<patternset>
<include name="**/META-INF/MANIFEST.MF"/>
<include name="**/META-INF/*.SF"/>
<include name="**/META-INF/*.DSA"/>
<include name="**/META-INF/*.RSA"/>
<include name="**/META-INF/SIG-*"/>
</patternset>
</unzip>
<!-- put everything else into their CONFLICT directory -->
<mkdir dir="${build-temp}/CONFLICT/${jarname}"/>
<unzip dest="${build-temp}/CONFLICT/${jarname}" src="@{file}">
<patternset>
<exclude name="**/META-INF/spring.*"/>
<exclude name="**/META-INF/MANIFEST.MF"/>
<exclude name="**/META-INF/*.SF"/>
<exclude name="**/META-INF/*.DSA"/>
<exclude name="**/META-INF/*.RSA"/>
<exclude name="**/META-INF/SIG-*"/>
<exclude name="**/LICENSE.*"/>
<exclude name="**/license.*"/>
<exclude name="**/NOTICE.*"/>
<exclude name="**/notice.*"/>
<exclude name="**/LICENSE"/>
<exclude name="**/NOTICE"/>
<exclude name="**/DEPENDENCIES"/>
<exclude name="**/INDEX.LIST"/>
</patternset>
</unzip>
<!-- move over only files that are not in conflict into UBER -->
<move todir="${build-temp}/UBER/" overwrite="false">
<fileset dir="${build-temp}/CONFLICT/${jarname}/">
</fileset>
</move>
</sequential>
</for>
<!-- build the concatenated spring.* files -->
<mkdir dir="${build-temp}/UBER/META-INF"/>
<concat destfile="${build-temp}/UBER/META-INF/spring.handlers" fixlastline="true">
<fileset dir="${build-temp}/SPRING/" includes="*/*/spring.handlers"/>
</concat>
<concat destfile="${build-temp}/UBER/META-INF/spring.schemas" fixlastline="true">
<fileset dir="${build-temp}/SPRING/" includes="*/*/spring.schemas"/>
</concat>
<concat destfile="${build-temp}/UBER/META-INF/spring.tooling" fixlastline="true">
<fileset dir="${build-temp}/SPRING/" includes="*/*/spring.tooling"/>
</concat>
<concat destfile="${build-temp}/UBER/META-INF/spring.factories" fixlastline="true">
<fileset dir="${build-temp}/SPRING/" includes="*/*/spring.factories"/>
</concat>
<!-- empty out unneeded empty directories -->
<delete includeemptydirs="true">
<fileset dir="${build-temp}" >
<and>
<size value="0"/>
<type type="dir"/>
</and>
</fileset>
</delete>
</target>
<!-- Flatten the libs : Used the lib folder for runtime (similar to tomcat) -->
<target name="flattenLibs">
<mkdir dir="bin/libs"/>
<copy todir="bin/libs" flatten="true">
<!-- scan against every file found on lib-organized -->
<fileset dir="${lib-organized-dir}">
<include name="**/*.jar"/>
</fileset>
</copy>
</target>
<!-- Build the one GIANT jar : This is depreciated, as it always seem to cause problems somehow -->
<target name="build-uberJar" depends="build-lib-tempWorkspace">
<!-- build the uber jar! -->
<delete file="${build-libOnly}" failonerror="false"/>
<jar destfile="${build-libOnly}">
<!-- all dependency files except spring.* -->
<fileset dir="${build-temp}/UBER"/>
<!-- my project's classes & etc -->
<!--<zipgroupfileset dir="${dist.dir}" includes="myproject.jar" />-->
<!--
<manifest>
<attribute name="Main-Class" value="${main-class}"/>
</manifest>
-->
</jar>
<path id="lib.path.ref">
<!--<fileset dir="bin/build" includes="*-libsOnly.jar" />-->
<fileset dir="bin/libs" includes="*.jar" />
</path>
</target>
<!-- rebuilds the flatten libs jar from all library organized files -->
<target name="build-lib" depends="flattenLibs">
</target>
<!-- check if lib jar exists -->
<target name="build-lib-check">
<available file="${build-libOnly}" property="build-libOnly.present"/>
<path id="lib.path.ref">
<!--<fileset dir="bin/build" includes="*-libsOnly.jar" />-->
<fileset dir="bin/libs" includes="*.jar" />
</path>
</target>
<!-- build the lib jar only if it does noot exists -->
<target name="build-lib-ifneeded" depends="build-lib-check" unless="${build-libOnly.present}">
<antcall target="build-lib"/>
</target>
<!-- **************************************************
* Source code complation
************************************************** -->
<!-- compile the source -->
<target name="compile-src" depends="build-lib-ifneeded">
<mkdir dir="${build-classes}"/>
<javac destdir="${build-classes}" classpathref="lib.path.ref" debug="true" debuglevel="lines,source"
includeantruntime="false">
<!-- bootclasspath="./build-tools/rt-stubs/java-rt-jar-stubs-1.5.0.jar" -->
<compilerarg value="-Xlint:all"/>
<compilerarg value="-Xlint:-serial"/>
<src path="${src-path}"/>
<exclude name="**/package-info.java"/>
</javac>
</target>
<!-- convinent aliases -->
<target name="compile" depends="compile-src">
</target>
<target name="source" depends="compile-src">
</target>
<target name="test" depends="compile-tests">
</target>
<!-- compile the source with picodedTests -->
<target name="compile-tests" depends="build-lib-ifneeded">
<delete dir="test-files/tmp" failonerror="false"/>
<mkdir dir="test-files/tmp"/>
<path id="lib.test.ref">
<!--<fileset dir="bin/build" includes="*-libsOnly.jar" />-->
<fileset dir="bin/libs" includes="*.jar" />
<fileset dir="build-tools/junit" includes="*.jar" />
</path>
<mkdir dir="${build-classes}"/>
<mkdir dir="${src-test}"/>
<mkdir dir="${src-test-old}"/>
<javac destdir="${build-classes}" classpathref="lib.test.ref" debug="true" debuglevel="lines,source"
includeantruntime="false">
<compilerarg value="-Xlint:all"/>
<compilerarg value="-Xlint:-serial"/>
<src path="${src-path}"/>
<src path="${src-test}"/>
<src path="${src-test-old}"/>
<exclude name="**/package-info.java"/>
</javac>
</target>
<!-- **************************************************
* Complete build / docs / hybut
************************************************** -->
<!-- Build all the respective realese jar files -->
<target name="build" depends="build-lib,compile-src">
<!-- no libs -->
<delete dir="bin/build/picodedJavaCommons-noLibs.jar" failonerror="false"/>
<jar destfile="bin/build/picodedJavaCommons-noLibs.jar">
<fileset dir="${build-classes}" includes="**/*.class" excludes="**/*_test.class"/>
</jar>
<!-- with dependency files -->
<delete dir="bin/build/picodedJavaCommons-withLibs.jar" failonerror="false"/>
<jar destfile="bin/build/picodedJavaCommons-withLibs.jar">
<fileset dir="${build-temp}/UBER"/>
<fileset dir="${build-classes}" includes="**/*.class" excludes="**/*_test.class"/>
</jar>
</target>
<!-- Build all the respective realese jar files, without cleaning out existing files -->
<target name="build-src" depends="compile-src">
<!-- no libs -->
<delete dir="bin/build/picodedJavaCommons-noLibs.jar" failonerror="false"/>
<jar destfile="bin/build/picodedJavaCommons-noLibs.jar">
<fileset dir="${build-classes}" includes="**/*.class" excludes="**/*_test.class"/>
</jar>
</target>
<!-- Build all the respective javadocs files -->
<target name="javadoc" depends="build-lib-ifneeded">
<delete dir="bin/javadoc" failonerror="false"/>
<mkdir dir="bin/javadoc"/>
<javadoc destdir="bin/javadoc" classpathref="lib.path.ref" access="private" author="true" sourcepath="src" packagenames="picoded.*" use="true" version="true">
<!--<fileset dir="${build-classes}" includes="**/*.class" excludes="**/*_test.class"/>-->
</javadoc>
<jar destfile="bin/build/picodedJavaCommons-javadocs.jar" basedir="bin/javadoc"/>
</target>
<!-- jUnit test report runner, used for continuous unit testing -->
<target name="junit-all" depends="compile-tests">
<mkdir dir="${junit-reports}"/>
<jacoco:coverage destfile="${junit-reports}/junit-all.exec">
<junit printsummary="yes" haltonfailure="yes" fork="true" forkmode="once">
<classpath>
<pathelement path="${build-classes}"/>
<!--<pathelement path="${build-libOnly}"/>-->
<fileset dir="build-tools/junit" includes="**/*.jar" />
<fileset dir="bin/libs" includes="**/*.jar" />
<!--<fileset dir="${build-lib}" includes="**/*.jar" />-->
</classpath>
<formatter type="plain"/>
<formatter type="xml"/>
<!--
<test name="picodedTests.all_test"
haltonfailure="no" todir="${junit-reports}" outfile="junit-all">
<formatter type="plain"/>
<formatter type="xml"/>
</test>
-->
<batchtest haltonfailure="no" todir="${junit-reports}">
<fileset dir="test">
<include name="picoded/**/*_test.java"/>
</fileset>
<formatter type="plain"/>
<formatter type="xml"/>
</batchtest>
</junit>
</jacoco:coverage>
<antcall target="junit-xml-fix"/>
</target>
<!-- Sanatize junit xml reports, and fix common issues -->
<target name="junit-xml-fix">
<!--
Sanatize the junit XML report, for ending > error, which occurs randomly
but frequently enough to be a real annoyance on jenkins
-->
<replace dir="${junit-reports}">
<include name="**/*.xml"/>
<replacetoken><![CDATA[</testsuite>
>]]></replacetoken>
<replacevalue><![CDATA[</testsuite>]]></replacevalue>
</replace>
</target>
<!--Sams own targets -->
<target name="b">
<antcall target="build-src"></antcall>
</target>
</project>