forked from openlcb/OpenLCB_Java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
403 lines (363 loc) · 18.3 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
<!-- Ant build.xml file for OpenLCB development -->
<!-- Bob Jacobsen, Copyright 2009 -->
<!-- Revision $Revision: 370 $ -->
<project name="OpenLCB" default="run" basedir="." xmlns:jacoco="antlib:org.jacoco.ant">
<!-- basedir="." means all paths are relative to the "java" subdir. -->
<description>
Provides build services for OpenLCB development
</description>
<!-- options you might want to change during development, -->
<!-- but please change them back before commiting this file -->
<!-- should compiler warn of use of deprecated APIs? (yes/no) -->
<property name="deprecation" value="no" />
<!-- SDK version -->
<property name="sdk_version" value="1.8" />
<!-- source code version -->
<property name="source_version" value="1.8" />
<!-- JRE version -->
<property name="jre_version" value="1.8" />
<!-- set global properties for this build -->
<property name="source" value="src"/>
<property name="test" value="test"/>
<property name="coveragetarget" value="./coveragereport"/>
<property name="target" value="classes"/>
<property name="testreporttarget" value="restreport"/>
<property name="jartarget" value="."/>
<property name="doctarget" value="doc"/>
<path id="project.class.path">
<pathelement location="." />
<pathelement location="lib/junit-4.12.jar" />
<pathelement location="lib/xercesImpl.jar" /> <!-- only needed for tests compile and run -->
<pathelement location="lib/mockito-core-2.2.9-javadoc.jar" /> <!-- only needed for tests compile and run -->
<pathelement location="lib/mockito-core-2.2.9.jar" /> <!-- only needed for tests compile and run -->
<pathelement location="lib/hamcrest-core-1.3.jar" /> <!-- only needed for tests compile and run -->
<pathelement location="lib/hamcrest-library-1.3.jar" /> <!-- only needed for tests compile and run -->
<pathelement location="lib/byte-buddy-1.5.0.jar" /> <!-- only needed for tests compile and run -->
<pathelement location="lib/byte-buddy-agent-1.5.0.jar" /> <!-- only needed for tests compile and run -->
<pathelement location="lib/objenesis-2.4.jar" /> <!-- only needed for tests compile and run -->
<pathelement location="lib/jdom-2.0.5.jar" />
<pathelement location="lib/jdom.jar" />
<pathelement location="lib/jlfgr-1_0.jar" />
<pathelement location="lib/annotations.jar" /> <!-- only needed for compile -->
<pathelement location="lib/jsr305.jar" /> <!-- only needed for compile -->
<pathelement location="lib/spotbugs-annotations-3.1.2.jar" /> <!-- only needed for compile -->
<pathelement location="/System/Library/Java" /> <!-- MacOS X -->
<pathelement location="${target}/" /> <!-- last to check for name collisions -->
</path>
<!-- Java Code Coverage -->
<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
<classpath path="lib/jacocoant.jar" />
</taskdef>
<!-- fileset for the jacoco targets. -->
<fileset id="jacocofileset" dir="${target}">
<include name="**/*.class" />
<!-- Exclude classes necessary for testing only from the code coverage report-->
<exclude name="**/*Test*.class" />
<!-- Exclude testing infrastructure classes -->
<exclude name="**/*Scaffold.class" />
<exclude name="**/*JUnit*.class" />
<exclude name="**/*Demo.class" />
<exclude name="**/*Mock*.class" />
<exclude name="**/package-info.class" />
<exclude name="org/openlcb/FakeConnection.class" />
<exclude name="org/openlcb/cdi/jdom/SampleFactory.class" />
<exclude name="org/openlcb/FakeOlcbInterface.class" />
<exclude name="tools/jmri/DecoderDefnToCdi.class" />
<exclude name="tools/cansim/CanFrame.class" />
<exclude name="tools/cansim/CanSegment.class" />
<exclude name="tools/cansim/CanInterface.class" />
<exclude name="tools/Timed.class" />
<exclude name="tools/Timer.class" />
<exclude name="tools/QueueSim*.class" />
<exclude name="simulations/NodeIDCollisions.class" />
<exclude name="scenarios/ScenarioRunner*.class" />
<exclude name="scenarios/TwoBusesFiltered.class" />
<exclude name="scenarios/ThreeBuses.class" />
<exclude name="scenarios/NineOnALink.class" />
<exclude name="scenarios/ConfigDemoApplet*.class" />
<exclude name="scenarios/BlueGoldCheck*.class" />
<exclude name="scenarios/TwoBuses.class" />
<exclude name="scenarios/can/TwoOnASegment.class" />
<exclude name="scenarios/can/CanScenarios.class" />
<exclude name="scenarios/can/NineOnASegment.class" />
<exclude name="scenarios/BlueGoldApplet*.class" />
</fileset>
<!-- end of definitions -->
<!-- target definitions start here -->
<target name="init" description="create needed directories">
<!-- Create the time stamp -->
<tstamp/>
<!-- Create the build directory structure used by compile -->
<mkdir dir="${target}"/>
<mkdir dir="${target}/resources" />
</target>
<target name="clean" description="remove compilation results to force rebuild">
<mkdir dir="${target}"/>
<delete includeEmptyDirs="true" quiet="true">
<fileset dir="${target}"/>
<fileset dir="${coveragetarget}"/>
<fileset dir="${testreporttarget}"/>
<file file="jacoco.exec"/>
<file file="junit-results.xml"/>
</delete>
</target>
<target name="copyfiles" depends="init" description="copy resource files">
<copy todir="${target}">
<fileset dir="src/" includes="**/*.properties" />
</copy>
</target>
<target name="compile" depends="init, copyfiles" description="compile source, omitting tests">
<!-- Compile the java code from ${source} into ${target} -->
<javac srcdir="${source}"
destdir="${target}"
source="${source_version}"
target="${jre_version}"
fork="true"
includeantruntime="false"
memoryinitialsize="256m"
memorymaximumsize="256m"
deprecation="${deprecation}"
debug="yes" >
<!-- <compilerarg value="-Xlint:{fallthrough,path,finally,-unchecked,-serial} "/> -->
<!-- <compilerarg value="-Xlint:unchecked" /> -->
<compilerarg value="-Xmaxerrs"/><compilerarg value="1000"/><!-- change from default 100 errors -->
<classpath refid="project.class.path" />
</javac>
</target>
<target name="tests" depends="compile" description="compile test classes">
<!-- Compile the test java code from ${source} into ${target} -->
<copy todir="${target}">
<fileset dir="test/" includes="**/*.properties" />
</copy>
<javac srcdir="${test}"
destdir="${target}"
source="${source_version}"
target="${jre_version}"
fork="true"
includeantruntime="false"
memoryinitialsize="256m"
memorymaximumsize="256m"
deprecation="${deprecation}"
debug="yes" >
<compilerarg value="-Xmaxerrs"/><compilerarg value="1000"/><!-- change from default 100 errors -->
<classpath refid="project.class.path" />
</javac>
</target>
<target name="run" depends="compile, tests" description="build and run test suite">
<mkdir dir="${testreporttarget}"/>
<junit haltonerror="false" haltonfailure="false" showoutput="yes" printsummary="yes" fork="yes" dir="." timeout="3600000" errorProperty="test.failed" failureProperty="test.failed">
<classpath refid="project.class.path" />
<sysproperty key="java.security.policy" value="lib/security.policy"/>
<sysproperty key="java.library.path" path=".:lib/"/>
<formatter type="xml"/>
<batchtest fork="yes" todir="${testreporttarget}" skipNonTests="yes" >
<fileset dir="${test}">
<include name="**/*Test.java" />
<exclude name="**/PackageTest.java" />
<exclude name="**/AllTest.java" />
<exclude name="**/HeadLessTest.java" />
</fileset>
</batchtest>
</junit>
<fail>
<condition>
<istrue value="${test.failed}" />
</condition>
</fail>
</target>
<target name="run-travis" depends="compile, javadoc, tests" description="build and run test suite">
<mkdir dir="${testreporttarget}"/>
<junit haltonerror="false" haltonfailure="false" showoutput="yes" printsummary="yes" fork="yes" dir="." timeout="3600000" errorProperty="test.failed" failureProperty="test.failed">
<classpath refid="project.class.path" />
<sysproperty key="java.security.policy" value="lib/security.policy"/>
<sysproperty key="java.library.path" path=".:lib/"/>
<formatter type="xml"/>
<batchtest fork="yes" todir="${testreporttarget}" skipNonTests="yes" >
<fileset dir="${test}">
<include name="**/*Test.java" />
<exclude name="**/PackageTest.java" />
<exclude name="**/AllTest.java" />
<exclude name="**/HeadLessTest.java" />
</fileset>
</batchtest>
</junit>
<fail>
<condition>
<istrue value="${test.failed}" />
</condition>
</fail>
</target>
<target name="run-coverage" depends="compile, tests" description="build and run test suite, generating coverage report.">
<mkdir dir="${testreporttarget}"/>
<jacoco:coverage destfile="jacoco.exec" excludes="org.slf4j.*">
<junit haltonerror="false" haltonfailure="false" showoutput="yes" printsummary="withOutAndErr" fork="yes" dir="." timeout="3600000">
<classpath refid="project.class.path" />
<sysproperty key="java.security.policy" value="lib/security.policy"/>
<sysproperty key="java.library.path" path=".:lib/"/>
<formatter type="xml"/>
<batchtest fork="yes" todir="${testreporttarget}" skipNonTests="yes" >
<fileset dir="${test}">
<include name="**/*.java" />
<exclude name="**/PackageTest.java" />
<exclude name="**/AllTest.java" />
<exclude name="**/HeadLessTest.java" />
</fileset>
</batchtest>
</junit>
</jacoco:coverage>
<jacoco:report>
<executiondata>
<file file="jacoco.exec" />
</executiondata>
<structure name="AntTestReporting">
<classfiles>
<fileset refid="jacocofileset"/>
</classfiles>
</structure>
<html destdir="${coveragetarget}" />
</jacoco:report>
</target>
<target name="bg" depends="compile, tests" description="build and run Blue/Gold test">
<java classname="scenarios.BlueGoldCheck"
dir=".."
fork="yes" >
<classpath refid="project.class.path" />
<sysproperty key="java.security.policy" value="lib/security.policy"/>
<sysproperty key="java.library.path" path=".:lib/"/>
</java>
</target>
<target name="javadoc" depends="init" description="create JavaDoc for prototype code, omitting tests">
<javadoc packagenames="org.*"
maxmemory="512m"
sourcepath="${source}"
overview="src/overview.html"
defaultexcludes="yes"
destdir="${doctarget}"
additionalparam="-breakiterator"
author="true"
version="false"
use="true"
failonerror="true"
windowtitle="OpenLCB">
<arg value="-Xdoclint:all,-missing"/> <!-- dropping some 1.8 warnings -->
<group title="Core" packages="org.openlcb"/>
<classpath refid="project.class.path" />
<doctitle><![CDATA[<h1>OpenLCB API</h1>]]></doctitle>
<link href="http://java.sun.com/j2se/1.4.1/docs/api/" />
</javadoc>
</target>
<!-- The structure of the following should closely follow the -->
<!-- main 'javadoc' target directly above. The only difference -->
<!-- is the doclet clause referencing the UML generator, the -->
<!-- use of the public option in the main task definition, and -->
<!-- the execution of "dot" at the bottom. -->
<!-- Requires Graphviz from http://www.graphviz.org -->
<target name="javadoc-uml" depends="init" description="create JavaDocs with UML">
<javadoc packagenames="org.*"
maxmemory="512m"
sourcepath="${source}"
overview="${source}/overview.html"
destdir="${doctarget}"
additionalparam="-breakiterator"
author="true"
version="false"
package="yes"
use="true"
failonerror="true"
windowtitle="OpenLCB API">
<arg value="-Xdoclint:all,-missing"/> <!-- dropping some 1.8 warnings -->
<doclet name="org.umlgraph.doclet.UmlGraphDoc"
path="lib/UmlGraph-5.7.jar">
<param name="-attributes"/>
<param name="-operations"/>
<param name="-qualify"/>
<param name="-types"/>
<!-- <param name="-visibility"/> not used, as only showing public visibility -->
<param name="-collapsible"/> <!-- hide images at first on web pages -->
<param name="-inferdepvis" value="public"/> <!-- only show public -->
</doclet>
<classpath refid="project.class.path"/>
<doctitle><![CDATA[<h1>OpenLCB API</h1>]]></doctitle>
<bottom><![CDATA[<a href="http://openlcb.org/Copyright.html">Information on copyright, trademarks and licenses is linked here.</a>
<br>Site hosted by:
<a href="http://sourceforge.net/projects/jmri">
<img src="http://sflogo.sourceforge.net/sflogo.php?group_id=26788&type=12" width="120" height="30" border="0" alt="Get JMRI Model Railroad Interface at SourceForge.net. Fast, secure and Free Open Source software downloads"/></a>
]]>
</bottom>
<link href="http://docs.oracle.com/javase/8/docs/api/"/>
<link href="http://download.oracle.com/javase/8/docs/api/"/>
<link href="http://java.sun.com/products/javacomm/reference/api/"/>
<link href="http://www.jdom.org/docs/apidocs/"/>
<link href="http://javacsv.sourceforge.net/"/> <!-- A -->
<link href="http://fasterxml.github.io/jackson-databind/javadoc/2.0.6"/>
<link href="http://logging.apache.org/log4j/1.2/apidocs/"/>
<!-- <link href="http://java.sun.com/javase/technologies/desktop/java3d/forDevelopers/j3dapi/"/> failes, so bypassed -->
<link href="https://jogamp.org/deployment/jogamp-next/javadoc/joal/javadoc/"/>
<link href="https://commons.apache.org/proper/commons-lang/javadocs/api-release"/>
</javadoc>
<apply executable="dot" dest="${doctarget}" parallel="false">
<arg value="-Tpng"/>
<arg value="-o"/>
<targetfile/>
<srcfile/>
<fileset dir="${doctarget}" includes="*.dot"/>
<mapper type="glob" from="*.dot" to="*.png"/>
</apply>
</target>
<target name="javadocall" depends="init" description="create JavaDoc for all code including tests">
<javadoc packagenames="org.*, tools.*, simulations.*, scenarios.*"
maxmemory="512m"
sourcepath="${source}:${test}"
overview="src/overview.html"
defaultexcludes="yes"
destdir="${doctarget}"
additionalparam="-breakiterator"
author="true"
version="false"
use="true"
windowtitle="OpenLCB">
<arg value="-Xdoclint:all,-missing"/> <!-- dropping some 1.8 warnings -->
<group title="Core" packages="org.openlcb"/>
<classpath refid="project.class.path" />
<doctitle><![CDATA[<h1>OpenLCB API</h1>]]></doctitle>
<link href="http://java.sun.com/j2se/1.4.1/docs/api/" />
</javadoc>
</target>
<target name="jars" description="create working jar files with current contents">
<antcall target="clean" />
<antcall target="compile" />
<jar jarfile="${jartarget}/openlcb.jar"
basedir="${target}"
manifest="manifest"
compress="true" /> <!-- compress="true" is default -->
<antcall target="tests" />
<jar jarfile="${jartarget}/openlcb-demo.jar"
basedir="${target}"
manifest="manifest"
compress="true" /> <!-- compress="true" is default -->
</target>
<target name="rejar" description="re-create working jar files without clean">
<antcall target="compile" />
<jar jarfile="${jartarget}/openlcb.jar"
basedir="${target}"
manifest="manifest"
compress="true" /> <!-- compress="true" is default -->
</target>
<target name="testrejar" description="re-create working test jar files without clean">
<antcall target="compile" />
<jar jarfile="${jartarget}/openlcb.jar"
basedir="${target}"
manifest="manifest"
compress="true" /> <!-- compress="true" is default -->
<antcall target="tests" />
<jar jarfile="${jartarget}/openlcb-demo.jar"
basedir="${target}"
manifest="manifest"
compress="true" /> <!-- compress="true" is default -->
</target>
<target name="travis-ci-tests" > <!-- tests used on travis CI -->
<antcall target="compile" />
<antcall target="run-travis" />
<antcall target="javadoc-uml" />
</target>
</project>