-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.xml
337 lines (272 loc) · 13.1 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
<?xml version="1.0"?>
<project name="Macker" default="build" basedir=".">
<!-- ================================================================= -->
<!-- Properties -->
<!-- ================================================================= -->
<!-- Global -->
<property name="Name" value="Macker" />
<property name="name" value="macker" />
<property name="src.dir" location="${basedir}/src/main/java" />
<property name="res.dir" location="${basedir}/src/main/resources" />
<property name="lib.dir" location="${basedir}/lib" />
<property name="test.dir" location="${basedir}/src/test" />
<property name="doc.dir" location="${basedir}/doc" />
<property name="build.lib.dir" location="${lib.dir}/build-only" />
<property name="example.dir" location="${doc.dir}/example" />
<property file="${basedir}/build.properties" />
<!-- Targets -->
<property name="build.dir" location="${basedir}/target/ant/" />
<property name="build.classes.dir" location="${build.dir}/target/classes" />
<property name="build.test.dir" location="${build.dir}/target/test" />
<property name="dist.dir" location="${build.dir}/target" />
<property name="jar.file" location="${build.dir}/${name}.jar" />
<property name="jar.manifest" location="${basedir}/src/manifest.mf" />
<property name="javadoc.dir" location="${doc.dir}/target/javadoc"/>
<property name="javadoc.packages" value="net.innig.macker.*" />
<property name="run.mainclass" value="net.innig.macker.Macker" />
<property name="run.args" value="" />
<!-- ================================================================= -->
<!-- prepare: -->
<!-- Sets up directories and such for compilation -->
<!-- ================================================================= -->
<target name="prepare">
<mkdir dir="${build.dir}" />
<mkdir dir="${build.classes.dir}" />
<mkdir dir="${build.lib.dir}" /> <!-- because it's usually empty -->
<path id="build.classpath">
<fileset dir="${lib.dir}" includes="**/*.jar" />
<fileset dir="${build.lib.dir}" includes="**/*.jar" />
</path>
<property name="build.classpath" refid="build.classpath" />
<path id="run.classpath">
<pathelement location="${build.classes.dir}" />
<fileset dir="${lib.dir}" includes="**/*.jar" />
</path>
<property name="run.classpath" refid="run.classpath" />
<path id="test.classpath">
<pathelement location="${build.test.dir}" />
<path refid="run.classpath" />
</path>
<tstamp><format property="timestamp" pattern="yyyy/MM/dd HH:mm:ss z" locale="en"/></tstamp>
<condition property="dist.version.long" value="version ${dist.version}">
<isset property="dist.version" />
</condition>
<property name="dist.version" value="nonrelease" />
<property name="dist.version.long" value="non-release build [${timestamp}]" />
</target>
<!-- ================================================================= -->
<!-- compile: -->
<!-- Compiles the source code -->
<!-- ================================================================= -->
<target name="compile"
depends="prepare"
description="Compiles the source code">
<javac
srcdir="${src.dir}"
destdir="${build.classes.dir}"
source="1.5"
target="1.5"
debug="true">
<classpath refid="build.classpath" />
</javac>
<!--
<taskdef name="javamake"
classname="com.sun.tools.javamake.ant.JavaMake"
classpath="${build.classpath}" />
<javamake
srcdir="${src.dir}"
destdir="${build.classes.dir}"
pdbFilename="${build.dir}/${name}.pdb"
source="1.5"
target="1.5">
<classpath refid="build.classpath" />
</javamake>
-->
</target>
<!-- ================================================================= -->
<!-- copy-resources: -->
<!-- Copies resource files to the build directory -->
<!-- ================================================================= -->
<target name="copy-resources"
depends="prepare"
description="Copies resource files to the build directory">
<copy todir="${build.classes.dir}">
<fileset dir="${res.dir}">
<exclude name="**/*.properties"/>
</fileset>
</copy>
<copy todir="${build.classes.dir}" overwrite="yes">
<filterset>
<filter token="dist.version" value="${dist.version}"/>
<filter token="dist.version.long" value="${dist.version.long}"/>
</filterset>
<fileset dir="${res.dir}">
<include name="**/*.properties"/>
</fileset>
</copy>
</target>
<!-- ================================================================= -->
<!-- build: -->
<!-- The default target -->
<!-- ================================================================= -->
<target name="build"
depends="jar,compile-tests"
description="Builds an executable target (default)">
</target>
<!-- ================================================================= -->
<!-- jar: -->
<!-- Creates jar file -->
<!-- ================================================================= -->
<target name="jar" depends="compile,copy-resources" description="Creates a jar file">
<delete file="${jar.file}"/>
<jar
manifest="${jar.manifest}"
jarfile="${jar.file}"
compress="false">
<fileset dir="${build.classes.dir}" />
</jar>
</target>
<!-- ================================================================= -->
<!-- run: -->
<!-- Runs the darn thing -->
<!-- ================================================================= -->
<target name="run" depends="build" description="Runs the darn thing">
<java classname="${run.mainclass}" fork="yes">
<arg line="${run.args}"/>
<classpath refid="run.classpath" />
</java>
</target>
<!-- ================================================================= -->
<!-- test: -->
<!-- Runs JUnit test suites -->
<!-- ================================================================= -->
<target name="compile-tests"
depends="jar">
<mkdir dir="${build.test.dir}" />
<javac
srcdir="${test.dir}/java/"
destdir="${build.test.dir}"
source="1.5"
target="1.5"
debug="true">
<classpath refid="test.classpath" />
</javac>
<!--
<javamake
srcdir="${test.dir}"
destdir="${build.test.dir}"
pdbFilename="${build.dir}/${name}-test.pdb">
<classpath refid="test.classpath" />
</javamake>
-->
</target>
<target name="test"
depends="compile-tests"
description="Runs JUnit test suites">
<property name="test.build.recording.dir" location="${build.test.dir}/recording-tests" />
<delete dir="${test.build.recording.dir}" />
<mkdir dir="${test.build.recording.dir}" />
<taskdef name="junit"
classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask"
classpath="${test.junit.lib}"/>
<junit
printsummary="${junit.printsummary}"
timeout="${junit.timeout}"
showoutput="${junit.showoutput}"
haltonerror="yes"
haltonfailure="yes"
fork="no">
<formatter type="plain" usefile="no" />
<classpath refid="test.classpath" />
<sysproperty key="Macker.RecordingTest.testDir" value="${test.dir}/recording-tests" />
<sysproperty key="Macker.RecordingTest.buildDir" value="${test.build.recording.dir}" />
<batchtest>
<fileset dir="${test.dir}/java/">
<include name="**/*Test.java"/>
</fileset>
</batchtest>
</junit>
<!-- We need some actual tests around the Ant task — but for now, just make sure it doesn't blow up! -->
<ant antfile="${test.dir}/ant-test/build.xml" target="go" inheritall="no"/>
</target>
<!-- ================================================================= -->
<!-- javadoc: -->
<!-- Generates javadoc -->
<!-- ================================================================= -->
<target
name="javadoc"
description="Builds javadoc"
depends="prepare">
<property name="javadoc.title" value="${Name} API ${dist.version.long}"/>
<mkdir dir="${javadoc.dir}" />
<javadoc sourcepath="${src.dir}"
destdir="${javadoc.dir}"
packagenames="${javadoc.packages}"
public="true"
windowtitle="${javadoc.title}"
use="true">
<classpath refid="build.classpath" />
<link href="http://java.sun.com/j2se/1.3/docs/api/" />
</javadoc>
<copy todir="${javadoc.dir}">
<fileset dir="${src.dir}">
<include name="**/*.gif"/>
<include name="**/*.jpeg"/>
<include name="**/*.jpg"/>
<include name="**/*.png"/>
<include name="**/*.pdf"/>
<include name="**/*.svg"/>
</fileset>
</copy>
</target>
<!-- ================================================================= -->
<!-- clean: -->
<!-- Removes all build files -->
<!-- ================================================================= -->
<target name="clean" description="Removes all build files">
<delete dir="${javadoc.dir}" />
<delete dir="${build.classes.dir}" />
<delete dir="${build.dir}" />
<delete dir="${dist.dir}" />
</target>
<!-- ================================================================= -->
<!-- dist: -->
<!-- Package distribution version -->
<!-- ================================================================= -->
<target
name="dist"
depends="clean,test,javadoc"
description="Prepares distribution-ready archives (uses dist.version parameter)">
<echo>Bundling dist: ${dist.version.long}</echo>
<property name="dist.name" value="${name}-${dist.version}" />
<property name="dist.file" value="${dist.dir}/${dist.name}" />
<property name="dist.tmp.dir" value="${dist.dir}/tmp" />
<property name="dist.staging.dir" value="${dist.tmp.dir}/${dist.name}" />
<mkdir dir="${dist.staging.dir}" />
<copy todir="${dist.staging.dir}">
<fileset dir="${basedir}">
<include name="**" />
<exclude name="build/**" />
<exclude name="**/.DS_Store" />
</fileset>
</copy>
<copy todir="${dist.staging.dir}">
<fileset dir="${build.dir}" includes="${name}.jar" />
</copy>
<copy todir="${dist.staging.dir}" overwrite="yes">
<filterset>
<filter token="dist.version" value="${dist.version}"/>
<filter token="dist.version.long" value="${dist.version.long}"/>
</filterset>
<fileset dir="${basedir}" includes="README.html" />
</copy>
<tar basedir="${dist.tmp.dir}"
destfile="${dist.file}.tar.gz"
compression="gzip"
longfile="gnu" />
<zip basedir="${dist.tmp.dir}"
destfile="${dist.file}.zip"
filesonly="no" />
<delete dir="${dist.tmp.dir}" />
</target>
</project>