-
Notifications
You must be signed in to change notification settings - Fork 23
/
build.xml
360 lines (326 loc) · 16.9 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
<?xml version="1.0"?>
<!-- Copyright (C) 1989-2022 PC2 Development Team: John Clevenger, Douglas Lane, Samir Ashoo, and Troy Boudreau. -->
<project name="pc2v9" default="jar" basedir=".">
<description>
v9 build file
</description>
<!-- set global properties for this build -->
<property name="lastGITLABbuild" value="6259" />
<property name="apt.build.javac.target" value="1.8" />
<property name="apt.build.javac.source" value="1.8" />
<property name="src.dir" location="src" />
<property name="test.dir" location="test" />
<property name="build.dir" location="build" />
<property name="data.dir" location="data" />
<property name="build.prod.dir" location="${build.dir}/prod" />
<property name="build.test.dir" location="${build.dir}/test" />
<property name="testresults.dir" location="${build.dir}/test-results" />
<property name="version.path" value="${build.dir}/VERSION"/>
<property name="spec.path" value="${build.dir}/pc2.spec"/>
<property name="testresults.xml.dir" location="${testresults.dir}/xml" />
<property name="testresults.html.dir" location="${testresults.dir}/html" />
<property name="compilelogs.dir" location="${build.dir}" />
<property name="docs.dir" location="${build.dir}/docs" />
<property name="docs.api.dir" location="${docs.dir}/api" />
<property name="dist.dir" location="dist" />
<!-- this should change one the location of mclb.jar changes -->
<property name="vendor.lib.dir" location="${basedir}/vendor/lib"/>
<property name="packagelistloc.dir" location="${basedir}/vendor/api-1.5.0/"/>
<property name="scripts.dir" location="${basedir}/bin"/>
<property name="samps.dir" location="${basedir}/samps"/>
<property name="intscripts.dir" location="${basedir}/scripts"/>
<property name="support.dir" location="${basedir}/support"/>
<property name="projects.dir" location="${basedir}/projects"/>
<!-- used in javadocs linkoffline, this is the location on
the build host, override on the ant commandline -->
<property name="api.url" location="/software/pc2/java/docs/api/"/>
<!-- Compiler settings. -->
<property name="javacFailOnError" value="true"/>
<property name="javacDebugInfo" value="true"/>
<property name="javacVerbose" value="off"/>
<property name="logExtension" value=".log"/>
<property name="compilerArg" value=""/>
<property name="javacSource" value="1.8"/>
<property name="javacTarget" value="1.8"/>
<path id="path_bootclasspath">
<fileset dir="${java.home}/lib">
<include name="*.jar"/>
</fileset>
</path>
<property name="bootclasspath" refid="path_bootclasspath"/>
<property name="bundleJavacSource" value="${javacSource}"/>
<property name="bundleJavacTarget" value="${javacTarget}"/>
<property name="bundleBootClasspath" value="${bootclasspath}"/>
<property name="name" value="pc2"/>
<property name="jar.name" value="${name}.jar"/>
<property name="jar.path" value="${dist.dir}/${jar.name}"/>
<property environment="env"/>
<condition property="exists.GITHUB_RUN_NUMBER">
<isset property="env.GITHUB_RUN_NUMBER"/>
</condition>
<tstamp>
<format property="date" pattern="yyyyMMdd" timezone="UTC" />
</tstamp>
<tstamp>
<format property="time" pattern="HHmm" timezone="UTC" />
</tstamp>
<property name="timestamp" value="${date}${time}" />
<tstamp>
<format
property="date.english"
pattern="EEEE, MMMM d yyyy"
timezone="UTC" />
</tstamp>
<tstamp>
<format
property="time.english"
pattern="HH:mm z"
timezone="UTC" />
</tstamp>
<property
name="timestamp.english"
value="${date.english} ${time.english}" />
<!-- version is used in the jar manifest & in package.xml -->
<property name="version" value="9.11build"/>
<path id="project.classpath">
<pathelement location="${build.prod.dir}"/>
<pathelement location="${build.test.dir}"/>
<fileset dir="${vendor.lib.dir}">
<include name="*.jar"/>
</fileset>
</path>
<path id="checkstyle.classpath">
<fileset dir="${vendor.lib.dir}">
<include name="checkstyle*.jar"/>
</fileset>
</path>
<property environment="env"/>
<macrodef name="add">
<attribute name="operand1"/>
<attribute name="operand2"/>
<attribute name="result"/>
<sequential>
<script language="javascript">
tmp = parseInt("@{operand1}") + parseInt("@{operand2}");
project.setProperty("@{result}", tmp);
</script>
</sequential>
</macrodef>
<target name="properties">
<available classname="org.eclipse.jdt.core.JDTCompilerAdapter" property="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
<condition property="git_hash" value="${env.GIT_COMMIT}" else="HEAD">
<isset property="env.GIT_COMMIT"/>
</condition>
</target>
<target name="jarSkipTests" description="create jar file skip unit tests">
<property name="RUN_NO_TESTS" value="Yes"/>
<antcall target="jar"/>
</target>
<target name="jarSkipTestsAndSubprojectBuilds" description="create jar file skip unit tests do not build sub projects">
<property name="RUN_NO_TESTS" value="Yes"/>
<property name="BUILD_NO_SUBPROJECTS" value="Yes"/>
<antcall target="jar"/>
</target>
<target name="jarSkipBuildSubprojects" description="create jar file, run unit tests, skip building sub projects ">
<property name="BUILD_NO_SUBPROJECTS" value="Yes"/>
<antcall target="jar"/>
</target>
<target name="init" depends="properties, -execgit, -getenv">
<taskdef resource="com/puppycrawl/tools/checkstyle/ant/checkstyle-ant-task.properties" classpathref="checkstyle.classpath"/>
<!-- Create the time stamp -->
<tstamp />
</target>
<target name="-execgit" unless="exists.GITHUB_RUN_NUMBER">
<exec executable="git" outputproperty="repo.version" failifexecutionfails="false" errorproperty="">
<arg value="rev-list"/>
<arg value="${git_hash}"/>
<arg value="--count"/>
</exec>
<!-- if above failed, set the repo.version to 0 -->
<condition property="repo.version" value="0">
<not>
<isset property="repo.version"/>
</not>
</condition>
</target>
<target name="-getenv" if="exists.GITHUB_RUN_NUMBER">
<add operand1="${lastGITLABbuild}" operand2="${env.GITHUB_RUN_NUMBER}" result="repo.version0"/>
<!--
TODO consider switching back to this at 9.8.0/9.9build
<property name="repo.version0" value="${env.GITHUB_RUN_NUMBER}"/>
-->
<condition property="version.add" value="~${env.GITHUB_REF_NAME}" else="">
<not>
<equals arg1="${env.GITHUB_REF_NAME}" arg2="master"/>
</not>
</condition>
<property name="repo.version" value="${repo.version0}${version.add}"/>
</target>
<target name="compile" depends="init,checkstyle" description="compile the source ">
<!-- Create the build directory structure used by compile -->
<mkdir dir="${build.prod.dir}" />
<mkdir dir="${build.test.dir}" />
<mkdir dir="${compilelogs.dir}" />
<!-- Compile the java code from ${src.dir} into ${build.dir} -->
<javac srcdir="${src.dir}" destdir="${build.prod.dir}" failonerror="${javacFailOnError}" verbose="${javacVerbose}" debug="${javacDebugInfo}" includeAntRuntime="no" classpath="${bundleBootClasspath}" source="${bundleJavacSource}" target="${bundleJavacTarget}">
<compilerarg line="${compilerArg}" compiler="${build.compiler}"/>
<classpath refid="project.classpath"/>
<!-- <compilerarg value="" compiler="org.eclipse.jdt.core.JDTCompilerAdapter"/> -->
<compilerarg line="-log '${compilelogs.dir}/${name}.prod${logExtension}'" compiler="org.eclipse.jdt.core.JDTCompilerAdapter"/>
</javac>
</target>
<target name="compile-tests" depends="compile" description="compile the junit tests">
<javac srcdir="${test.dir}" destdir="${build.test.dir}" failonerror="${javacFailOnError}" verbose="${javacVerbose}" debug="${javacDebugInfo}" includeAntRuntime="no" classpath="${bundleBootClasspath}" source="${bundleJavacSource}" target="${bundleJavacTarget}">
<compilerarg line="${compilerArg}" compiler="${build.compiler}"/>
<classpath refid="project.classpath"/>
<!-- <compilerarg value="" compiler="org.eclipse.jdt.core.JDTCompilerAdapter"/> -->
<compilerarg line="-log '${compilelogs.dir}/${name}.test${logExtension}'" compiler="org.eclipse.jdt.core.JDTCompilerAdapter"/>
</javac>
</target>
<!-- test only AllTests.class classes -->
<target name="old_test" depends="compile-tests" description="run junit tests">
<delete dir="${testresults.dir}"/>
<mkdir dir="${testresults.xml.dir}"/>
<junit errorProperty="test.failed" failureProperty="test.failed">
<classpath refid="project.classpath"/>
<formatter type="brief" usefile="false"/>
<formatter type="xml"/>
<batchtest todir="${testresults.xml.dir}">
<fileset dir="${build.test.dir}" includes="**/AllTests.class"/>
</batchtest>
</junit>
<!-- remove TEST- from filenames -->
<move todir="${testresults.xml.dir}">
<fileset dir="${testresults.xml.dir}" includes="**/*"/>
<mapper type="glob" from="TEST-*" to="*"/>
</move>
<fail message="Tests failed! Check test reports.">
<condition>
<and>
<isset property="test.failed"/>
<not>
<isset property="cruisecontrol"/>
</not>
</and>
</condition>
</fail>
</target>
<target name="version" depends="init" description="re-creates the VERSION file">
<delete file="${version.path}"/>
<echo message="CSUS Programming Contest Control System${line.separator}" file="${version.path}"/>
<echo message="Version ${version} ${date} ${repo.version} (${timestamp.english})${line.separator}" file="${version.path}" append="true"/>
<delete file="${spec.path}"/>
<echo message="Version: ${version}${line.separator}Release: ${repo.version}${line.separator}" file="${spec.path}"/>
<concat destfile="${spec.path}" append="true">
<fileset file=".spec.base"/>
</concat>
</target>
<target name="jar" depends="test" description="creates a jar of our classes">
<antcall target="version"/>
<mkdir dir="${dist.dir}" />
<!-- include the images in the jar -->
<copy file="images/csus_logo.png" todir="${build.prod.dir}/images"/>
<copy file="images/ICPCWebMast_small.png" todir="${build.prod.dir}/images"/>
<copy file="images/icpc_logo.png" todir="${build.prod.dir}/images"/>
<copy file="images/PC2Logo.png" todir="${build.prod.dir}/images"/>
<copy file="images/PC2Logo.ico" todir="${build.prod.dir}/images"/>
<!-- consider doing the manifest in a separate target
then the Version can be ommitted if not set -->
<jar jarfile="${jar.path}" basedir="${build.prod.dir}">
<manifest>
<attribute name="Specification-Version" value="${version}"/>
<attribute name="Implementation-Title" value="CSUS Programming Contest Control System"/>
<attribute name="Implementation-Version" value="${repo.version}"/>
<attribute name="Built-On" value="${timestamp.english}"/>
<attribute name="Built-On-Date" value="${date}"/>
<attribute name="Main-Class" value="edu.csus.ecs.pc2.Starter"/>
</manifest>
</jar>
<antcall target="buildSubProjects"/>
</target>
<!-- build sub-projects unless BUILD_NO_SUBPROJECTS defined -->
<target name="buildSubProjects" unless="BUILD_NO_SUBPROJECTS" description="build sub projects ">
<!-- Build the WebTeamInterface (WTI) project (which also implicitly builds WTI-UI) and copy it to the "projects" folder. -->
<ant dir="projects/WTI-API" antfile="packageWTI.xml" useNativeBasedir="true" inheritAll="false"/>
<!-- Copy the archive (zip and tar.gz) files of the WTI project to the projects folder -->
<copy todir="projects">
<fileset dir="projects/WTI-API/dist" includes="WebTeamInterface*.tar.gz"/>
<fileset dir="projects/WTI-API/dist" includes="WebTeamInterface*.zip"/>
</copy>
</target>
<target name="clean" description="clean up">
<!-- Delete the ${build.dir} and ${dist.dir} directory trees -->
<delete dir="${build.dir}" />
<delete dir="${dist.dir}" />
<!-- junit intended output -->
<delete dir="testout" />
<!-- and crap dumped by junit tests -->
<delete dir="profiles" />
<delete dir="logs" />
<delete dir="executesite2judge1" />
<delete file="profiles.properties" />
<delete file="teams.output.txt" />
<delete>
<fileset dir="projects" includes="EWTeam-*"/>
<fileset dir="projects" includes="WebTeamInterface-*"/>
</delete>
</target>
<target name="checkstyle" unless="RUN_NO_TESTS" description="Generates a report of code convention violations." depends="init">
<mkdir dir="${build.dir}"/>
<checkstyle config="${basedir}/.pc2_checks.xml" failureProperty="checkstyle.failure" failOnViolation="false">
<formatter type="xml" tofile="${build.dir}/checkstyle-result.xml" />
<fileset dir="src" includes="**/*.java" />
<classpath refid="checkstyle.classpath"/>
</checkstyle>
<xslt in="${build.dir}/checkstyle-result.xml" out="${build.dir}/checkstyle-result.html" style="checkstyle.xsl" />
</target>
<!-- run this target as part of automated build -->
<target name="checkstyle-nightly" depends="checkstyle" if="checkstyle.failure" description="Sends email if checkstyle detected code conventions violations.">
<mail from="pc2@ecs.csus.edu" tolist="boudreat@gaia.ecs.csus.edu" mailhost="gaia.ecs.csus.edu" subject="Checkstyle violation(s) in project ${ant.project.name}" files="${build.dir}/checkstyle-result.html" />
</target>
<target name="javadocs-api" description="Creates API javadocs">
<mkdir dir="${docs.api.dir}" />
<javadoc access="protected" author="true" classpath="vendor/lib/mclb.jar:vendor/lib/jackson-annotations-2.5.4.jar:vendor/lib/jackson-databind-2.5.4.jar:vendor/lib/jackson-core-2.5.4.jar:vendor/lib/snakeyaml-1.16.jar"
destdir="${docs.api.dir}" doctitle="PC&sup2; Version 9 API" nodeprecated="false" nodeprecatedlist="false" noindex="false" nonavbar="false" notree="false" overview="api_overview.html" packagenames="edu.csus.ecs.pc2.api,edu.csus.ecs.pc2.api.exceptions,edu.csus.ecs.pc2.api.listener" source="1.8" sourcepath="src" splitindex="true" use="true" version="true" useexternalfile="true">
<link offline="true" href="http://java.sun.com/j2se/1.5.0/docs/api/" packagelistloc="${packagelistloc.dir}"/>
</javadoc>
</target>
<target name="javadocs" description="Creates project javadocs">
<mkdir dir="${docs.dir}/api-full" />
<javadoc sourcepath="${src.dir}" destdir="${docs.dir}/api-full" defaultexcludes="yes" packagenames="edu.csus.ecs.pc2.*" doctitle="PC^2 Version 9 Java Documentation" Use="yes" SplitIndex="yes" linkoffline="http://java.sun.com/j2se/1.5.0/docs/api/ ${api.url}" classpathref="project.classpath">
<link offline="true" href="http://java.sun.com/j2se/1.5.0/docs/api/" packagelistloc="${packagelistloc.dir}"/>
</javadoc>
</target>
<!-- run test unless RUN_NO_TESTS defined -->
<target name="test" depends="compile-tests" unless="RUN_NO_TESTS" description="run junit tests">
<delete dir="${testresults.dir}"/>
<mkdir dir="${testresults.xml.dir}"/>
<junit errorProperty="test.failed" failureProperty="test.failed" fork="yes">
<jvmarg value="-Djdk.crypto.KeyAgreement.legacyKDF=true"/>
<classpath refid="project.classpath"/>
<formatter type="brief" usefile="false"/>
<formatter type="xml"/>
<batchtest todir="${testresults.xml.dir}">
<fileset dir="${build.test.dir}">
<include name="**/*Test.class" />
<exclude name="**/Version10AbstractTest.class" />
</fileset>
</batchtest>
</junit>
<!-- remove TEST- from filenames -->
<move todir="${testresults.xml.dir}">
<fileset dir="${testresults.xml.dir}" includes="**/*"/>
<mapper type="glob" from="TEST-*" to="*"/>
</move>
<fail message="Tests failed! Check test reports.">
<condition>
<and>
<isset property="test.failed"/>
<not>
<isset property="cruisecontrol"/>
</not>
</and>
</condition>
</fail>
</target>
</project>