-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.xml
457 lines (386 loc) · 19.5 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
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
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
<?xml version="1.0" encoding="UTF-8"?>
<project name="simulator" basedir="." default="build">
<!-- ################################### Definitions ################################### -->
<property environment="env"/>
<property name="debuglevel" value="source,lines,vars"/>
<property name="target" value="1.6"/>
<property name="source" value="1.6"/>
<property name="build.dir" value="tmp/ant"/>
<property name="lib.dir" value="lib"/>
<property name="src.dir" value="src/main"/>
<property name="unit-tests.dir" value="src/test/unit"/>
<property name="acceptance-tests.dir" value="src/test/acceptance"/>
<property name="slow-tests.dir" value="src/test/slow"/>
<property name="resources.dir" value="resources"/>
<property name="dist.dir" value="jar"/>
<property name="javadoc.dir" value="javadoc"/>
<property name="deploy.dir" value="deploy"/>
<property name="license.src.dir" value="src/license"/>
<property name="license.build.dir" value="${build.dir}/license"/>
<fileset id="external.jars" dir="${lib.dir}">
<include name="xstream/xstream-1.3.jar"/>
<include name="xstream/xpp3_min-1.1.4c.jar"/>
<include name="commons-logging/commons-logging-1.1.1.jar"/>
<include name="log4j/log4j-1.2.15.jar"/>
<include name="commons-cli/commons-cli-1.1.jar"/>
<include name="jfreechart/jcommon-1.0.16.jar"/>
<include name="jfreechart/jfreechart-1.0.13.jar"/>
<include name="spring/spring-beans-2.0.2.jar"/>
<include name="spring/spring-context-2.0.2.jar"/>
<include name="spring/spring-core-2.0.2.jar"/>
</fileset>
<fileset id="test.jars" dir="${lib.dir}">
<include name="xstream/xstream-1.3.jar"/>
<include name="xstream/xpp3_min-1.1.4c.jar"/>
<include name="log4j/log4j-1.2.15.jar"/>
<include name="commons-cli/commons-cli-1.1.jar"/>
<include name="jfreechart/jcommon-1.0.16.jar"/>
<include name="jfreechart/jfreechart-1.0.13.jar"/>
<include name="spring/spring-beans-2.0.2.jar"/>
<include name="spring/spring-context-2.0.2.jar"/>
<include name="spring/spring-core-2.0.2.jar"/>
<include name="junit/junit.jar"/>
</fileset>
<path id="test.classpath">
<pathelement path="${build.dir}/test"/>
<fileset refid="test.jars"/>
</path>
<path id="simulator.classpath">
<pathelement path="${build.dir}"/>
<fileset refid="external.jars"/>
</path>
<!-- ################################### Misc Targets ################################### -->
<target name="all" depends="cleanall,build,deploy,doc,test"
description="Cleanly build, package and test everything. It runs: cleanall,build,deploy,doc,test"/>
<target name="clean" description="Clean up build and distribution directories">
<delete dir="${build.dir}"/>
<delete dir="${dist.dir}"/>
</target>
<target name="cleanall" depends="clean" description="Clean up build, distribution, javadoc, and deployment directory. Depends on: clean" >
<delete dir="${javadoc.dir}"/>
<delete dir="${deploy.dir}"/>
</target>
<target name="build" depends="set-revision,build-subprojects,build-project"
description="Sets the revision numnber, builds sub-projects and this project. Depends on: set-revision,build-subprojects,build-project"/>
<target name="build-subprojects" depends="build-license" description="Build all sub-projects. Depends on: build-license"/>
<target name="init" depends="filter-tpl" description="Initializes the build directory. Depends on: filter-tpl">
<tstamp/>
<mkdir dir="${build.dir}"/>
<mkdir dir="${license.build.dir}"/>
<copy includeemptydirs="false" todir="${build.dir}">
<fileset dir="${src.dir}" excludes="**/*.launch, **/*.java, **/*.tpl"/>
</copy>
</target>
<target name="build-project" depends="set-revision,filter-tpl,init" description="Builds the project. Depends on: set-revision,filter-tpl,init">
<echo message="OS: ${os.name} "/>
<echo message="Java: ${java.version} "/>
<echo message="Ant Java: ${ant.java.version} "/>
<echo message="${ant.project.name}: ${ant.file} "/>
<javac srcdir="${src.dir}" destdir="${build.dir}" debug="true" failonerror="true">
<classpath refid="simulator.classpath"/>
</javac>
</target>
<target name="build-license" depends="init" description="Builds the code for license management. Depends on: init">
<echo message="OS: ${os.name} "/>
<echo message="Java: ${java.version} "/>
<echo message="Ant Java: ${ant.java.version} "/>
<echo message="${ant.project.name}: ${ant.file} "/>
<javac srcdir="${license.src.dir}" destdir="${license.build.dir}" debug="true" failonerror="true">
<classpath refid="simulator.classpath"/>
</javac>
</target>
<target name="package" depends="build-project" description="Creates the main simulator JAR file. Depends on: build-project">
<mkdir dir="${dist.dir}"/>
<jar jarfile="${dist.dir}/simulator.jar" compress="false">
<fileset dir="${build.dir}">
<include name="com/**"/>
</fileset>
<manifest>
<attribute name="Main-Class" value="com.plectix.simulator.SimulationMain"/>
</manifest>
</jar>
</target>
<target name="package-license-server" depends="build-license" description="Creates server-side JAR files for license management. Depends on: build-license">
<mkdir dir="${dist.dir}"/>
<jar jarfile="${dist.dir}/license-server.jar" compress="false">
<fileset dir="${license.build.dir}">
<include name="com/**"/>
</fileset>
</jar>
</target>
<target name="package-license-client" depends="build-license" description="Creates obfuscated, client-side JAR files for license management. Depends on: build-license">
<mkdir dir="${dist.dir}"/>
<jar jarfile="${dist.dir}/license-client.jar" compress="false">
<fileset dir="${license.build.dir}">
<include name="com/**/client/**"/>
</fileset>
</jar>
<proguard configuration="config/license-client-obfuscation-proguard4.5beta2-config.pro"/>
</target>
<target name="deploy" depends="build,package,package-license-server,createPaths"
description="Deploys the package by building the project, creating the JAR file, and setting the paths. Depends on: build,package,package-license-server,createPaths">
<mkdir dir="${deploy.dir}"/>
<property name="deploy-dest" value="Plectix-Simulator-${DSTAMP}"/>
<property name="deploy-zip.dir" value="${deploy.dir}/${deploy-dest}"/>
<delete dir="${deploy-zip.dir}"/>
<copy todir="${deploy-zip.dir}">
<fileset dir=".">
<include name="config/log4j.properties"/>
<include name="config/applicationContext.xml"/>
<include name="config/ui.properties"/>
<include name="data/*.ka"/>
<include name="${dist.dir}/simulator.jar"/>
<include name="${dist.dir}/license-server.jar"/>
<exclude name="**/.svn"/>
<exclude name="**/.git"/>
</fileset>
</copy>
<copy todir="${deploy-zip.dir}/${lib.dir}">
<fileset refid="external.jars"/>
</copy>
<copy todir="${deploy-zip.dir}" file="run/Simulator.bat"/>
<copy todir="${deploy-zip.dir}" file="run/Simulator.sh"/>
<copy todir="${deploy-zip.dir}" file="run/LiveDataGUI.bat"/>
<copy todir="${deploy-zip.dir}" file="run/LiveDataGUI.sh"/>
<replaceregexp>
<regexp pattern="\$\{export.classpath.unix}"/>
<substitution expression="${export.classpath.unix}"/>
<fileset dir="${deploy-zip.dir}" includes="*.sh"/>
</replaceregexp>
<replaceregexp>
<regexp pattern="\$\{export.classpath.windows}"/>
<substitution expression="${export.classpath.windows}"/>
<fileset dir="${deploy-zip.dir}" includes="*.bat,*.lap"/>
</replaceregexp>
<fixcrlf srcdir="${deploy-zip.dir}" eol="lf" eof="remove" includes="*.sh"/>
<mkdir dir="${deploy-zip.dir}/logs"/>
<touch file="${deploy-zip.dir}/logs/simulator.log"/>
<!-- Make Windows zip file, including JRE -->
<zip destfile="${deploy.dir}/${deploy-dest}.zip">
<zipfileset dir="${deploy-zip.dir}" includes="**" prefix="${deploy-dest}"/>
</zip>
</target>
<target name="SimulationMain" description="Executes the simulator through the command line options. Equivalent to simplx or complx.">
<java classname="com.plectix.simulator.SimulationMain" failonerror="true" fork="yes">
<arg line="--sim data/Example.ka --time 10"/>
<classpath refid="simulator.classpath"/>
</java>
</target>
<target name="createPaths" description="Create paths to be used in sh or bat scripts">
<!-- Define properties for the full paths to the lib and jar directories,
so we can replace them below with the relative paths -->
<property name="lib-location" location="lib"/>
<property name="jar-location" location="jar"/>
<path id="export.classpath">
<pathelement path="${dist.dir}/simulator.jar"/>
<fileset refid="external.jars"/>
</path>
<pathconvert refid="export.classpath" targetos="unix" property="export.classpath.unix">
<map from="${lib-location}" to="lib"/>
<map from="${jar-location}" to="jar"/>
</pathconvert>
<pathconvert refid="export.classpath" pathsep=";" dirsep="/" property="export.classpath.windows">
<map from="${lib-location}" to="lib"/>
<map from="${jar-location}" to="jar"/>
</pathconvert>
</target>
<target name="showPaths" depends="createPaths" description="Shows the paths to the jar files needed for this project. Depends on: createPaths" >
<echo message="The value of export.classpath.windows is ${export.classpath.windows}"/>
<echo message="The value of export.classpath.unix is ${export.classpath.unix}"/>
</target>
<!-- Set version -->
<available file=".svn" type="dir" property="set-svn-revision" />
<available file=".git" type="dir" property="set-git-revision" />
<target name="set-revision" depends="set-svn-revision,set-git-revision"
description="Sets the source code repository revision number in the code. Depends on: set-svn-revision,set-git-revision">
<!-- Show revision -->
<property name="build.revision" value="${scm.name} ${revision.id}"/>
<echo message="Repository Revision: ${build.revision}" />
</target>
<!-- for xpath task below -->
<taskdef resource="net/uworks/andariel/andariel.properties">
<classpath>
<pathelement location="${lib.dir}/ant/andariel-1.2.3.jar"/>
</classpath>
</taskdef>
<target name="set-svn-revision" if="set-svn-revision">
<echo message="${lib.dir}/ant/andariel-1.2.3.jar"/>
<property name="svn.info" value="svn.info" />
<!-- Get last SVN revision. -->
<exec executable="svn" output="${svn.info}">
<arg value="info" />
<arg value="--xml" />
</exec>
<!-- Query revision. -->
<xpath file="${svn.info}"
expression="//entry/@revision"
outputproperty="svn.build.revision" />
<property name="scm.name" value="SVN"/>
<property name="revision.id" value="${svn.build.revision}"/>
<!-- Delete temp revision file. -->
<delete file="${svn.info}" />
</target>
<target name="set-git-revision" if="set-git-revision">
<!-- Get last SVN revision. -->
<exec executable="git" outputproperty="git.build.revision">
<arg value="rev-parse" />
<arg value="HEAD" />
</exec>
<property name="scm.name" value="GIT"/>
<property name="revision.id" value="${git.build.revision}"/>
</target>
<target name="filter-tpl">
<echo message="Processing the templates. ${ant.build.javac.source}" />
<tstamp>
<format property="build.date" pattern="yyyy-MM-dd HH:mm:ss z" />
</tstamp>
<copy todir="${src.dir}" overwrite="true" verbose="true">
<fileset dir="${src.dir}">
<include name="**/*.tpl" />
</fileset>
<filterset>
<filter token="build.revision" value="${build.revision}" />
<filter token="build.date" value="${build.date}" />
<filter token="build.os.name" value="${os.name}" />
<filter token="java.version" value="${java.version}" />
<filter token="ant.java.version" value="${ant.java.version}" />
</filterset>
<globmapper from="*.tpl" to="*.java" />
</copy>
</target>
<!-- ################################### Javadoc Targets ################################### -->
<target name="doc" description="Create all Javadoc documentation">
<echo>Building Javadocs</echo>
<mkdir dir="${javadoc.dir}"/>
<javadoc destdir="${javadoc.dir}" windowtitle="JSIM: Plectix Java Simulator" source="1.6" author="true" version="true" use="true" Overview="src/overview.html" access="private" >
<doctitle><![CDATA[<h1>JSIM: Plectix Java Simulator</h1>]]></doctitle>
<bottom><![CDATA[<i>(c) 2008-2009 Plectix BioSystems Inc.</i>]]></bottom>
<classpath refid="simulator.classpath"/>
<group title="All Packages" packages="com.plectix.simulator*"/>
<packageset dir="${src.dir}" defaultexcludes="yes">
<include name="com/plectix/simulator/**"/>
</packageset>
</javadoc>
</target>
<!-- ################################### Test Targets ################################### -->
<target name="build-tests" depends="build" description="Builds tests. Depends on: build">
<echo>Building tests</echo>
<mkdir dir="${build.dir}/test"/>
<echo message="OS: ${os.name} "/>
<echo message="Java: ${java.version} "/>
<echo message="Ant Java: ${ant.java.version} "/>
<echo message="${ant.project.name}: ${ant.file} "/>
<javac srcdir="${unit-tests.dir};${src.dir};${acceptance-tests.dir};${slow-tests.dir}" destdir="${build.dir}/test" debug="true" failonerror="true">
<classpath refid="test.classpath"/>
</javac>
</target>
<target name="test" depends="unit-tests, acceptance-tests" description="Runs unit and acceptance tests with junit. Depends on: unit-tests, acceptance-tests">
<echo message="All tests are complete - check log for errors"/>
</target>
<target name="acceptance-tests" depends="build-tests" description="Run acceptance tests with junit. Depends on: build-tests">
<echo>Running JUnit Tests</echo>
<junit printsummary="yes" fork="yes" haltonfailure="yes" showoutput="no">
<classpath refid="test.classpath" />
<formatter type="plain"/>
<test name="com.plectix.simulator.RunAllAcceptanceTests"/>
</junit>
<echo message="Acceptance tests are complete - check log for errors"/>
</target>
<target name="unit-tests" depends="build-tests" description="Run unit tests with junit. Depends on: build-tests">
<echo>Running JUnit Tests</echo>
<junit printsummary="yes" fork="yes" haltonfailure="yes" showoutput="no">
<classpath refid="test.classpath" />
<formatter type="plain"/>
<test name="com.plectix.simulator.RunAllUnitTests"/>
</junit>
<echo message="Unit tests are complete - check log for errors"/>
</target>
<target name="slowTests" depends="build-tests" description="Run Slow JUnit tests. Depends on: build-tests">
<echo>Running Slow JUnit Tests</echo>
<junit printsummary="yes" fork="yes" haltonfailure="yes" showoutput="no">
<classpath refid="test.classpath" />
<formatter type="plain"/>
<test name="com.plectix.simulator.RunAllSlowTests"/>
</junit>
<echo message="Slow Tests are complete - check log for errors"/>
</target>
<!-- ################################### findbugs Targets ################################### -->
<property name="findbugs.home" value="3rd.party/findbugs-1.3.9-rc1" />
<taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask" >
<classpath>
<pathelement location="${findbugs.home}/lib/findbugs-ant.jar"/>
</classpath>
</taskdef>
<target name="findbugs" depends="package" description="Runs the 3rd party findbugs application to analyze and locate bugs statically. Depends on: package">
<echo>Running findbugs</echo>
<findbugs home="${findbugs.home}"
effort="max"
reportLevel="low"
jvmargs="-Xmx1G"
stylesheet="fancy-hist.xsl"
output="html"
outputFile="simulator-fb.html" >
<auxClasspath>
<fileset refid="external.jars"/>
</auxClasspath>
<sourcePath path="${src.dir}" />
<class location="${dist.dir}/simulator.jar" />
</findbugs>
</target>
<!-- ################################### proguard targets ################################### -->
<property name="proguard.home" value="3rd.party/proguard4.5beta2" />
<taskdef resource="proguard/ant/task.properties" classpath="${proguard.home}/lib/proguard.jar" />
<target name="jsim-obf-jar" depends="package" description="Runs the 3rd party proguard application to shrink, optimize, and obfuscate the project jar file. Depends on: package">
<echo>Running proguard for shrinking, optimizing, and obfuscation</echo>
<proguard configuration="config/jsim-obfuscation-proguard4.5beta2-config.pro"/>
</target>
<target name="jsim-all-jar" depends="package" description="Runs the 3rd party proguard application to prepare a jar file with all libs JSIM needs. Depends on: package">
<echo>Running proguard to prepare a jar file with all libs JSIM needs</echo>
<proguard configuration="config/jsim-all-proguard4.5beta2-config.pro"/>
<move file="${dist.dir}/jsim-all.jar" tofile="${dist.dir}/jsim-all-${scm.name}-${revision.id}.jar"/>
</target>
<target name="jsim-no-gui-jar" depends="package" description="Runs the 3rd party proguard application to prepare a jar file with all non-gui libs JSIM needs. Depends on: package">
<echo>Running proguard to prepare a jar file with non gui libs JSIM needs</echo>
<proguard configuration="config/jsim-no-gui-proguard4.5beta2-config.pro"/>
<move file="${dist.dir}/jsim-no-gui.jar" tofile="${dist.dir}/jsim-no-gui-${scm.name}-${revision.id}.jar"/>
</target>
<!-- ################################### release at S3 target ################################### -->
<taskdef name="S3Upload" classname="dak.ant.taskdefs.S3Upload">
<classpath>
<pathelement location="${lib.dir}/ant/awstasks-0.3.jar"/>
<pathelement location="${lib.dir}/ant/commons-codec-1.4.jar"/>
<pathelement location="${lib.dir}/ant/commons-httpclient-3.1.jar"/>
<pathelement location="${lib.dir}/ant/jets3t-0.7.1.jar"/>
<pathelement location="${lib.dir}/commons-logging/commons-logging-1.1.1.jar"/>
</classpath>
</taskdef>
<target name="releaseS3" depends="all, package-license-server" description="Builds and pushes the code to Amazons's S3. Depends on: all, package-license-server">
<property environment="env"/>
<property file="config/aws.properties"/>
<property name="latest" value="${scm.name}-${revision.id}"/>
<property name="s3.target.dir" value="${aws.prefix}/${latest}/"/>
<echo message = "Latest: ${latest}"/>
<echo message = "S3 Target Dir: ${s3.target.dir}"/>
<echo message = "Uploading jar files to ${aws.bucket}/${s3.target.dir}"/>
<S3Upload
verbose = "true"
accessId = "${env.AWS_SECRET_ACCESS_KEY}"
secretKey = "${env.AWS_ACCESS_KEY_ID}"
bucket = "${aws.bucket}"
prefix = "${s3.target.dir}"
publicRead = "false" >
<fileset dir="${deploy-zip.dir}" includes="**/*.jar"/>
</S3Upload>
<echo file="latest" append="false" message = "${latest}"/>
<S3Upload
verbose = "true"
accessId = "${env.AWS_SECRET_ACCESS_KEY}"
secretKey = "${env.AWS_ACCESS_KEY_ID}"
bucket = "${aws.bucket}"
prefix = "${aws.prefix}/"
publicRead = "false" >
<fileset dir="." includes="latest"/>
</S3Upload>
<delete file="latest"/>
</target>
</project>