-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild.xml
More file actions
359 lines (324 loc) · 15.4 KB
/
build.xml
File metadata and controls
359 lines (324 loc) · 15.4 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
<?xml version="1.0" encoding="UTF-8"?>
<!--
build.xml — Apache Ant build file for SimulationModeling
=========================================================
Requires: Apache Ant 1.10.6+, JDK 17+
JUnit JARs in lib/ are committed for classroom convenience. Quality tool
distributions are downloaded on demand to lib/tools/ by "ant resolve-tools".
Main targets
============
resolve Download JUnit 5 JARs to lib/ (run once)
compile Compile main sources to build/classes
compile-tests Compile test sources to build/test-classes
test Run JUnit 5 tests; reports in build/reports
javadoc Generate Javadoc into docs/
jar Package compiled classes into build/simulation.jar
checkstyle Run style checks
pmd Run PMD source analysis
spotbugs Run SpotBugs bytecode analysis
coverage Run tests with JaCoCo coverage
quality Run tests plus all quality tools
clean Delete all generated files
all clean → quality → javadoc → jar
-->
<project name="SimulationModeling" default="all" basedir="."
xmlns:junitlauncher="antlib:org.apache.tools.ant.taskdefs.optional.junitlauncher"
xmlns:jacoco="antlib:org.jacoco.ant">
<!-- ============================================================ -->
<!-- Load configurable properties -->
<!-- ============================================================ -->
<property file="build.properties"/>
<!-- Convenience path: all JARs in lib/ -->
<path id="lib.classpath">
<fileset dir="${lib.dir}" includes="*.jar"/>
</path>
<!-- Optional quality tool classpaths. Run "ant resolve-tools" first. -->
<path id="checkstyle.classpath">
<pathelement location="${checkstyle.jar}"/>
</path>
<path id="spotbugs.classpath">
<fileset dir="${spotbugs.home}/lib" includes="*.jar"/>
</path>
<path id="pmd.classpath">
<fileset dir="${pmd.home}/lib" includes="*.jar"/>
</path>
<path id="jacoco.classpath">
<pathelement location="${jacoco.ant.jar}"/>
</path>
<!-- Compilation classpath for main sources (no test deps needed) -->
<path id="compile.classpath">
<path refid="lib.classpath"/>
</path>
<!-- Compilation classpath for test sources -->
<path id="test.compile.classpath">
<pathelement location="${classes.dir}"/>
<path refid="lib.classpath"/>
</path>
<!-- Runtime classpath for running tests -->
<path id="test.run.classpath">
<pathelement location="${test.classes.dir}"/>
<pathelement location="${classes.dir}"/>
<path refid="lib.classpath"/>
</path>
<!-- ============================================================ -->
<!-- resolve: download JUnit 5 JARs from Maven Central -->
<!-- Run this once after a fresh clone if lib/ is not committed. -->
<!-- ============================================================ -->
<target name="resolve" description="Download JUnit 5 dependencies to lib/">
<mkdir dir="${lib.dir}"/>
<property name="mvn" value="https://repo1.maven.org/maven2"/>
<property name="ju.ver" value="5.10.2"/>
<property name="jp.ver" value="1.10.2"/>
<get dest="${lib.dir}" skipexisting="true" verbose="true">
<!-- JUnit Jupiter API (compile + test scope) -->
<url url="${mvn}/org/junit/jupiter/junit-jupiter-api/${ju.ver}/junit-jupiter-api-${ju.ver}.jar"/>
<!-- JUnit Jupiter Engine (runtime) -->
<url url="${mvn}/org/junit/jupiter/junit-jupiter-engine/${ju.ver}/junit-jupiter-engine-${ju.ver}.jar"/>
<!-- JUnit Platform Launcher -->
<url url="${mvn}/org/junit/platform/junit-platform-launcher/${jp.ver}/junit-platform-launcher-${jp.ver}.jar"/>
<!-- JUnit Platform Engine SPI -->
<url url="${mvn}/org/junit/platform/junit-platform-engine/${jp.ver}/junit-platform-engine-${jp.ver}.jar"/>
<!-- JUnit Platform Commons -->
<url url="${mvn}/org/junit/platform/junit-platform-commons/${jp.ver}/junit-platform-commons-${jp.ver}.jar"/>
<!-- OpenTest4J (assertion library used by JUnit) -->
<url url="${mvn}/org/opentest4j/opentest4j/1.3.0/opentest4j-1.3.0.jar"/>
<!-- API Guardian annotations -->
<url url="${mvn}/org/apiguardian/apiguardian-api/1.1.2/apiguardian-api-1.1.2.jar"/>
</get>
</target>
<!-- ============================================================ -->
<!-- resolve-tools: download optional quality tools -->
<!-- ============================================================ -->
<target name="resolve-tools"
description="Download Checkstyle, SpotBugs, PMD, JaCoCo, and JUnit Console">
<mkdir dir="${downloads.dir}"/>
<mkdir dir="${tools.dir}/checkstyle"/>
<mkdir dir="${tools.dir}/junit"/>
<get src="https://github.com/checkstyle/checkstyle/releases/download/checkstyle-${checkstyle.version}/checkstyle-${checkstyle.version}-all.jar"
dest="${checkstyle.jar}"
skipexisting="true"/>
<get src="https://repo1.maven.org/maven2/org/junit/platform/junit-platform-console-standalone/${junit.platform.version}/junit-platform-console-standalone-${junit.platform.version}.jar"
dest="${junit.console.jar}"
skipexisting="true"/>
<get src="https://github.com/spotbugs/spotbugs/releases/download/${spotbugs.version}/spotbugs-${spotbugs.version}.zip"
dest="${downloads.dir}/spotbugs-${spotbugs.version}.zip"
skipexisting="true"/>
<unzip src="${downloads.dir}/spotbugs-${spotbugs.version}.zip"
dest="${tools.dir}/spotbugs"
overwrite="false"/>
<get src="https://github.com/pmd/pmd/releases/download/pmd_releases%2F${pmd.version}/pmd-dist-${pmd.version}-bin.zip"
dest="${downloads.dir}/pmd-dist-${pmd.version}-bin.zip"
skipexisting="true"/>
<unzip src="${downloads.dir}/pmd-dist-${pmd.version}-bin.zip"
dest="${tools.dir}/pmd"
overwrite="false"/>
<get src="https://github.com/jacoco/jacoco/releases/download/v${jacoco.version}/jacoco-${jacoco.version}.zip"
dest="${downloads.dir}/jacoco-${jacoco.version}.zip"
skipexisting="true"/>
<unzip src="${downloads.dir}/jacoco-${jacoco.version}.zip"
dest="${jacoco.home}"
overwrite="false"/>
</target>
<!-- ============================================================ -->
<!-- clean: remove all generated files -->
<!-- ============================================================ -->
<target name="clean" description="Remove generated build artifacts">
<delete dir="${build.dir}"/>
</target>
<!-- ============================================================ -->
<!-- compile: compile main source files -->
<!-- ============================================================ -->
<target name="compile" description="Compile main source files">
<mkdir dir="${classes.dir}"/>
<javac srcdir="${src.main.dir}"
destdir="${classes.dir}"
release="${java.release.version}"
encoding="UTF-8"
includeantruntime="false"
debug="true"
deprecation="true">
<classpath refid="compile.classpath"/>
</javac>
</target>
<!-- ============================================================ -->
<!-- compile-tests: compile test source files -->
<!-- ============================================================ -->
<target name="compile-tests" depends="compile"
description="Compile JUnit 5 test source files">
<mkdir dir="${test.classes.dir}"/>
<javac srcdir="${src.test.dir}"
destdir="${test.classes.dir}"
release="${java.release.version}"
encoding="UTF-8"
includeantruntime="false"
debug="true">
<classpath refid="test.compile.classpath"/>
</javac>
</target>
<!-- ============================================================ -->
<!-- test: run JUnit 5 tests via the junitlauncher task -->
<!-- ============================================================ -->
<target name="test" depends="compile-tests"
description="Run JUnit 5 tests and generate reports">
<mkdir dir="${reports.dir}"/>
<junitlauncher haltOnFailure="true" printSummary="true">
<classpath refid="test.run.classpath"/>
<testclasses outputdir="${reports.dir}">
<fileset dir="${test.classes.dir}" includes="**/*Test.class"/>
<!-- XML report (compatible with CI tools) -->
<listener type="legacy-xml"
sendSysOut="true"
sendSysErr="true"/>
<!-- Plain-text summary to stdout -->
<listener type="legacy-plain"
sendSysOut="true"/>
</testclasses>
</junitlauncher>
</target>
<!-- ============================================================ -->
<!-- javadoc: generate API documentation into docs/ -->
<!-- ============================================================ -->
<target name="javadoc" depends="compile"
description="Generate Javadoc API documentation">
<mkdir dir="${javadoc.dir}"/>
<javadoc sourcepath="${src.main.dir}"
destdir="${javadoc.dir}"
packagenames="simulation.*"
author="true"
version="true"
use="true"
windowtitle="${project.name} ${project.version} API"
doctitle="${project.name} ${project.version}"
encoding="UTF-8"
charset="UTF-8"
docencoding="UTF-8"
failonerror="true">
<classpath refid="compile.classpath"/>
<link href="https://docs.oracle.com/en/java/javase/17/docs/api/"/>
</javadoc>
</target>
<!-- ============================================================ -->
<!-- jar: package compiled classes into a JAR file -->
<!-- ============================================================ -->
<target name="jar" depends="compile"
description="Package compiled classes into ${jar.file}">
<jar destfile="${jar.file}"
basedir="${classes.dir}">
<manifest>
<attribute name="Implementation-Title" value="${project.name}"/>
<attribute name="Implementation-Version" value="${project.version}"/>
</manifest>
</jar>
</target>
<!-- ============================================================ -->
<!-- all: full build pipeline -->
<!-- ============================================================ -->
<target name="all" depends="clean,quality,javadoc,jar"
description="Clean, run quality checks, build Javadoc, and create JAR"/>
<!-- ============================================================ -->
<!-- checkstyle: style analysis -->
<!-- ============================================================ -->
<target name="checkstyle" depends="resolve-tools,compile"
description="Run Checkstyle style analysis">
<mkdir dir="${reports.dir}"/>
<taskdef resource="com/puppycrawl/tools/checkstyle/ant/checkstyle-ant-task.properties"
classpathref="checkstyle.classpath"/>
<checkstyle config="checkstyle.xml" failOnViolation="true">
<fileset dir="${src.main.dir}" includes="**/*.java"/>
<fileset dir="${src.test.dir}" includes="**/*.java"/>
<formatter type="plain"/>
<formatter type="xml" tofile="${reports.dir}/checkstyle.xml"/>
</checkstyle>
</target>
<!-- ============================================================ -->
<!-- spotbugs: static bug analysis -->
<!-- ============================================================ -->
<target name="spotbugs" depends="resolve-tools,jar"
description="Run SpotBugs static analysis">
<mkdir dir="${reports.dir}"/>
<taskdef name="spotbugs"
classname="edu.umd.cs.findbugs.anttask.FindBugsTask"
classpathref="spotbugs.classpath"/>
<spotbugs home="${spotbugs.home}"
output="html"
outputFile="${reports.dir}/spotbugs.html"
effort="max"
reportLevel="medium"
jvmargs="-Xmx512m"
failOnError="false"
setExitCode="true"
warningsProperty="spotbugs.warnings"
excludeFilter="spotbugs-exclude.xml">
<auxClasspath refid="lib.classpath"/>
<sourcePath path="${src.main.dir}"/>
<class location="${jar.file}"/>
</spotbugs>
<fail if="spotbugs.warnings"
message="SpotBugs found warnings; see ${reports.dir}/spotbugs.html"/>
</target>
<!-- ============================================================ -->
<!-- pmd: source code analysis -->
<!-- ============================================================ -->
<target name="pmd" depends="resolve-tools"
description="Run PMD source code analysis">
<mkdir dir="${reports.dir}"/>
<taskdef name="pmd"
classname="net.sourceforge.pmd.ant.PMDTask"
classpathref="pmd.classpath"/>
<pmd rulesetfiles="pmd-ruleset.xml"
failOnRuleViolation="true">
<formatter type="html" toFile="${reports.dir}/pmd.html"/>
<formatter type="summaryhtml" toFile="${reports.dir}/pmd-summary.html"/>
<formatter type="xml" toFile="${reports.dir}/pmd.xml"/>
<fileset dir="${src.main.dir}" includes="**/*.java"/>
<fileset dir="${src.test.dir}" includes="**/*.java"/>
</pmd>
</target>
<!-- ============================================================ -->
<!-- coverage: JaCoCo code coverage -->
<!-- ============================================================ -->
<target name="coverage" depends="resolve-tools,compile-tests"
description="Run tests with JaCoCo coverage instrumentation">
<taskdef uri="antlib:org.jacoco.ant"
resource="org/jacoco/ant/antlib.xml"
classpathref="jacoco.classpath"/>
<jacoco:agent property="jacoco.agent.arg"
destfile="${jacoco.exec.file}"
includes="simulation.*"/>
<java classname="org.junit.platform.console.ConsoleLauncher"
fork="true"
failonerror="true">
<jvmarg line="${jacoco.agent.arg}"/>
<classpath>
<pathelement location="${junit.console.jar}"/>
<pathelement location="${test.classes.dir}"/>
<pathelement location="${classes.dir}"/>
</classpath>
<arg value="execute"/>
<arg value="--class-path"/>
<arg path="${test.classes.dir}${path.separator}${classes.dir}"/>
<arg value="--scan-class-path"/>
<arg value="${test.classes.dir}"/>
</java>
<jacoco:report>
<executiondata>
<file file="${jacoco.exec.file}"/>
</executiondata>
<structure name="${project.name}">
<classfiles>
<fileset dir="${classes.dir}"/>
</classfiles>
<sourcefiles encoding="UTF-8">
<fileset dir="${src.main.dir}"/>
</sourcefiles>
</structure>
<html destdir="${reports.dir}/coverage"/>
<xml destfile="${reports.dir}/jacoco.xml"/>
</jacoco:report>
</target>
<!-- ============================================================ -->
<!-- quality: run every verification tool -->
<!-- ============================================================ -->
<target name="quality" depends="test,checkstyle,pmd,spotbugs,coverage"
description="Run tests, style checks, static analysis, and coverage"/>
</project>