forked from aferro/java-example
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.xml
More file actions
251 lines (228 loc) · 7.16 KB
/
build.xml
File metadata and controls
251 lines (228 loc) · 7.16 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
<?xml version="1.0"?>
<project name="math" default="all">
<description>
Build file for maths examples.
</description>
<!-- Base directory. -->
<dirname property="base.dir" file="${ant.file.math}"/>
<!-- Load ant.properties -->
<property file="${base.dir}/ant.properties"/>
<!-- Libraries -->
<property name="lib.dir" value="${base.dir}/lib"/>
<!-- Source directories. -->
<property name="src.dir" value="${base.dir}/src"/>
<property name="test.src.dir" value="${base.dir}/test"/>
<!-- Build directories. -->
<property name="build.dir" value="${base.dir}/build"/>
<property name="build.classes.dir" value="${build.dir}/bin"/>
<property name="test.classes.dir" value="${build.dir}/test-bin"/>
<property name="test.report.xml.dir"
value="${build.dir}/test-xml"/>
<property name="test.report.html.dir"
value="${build.dir}/test-html"/>
<!-- Build control. -->
<property name="java.debug" value="on"/>
<property name="java.deprecation" value="off"/>
<property name="compiler.jvmarg" value=""/>
<!-- JAR names -->
<property name="jar.name" value="math.jar"/>
<property name="test.jar.name" value="math-test.jar"/>
<!-- CLASSPATH -->
<path id="classpath">
<pathelement path="${build.classes.dir}"/>
<pathelement path="${test.classes.dir}"/>
<fileset dir="${lib.dir}">
<include name="**/*.jar"/>
</fileset>
</path>
<!--
Make build directory.
-->
<target name="init" description="Make build directory">
<mkdir dir="${build.dir}"/>
<mkdir dir="${build.classes.dir}"/>
<mkdir dir="${test.classes.dir}"/>
<mkdir dir="${lib.dir}"/>
</target>
<!--
Remove build directory.
-->
<target name="clean" description="Remove build directory">
<delete dir="${build.dir}"/>
<delete>
<fileset dir="${lib.dir}">
<include name="**/math*.jar"/>
</fileset>
</delete>
</target>
<!--
Compile code.
-->
<target name="compile" description="Compile code" depends="init">
<compile src="${src.dir}" bin="${build.classes.dir}"
classpathref="classpath"/>
</target>
<!--
JAR classes.
-->
<target name="jar" description="JAR classes"
depends="compile, createManifest">
<makeJAR bin="${build.classes.dir}" lib="${lib.dir}" name="${jar.name}"
manifest="${build.dir}/MANIFEST.MF"/>
</target>
<!--
Compile tests.
-->
<target name="compileTests" description="Compile tests" depends="jar">
<compile src="${test.src.dir}"
bin="${test.classes.dir}"
classpathref="classpath"/>
</target>
<!--
JAR test classes.
-->
<target name="jarTests"
description="JAR test classes"
depends="compileTests, createManifest">
<makeJAR bin="${test.classes.dir}" lib="${lib.dir}"
name="${test.jar.name}"
manifest="${build.dir}/MANIFEST.MF"/>
</target>
<!--
Run tests.
-->
<target name="runTests"
description="Run tests"
depends="jarTests">
<runTests src="${test.src.dir}"
xmlReports="${test.report.xml.dir}"
htmlReports="${test.report.html.dir}"
classpathref="classpath"/>
<antcall target="testreport">
<param name="base.dir" value="${base.dir}"/>
<param name="xml.dir" value="${test.report.xml.dir}"/>
<param name="html.dir" value="${test.report.html.dir}"/>
</antcall>
</target>
<!-- Create JAR manifest -->
<target name="createManifest"
description="Create JAR manifest">
<mkdir dir="${build.dir}"/>
<tstamp>
<format property="build.time" pattern="EEE d MMMM yyyy HH:mm"/>
</tstamp>
<manifest file="${build.dir}/MANIFEST.MF">
<attribute name="Built-By" value="${user.name}"/>
<attribute name="Built-At" value="${build.time}"/>
</manifest>
</target>
<!--
Convert ANT junit XML reports into HTML.
-->
<target name="testreport"
description="Convert ANT junit XML reports into HTML">
<mkdir dir="${html.dir}"/>
<!-- Destination of aggregated XML report -->
<junitreport todir="${xml.dir}">
<fileset dir="${xml.dir}">
<include name="TEST-*.xml"/>
</fileset>
<report todir="${html.dir}"/>
</junitreport>
</target>
<!-- MACRO-DEFs -->
<!--
compile macro-def. Compile Java code.
The attributes are:
-src - source directory.
-bin - binary directory.
-classpathref - CLASSPATH reference.
-->
<macrodef name="compile">
<attribute name="src"/>
<attribute name="bin"/>
<attribute name="classpathref"/>
<sequential>
<mkdir dir="@{bin}"/>
<javac srcdir="@{src}"
destdir="@{bin}"
debug="${java.debug}"
deprecation="${java.deprecation}"
classpathref="@{classpathref}">
<include name="**/*.java"/>
<compilerarg line="${compiler.jvmarg}"/>
</javac>
</sequential>
</macrodef>
<!--
makeJAR macro-def. JAR compiled Java code adding timestamp
and manifest.
The attributes are:
-bin - binary directory.
-lib - library directory.
-name - JAR name.
-manifest - MANIFEST file location.
-->
<macrodef name="makeJAR">
<attribute name="bin"/>
<attribute name="lib"/>
<attribute name="name"/>
<attribute name="manifest"/>
<sequential>
<mkdir dir="@{lib}"/>
<!--
Make a binary directory if none is there. The skip below
avoids empty JARs anyway.
-->
<mkdir dir="@{bin}"/>
<tstamp>
<format property="build.time" pattern="EEE d MMMM yyyy HH:mm"/>
</tstamp>
<jar destfile="@{lib}/@{name}"
basedir="@{bin}"
manifest="@{manifest}"
whenmanifestonly="skip"/>
</sequential>
</macrodef>
<!--
runTests macro-def. Run JUnit tests and convert results to HTML.
The attributes are:
-src - source directory. Tests to are run are selected from
here. A pattern in the test.filter property determines what is
run. The default is "**/*Test.java".
-xmlReports - directory for XML reports.
-htmlReports - directory for HTML reports.
-classpathref - CLASSPATH reference.
-->
<macrodef name="runTests">
<attribute name="src"/>
<attribute name="xmlReports"/>
<attribute name="htmlReports"/>
<attribute name="classpathref"/>
<sequential>
<mkdir dir="@{xmlReports}"/>
<mkdir dir="@{htmlReports}"/>
<property name="test.filter" value="**/*Test.java"/>
<junit printsummary="yes"
haltonfailure="no">
<classpath>
<path refid="@{classpathref}"/>
</classpath>
<formatter type="xml"/>
<batchtest fork="yes"
todir="@{xmlReports}">
<fileset dir="@{src}">
<include name="${test.filter}"/>
</fileset>
</batchtest>
<sysproperty key="ogsadai.test.properties"
value="${ogsadai.test.properties}"/>
</junit>
</sequential>
</macrodef>
<!--
Clean, compile and JAR everything and run tests.
-->
<target name="all" description="Clean, compile, JAR and run tests"
depends="clean, jar, jarTests, runTests"/>
</project>