-
Notifications
You must be signed in to change notification settings - Fork 3
/
build-dev.xml
353 lines (291 loc) · 11.6 KB
/
build-dev.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
<project name="VStar" default="dist" basedir=".">
<description>
Ant build file for VStar.
</description>
<!-- Cobertura task definition -->
<property name="cobertura" value="${basedir}/extlib/cobertura-1.9.3" />
<path id="cobertura.classpath">
<fileset dir="${cobertura}">
<include name="cobertura.jar" />
<include name="lib/**/*.jar" />
</fileset>
</path>
<taskdef classpathref="cobertura.classpath" resource="tasks.properties" />
<!--
<taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask"/>
-->
<!-- Set global properties for this build -->
<property name="src" location="src" />
<property name="test" location="test" />
<property name="script" location="script" />
<property name="plugin" location="plugin" />
<property name="src_build" location="src/build" />
<property name="src_build_debug" location="src/build_debug" />
<property name="test_build" location="test/build" />
<property name="manifest_file" location="MANIFEST.MF" />
<property name="dist" location="dist" />
<property name="dist_debug" location="dist_debug" />
<property name="extlib" location="extlib" />
<property name="ui_resources" location="src/org/aavso/tools/vstar/ui/resources" />
<property name="test_report" location="test_report" />
<property name="instrumented" location="instrumented" />
<property name="coverage_report" location="coverage_report" />
<property name="jdepend_report" location="jdepend-report.txt" />
<property name="doc" location="doc" />
<property name="findbugs.home" value="/Users/david/java/lib/findbugs-2.0.1" />
<property name="javadoc" location="doc/vstar_docs" />
<!-- Classpaths -->
<path id="build.classpath">
<fileset dir="${extlib}" includes="*.jar" excludes="junit*.jar" />
</path>
<path id="test.classpath">
<fileset dir="${extlib}" includes="*.jar" />
<pathelement location="${dist}/vstar.jar" />
<pathelement path="${test_build}" />
</path>
<path id="coverage.classpath">
<fileset dir="${extlib}" includes="*.jar" />
<pathelement path="${src_build_debug}" />
<pathelement location="${dist}/vstar.jar" />
<pathelement path="${test_build}" />
</path>
<target name="init">
<!-- Create the time stamp -->
<tstamp />
<!-- Create the build directory structure used by compile and test. -->
<mkdir dir="${src_build}" />
<mkdir dir="${src_build_debug}" />
<mkdir dir="${test_build}" />
<mkdir dir="${test_report}" />
</target>
<!-- Build targets -->
<target name="antlr4" depends="init" description="Generate Java source code from ANTLR VeLa grammar.">
<java jar="${extlib}/antlr-4.5.3-complete.jar" fork="true">
<arg value="${src}/org/aavso/tools/vstar/vela/VeLa.g4" />
<arg value="-o" />
<arg value="${src}/org/aavso/tools/vstar/vela" />
<arg value="-listener" />
<arg value="-visitor" />
<arg value="-package" />
<arg value="org.aavso.tools.vstar.vela" />
<arg value="-encoding" />
<arg value="UTF-8" />
</java>
</target>
<target name="compile_src" depends="init,antlr4" description="Compile the source">
<!-- Update svn revision -->
<exec outputproperty="svn_revision" executable="svnversion">
<arg value="-n" />
</exec>
<copy file="${ui_resources}/RevisionAccessor.java.template" tofile="${ui_resources}/RevisionAccessor.java" overwrite="true" />
<replace file="${ui_resources}/RevisionAccessor.java" token="@revision@" value="${svn_revision}" />
<!-- Compile source -->
<javac compiler="modern" source="1.8" target="1.8" srcdir="${src}" destdir="${src_build}" includeantruntime="false">
<classpath refid="build.classpath" />
</javac>
</target>
<target name="debug" depends="init, manifest" description="Compile the source">
<!-- Compile source. -->
<javac compiler="modern" source="1.8" target="1.8" srcdir="${src}" destdir="${src_build_debug}" debug="on" debuglevel="lines,vars,source" includeantruntime="false">
<classpath refid="build.classpath" />
</javac>
<mkdir dir="${dist_debug}" />
<jar jarfile="${dist_debug}/vstar.jar" basedir="${src_build_debug}" manifest="${manifest_file}" excludes="**/external/plugin/*.class">
<fileset dir="${ui_resources}" />
</jar>
<delete file="${manifest_file}" />
</target>
<target name="manifest" description="Creates a manifest file for VStar">
<manifestclasspath property="jar.classpath" jarfile="${dist}/vstar.jar">
<classpath refid="build.classpath" />
</manifestclasspath>
<manifest file="${manifest_file}">
<attribute name="Application-Name" value="VStar" />
<attribute name="Manifest-Version" value="1.0" />
<attribute name="Created-By" value="${user.name}" />
<attribute name="Main-Class" value="org.aavso.tools.vstar.ui.VStar" />
<attribute name="Class-Path" value="${jar.classpath}" />
<attribute name="Permissions" value="all-permissions" />
<!--
<attribute name="Codebase" value="http://www.aavso.org/files/vstar/" />
-->
</manifest>
</target>
<target name="dist" depends="compile_src, manifest" description="Generate the distribution">
<mkdir dir="${dist}" />
<jar jarfile="${dist}/vstar.jar" basedir="${src_build}" manifest="${manifest_file}" excludes="**/external/plugin/*.class">
<fileset dir="${ui_resources}" />
</jar>
<delete file="${manifest_file}" />
</target>
<target name="zip" depends="dist" description="Create a Zip archive suitable for deploying a standalone distribution.">
<zip destfile="vstar.zip">
<zipfileset dir="${dist}" prefix="vstar/dist" />
<zipfileset dir="${extlib}" prefix="vstar/extlib">
<exclude name="cobertura*"/>
<exclude name="cobertura*/**"/>
<exclude name="junit*"/>
</zipfileset>
<zipfileset dir="${doc}" prefix="vstar/doc">
<exclude name="plan/**" />
<exclude name="slides/**" />
</zipfileset>
<zipfileset dir="${plugin}" prefix="vstar/plugin" />
<zipfileset dir="${script}" includes="run_vstar.*" prefix="vstar/script" filemode="755"/>
<zipfileset dir="data" prefix="vstar/data" />
<zipfileset file="jnlp.*" prefix="vstar" />
<zipfileset file="ReadMe.txt" prefix="vstar" />
<zipfileset file="FAQ.txt" prefix="vstar" />
<zipfileset file="ChangeLog.txt" prefix="vstar" />
</zip>
</target>
<!-- Run targets -->
<target name="run" depends="dist" description="Run VStar GUI">
<java fork="true" jar="${dist}/vstar.jar">
<jvmarg value="-ea" />
</java>
</target>
<target name="run_debug" depends="debug" description="Run debug VStar GUI">
<java jar="${dist_debug}/vstar.jar" fork="true">
<sysproperty key="DEBUG" value="true" />
<arg value="-h" />
<jvmarg value="-Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y" />
<jvmarg value="-ea" />
</java>
</target>
<!-- Unit test targets -->
<target name="compile_ut" depends="dist" description="Compile the test code">
<javac compiler="modern" source="1.8" target="1.8" srcdir="${test}" destdir="${test_build}">
<classpath refid="test.classpath" />
</javac>
</target>
<target name="test" depends="compile_ut" description="Run unit tests">
<!-- Run the tests. -->
<junit fork="yes" printsummary="withOutAndErr" showoutput="true">
<formatter type="plain" />
<jvmarg value="-ea" />
<formatter type="plain" />
<test name="${testcase}" todir="${test_report}" if="testcase" />
<batchtest todir="${test_report}" unless="testcase">
<fileset dir="${test}">
<include name="**/*Test.java" />
</fileset>
</batchtest>
<classpath refid="test.classpath" />
</junit>
<!-- Generate a summary report file to make it easier to spot failures. -->
<concat destfile="${test_report}/summary.txt">
<header filtering="no" trimleading="yes">
Test Summary
============
</header>
<path>
<fileset dir="${test_report}" includes="TEST-*" />
</path>
<filterchain>
<linecontains>
<contains value="Tests run:" />
</linecontains>
</filterchain>
</concat>
</target>
<!-- Test coverage targets -->
<target name="coverage_instrument" description="Cobertura coverage instrumentation">
<delete file="${basedir}/cobertura.ser" />
<!-- Compile source as debug. -->
<javac compiler="modern" source="1.8" target="1.8" srcdir="${src}" destdir="${src_build_debug}" debug="on" debuglevel="lines,vars,source">
<classpath refid="build.classpath" />
</javac>
<!-- Compile UT code. -->
<javac srcdir="${test}" destdir="${test_build}">
<classpath refid="coverage.classpath" />
</javac>
<cobertura-instrument todir="${instrumented}">
<fileset dir="${src_build_debug}">
<include name="**/*.class" />
</fileset>
</cobertura-instrument>
</target>
<target name="test_coverage" depends="coverage_instrument" description="Collect coverage data from a UT run">
<junit fork="yes" printsummary="withOutAndErr" showoutput="true">
<!--
Specify the name of the coverage data file to use.
The value specified below is the default.
-->
<sysproperty key="net.sourceforge.cobertura.datafile" file="${basedir}/cobertura.ser" />
<!--
Note the classpath order: instrumented classes are before the
original (uninstrumented) classes. This is important.
-->
<classpath location="${instrumented}" />
<classpath refid="coverage.classpath" />
<!--
The instrumented classes reference classes used by the
Cobertura runtime, so Cobertura and its dependencies
must be on the classpath.
-->
<classpath refid="cobertura.classpath" />
<jvmarg value="-ea" />
<formatter type="plain" />
<test name="${testcase}" todir="${test_report}" if="testcase" />
<batchtest todir="${test_report}" unless="testcase">
<fileset dir="${test}">
<include name="**/*Test.java" />
</fileset>
</batchtest>
</junit>
</target>
<target name="coverage_report" depends="test_coverage" description="Generate a UT coverage report">
<cobertura-report format="html" destdir="${coverage_report}" srcdir="${src}" />
</target>
<!-- Code analysis targets -->
<!--
<target name="jdepend" depends="compile_src" description="Dependency analysis">
<jdepend outputfile="${jdepend_report}">
<exclude name="java.*" />
<exclude name="javax.*" />
<classespath>
<pathelement location="${dist}/vstar.jar" />
</classespath>
<classpath refid="build.classpath" />
</jdepend>
</target>
-->
<target name="findbugs" depends="dist">
<findbugs home="${findbugs.home}"
output="html"
outputFile="vstar-fb.html" >
<sourcePath path="${basedir}/src" />
<class location="${basedir}/dist/vstar.jar" />
</findbugs>
</target>
<!-- Documentation targets -->
<target name="javadoc" description="Javadoc generation">
<delete failonerror="false" includeemptydirs="true">
<fileset dir="${javadoc}" includes="**/*" />
</delete>
<javadoc sourcepath="${src}" destdir="${javadoc}"
classpathref="build.classpath"
header="VStar" />
<zip destfile="${doc}/vstar_docs.zip"
basedir="${doc}"
includes="vstar_docs/**/*" />
</target>
<!-- Clean targets -->
<target name="clean" description="Clean up">
<delete failonerror="false" includeemptydirs="true">
<!-- Delete the build, dist, UT, coverage directory trees -->
<fileset dir="${src_build}" includes="**/*" />
<fileset dir="${src_build_debug}" includes="**/*" />
<fileset dir="${test_build}" includes="**/*" />
<fileset dir="${dist}" includes="**/*" />
<fileset dir="${dist_debug}" includes="**/*" />
<fileset dir="${test_report}" includes="**/*" />
<fileset dir="${instrumented}" includes="**/*" />
<fileset dir="${coverage_report}" includes="**/*" />
<fileset dir="${basedir}" includes="cobertura.ser" />
<fileset dir="${basedir}" includes="${jdepend_report}" />
<fileset file="vstar.zip" />
</delete>
</target>
</project>