1 |
<project name="jsr166" default="usage"> |
2 |
|
3 |
<description> |
4 |
Build file for JSR-166 |
5 |
|
6 |
JUnit 1.8 must be in ${ant.home}/lib for the test target to work. |
7 |
</description> |
8 |
|
9 |
|
10 |
<target name="usage" description="Prints this message"> |
11 |
<echo> |
12 |
ant [target], where target is one of: |
13 |
|
14 |
usage (default) Prints this message |
15 |
compile Compiles all sources to build folder |
16 |
jar Builds library jar from compiled sources |
17 |
test Runs all tests (requires JUnit 1.8 in ${ant.home}/lib) |
18 |
docs Builds javadocs with custom tags to build folder |
19 |
dist-docs Builds javadocs without custom tags to dist folder |
20 |
dist Puts all distributable products in single hierarchy |
21 |
|
22 |
clean Removes all build products |
23 |
dist-clean Removes all build and distribution products |
24 |
|
25 |
checkstyle Reports on style errors in Java source (verbose, mostly chaff) |
26 |
doccheck Reports on javadoc style errors (not working yet) |
27 |
</echo> |
28 |
</target> |
29 |
|
30 |
<property file="user.properties"/> |
31 |
<property name="testcase" value="*"/> |
32 |
|
33 |
<!-- Compilation options --> |
34 |
<property name="build.sourcelevel" value="1.5"/> |
35 |
<property name="build.docsourcelevel" value="1.4"/> |
36 |
<property name="build.debug" value="true"/> |
37 |
<property name="build.debuglevel" value="source,lines,vars"/> |
38 |
<property name="build.deprecation" value="false"/> |
39 |
<!-- |
40 |
<property name="build.warnings" value="true"/> |
41 |
--> |
42 |
|
43 |
<!-- Build locations --> |
44 |
<property name="build.dir" location="build"/> |
45 |
<property name="build.classes.dir" location="${build.dir}/classes"/> |
46 |
<property name="build.testcases.dir" location="${build.dir}/testcases"/> |
47 |
<property name="build.lib.dir" location="${build.dir}/lib"/> |
48 |
<property name="build.ant.dir" location="${build.dir}/ant"/> |
49 |
<property name="build.javadocs.dir" location="${build.dir}/javadocs"/> |
50 |
<property name="build.stripped.dir" location="${build.dir}/stripped"/> |
51 |
<property name="build.reports.dir" location="${build.dir}/reports"/> |
52 |
<property name="build.doccheck.dir" location="${build.dir}/doccheck"/> |
53 |
<property name="build.filter.src.dir" location="${build.dir}/filtersrc"/> |
54 |
|
55 |
<!-- Source locations --> |
56 |
<property name="src.dir" location="${basedir}/src/main"/> |
57 |
<property name="test.src.dir" location="${basedir}/src/test"/> |
58 |
<property name="ant.src.dir" location="${basedir}/etc/ant"/> |
59 |
<property name="stylesheet.dir" location="${basedir}/etc/xsl"/> |
60 |
<property name="lib.dir" location="${basedir}/lib"/> |
61 |
<property name="dist.dir" location="${basedir}/dist"/> |
62 |
|
63 |
<!-- Distribution locations --> |
64 |
<property name="dist.javadocs.dir" location="${dist.dir}/docs"/> |
65 |
|
66 |
<!-- Jar locations --> |
67 |
<property name="product.jar" location="${build.lib.dir}/jsr166.jar"/> |
68 |
<property name="javac.jar" location="${lib.dir}/javac.jar"/> |
69 |
<property name="collect.jar" location="${lib.dir}/collect.jar"/> |
70 |
<property name="junit.jar" location="${lib.dir}/junit.jar"/> |
71 |
<property name="rt.jar" location="${java.home}/lib/rt.jar"/> |
72 |
|
73 |
<property name="javac.args" value='-J-Xbootclasspath/p:$[src.dir]:${javac.jar}'/> |
74 |
|
75 |
<path id="javac.bootclasspath"> |
76 |
<pathelement location="${src.dir}"/> |
77 |
<pathelement location="${collect.jar}"/> |
78 |
<pathelement location="${rt.jar}"/> |
79 |
</path> |
80 |
|
81 |
<path id="test.classpath"> |
82 |
<pathelement location="${product.jar}"/> |
83 |
</path> |
84 |
|
85 |
|
86 |
<!-- Main targets --> |
87 |
|
88 |
<target name="compile" depends="init" |
89 |
description="Compiles all sources to build folder"> |
90 |
<mkdir dir="${build.classes.dir}"/> |
91 |
<javac srcdir="${src.dir}" |
92 |
destdir="${build.classes.dir}" |
93 |
debug="${build.debug}" |
94 |
debuglevel="${build.debuglevel}" |
95 |
deprecation="${build.deprecation}" |
96 |
source="${build.sourcelevel}" |
97 |
fork="true"> |
98 |
|
99 |
<bootclasspath refid="javac.bootclasspath"/> |
100 |
<compilerarg line="${javac.args} ${build.warnings.option}"/> |
101 |
|
102 |
</javac> |
103 |
</target> |
104 |
|
105 |
|
106 |
<target name="jar" depends="compile" |
107 |
description="Builds library jar from compiled sources"> |
108 |
<mkdir dir="${build.lib.dir}"/> |
109 |
<jar basedir="${build.classes.dir}" |
110 |
destfile="${product.jar}" |
111 |
/> |
112 |
</target> |
113 |
|
114 |
|
115 |
<target name="test" depends="init, check-junit, report-tests" |
116 |
description="Runs all tests (requires JUnit 1.8 in ${ant.home}/lib)"/> |
117 |
|
118 |
|
119 |
<target name="checkstyle" depends="filter-src" |
120 |
description="Reports on style errors in Java source (verbose, mostly chaff)"> |
121 |
<taskdef resource="checkstyletask.properties" |
122 |
classpath="${lib.dir}/checkstyle-all-2.4.jar"/> |
123 |
|
124 |
<checkstyle> |
125 |
<formatter type="plain"/> <!-- also available: type="xml" --> |
126 |
<fileset dir="${build.filter.src.dir}" includes="**/*.java"/> |
127 |
</checkstyle> |
128 |
</target> |
129 |
|
130 |
|
131 |
<target name="doccheck" depends="filter-src" |
132 |
description="Reports on javadoc style errors (not working yet)"> |
133 |
<delete dir="${build.doccheck.dir}"/> |
134 |
<mkdir dir="${build.doccheck.dir}"/> |
135 |
<javadoc doclet="com.sun.tools.doclets.doccheck.DocCheck" |
136 |
docletpath="${lib.dir}/doccheck.jar" |
137 |
destdir="${build.doccheck.dir}"> |
138 |
<packageset dir="${build.filter.src.dir}"/> |
139 |
</javadoc> |
140 |
</target> |
141 |
|
142 |
|
143 |
<target name="docs" depends="filter-src" |
144 |
description="Builds javadocs with custom tags to build folder"> |
145 |
<delete dir="${build.javadocs.dir}"/> |
146 |
<mkdir dir="${build.javadocs.dir}"/> |
147 |
<javadoc destdir="${build.javadocs.dir}" |
148 |
link="http://java.sun.com/j2se/1.4.1/docs/api" |
149 |
overview="${src.dir}/intro.html" |
150 |
source="${build.docsourcelevel}"> |
151 |
|
152 |
<tag name="revised" description="Last revised:"/> |
153 |
<tag name="spec" description="Specified by:"/> |
154 |
<tag name="editor" description="Last edited by:"/> |
155 |
<tag name="fixme" description="FIX ME:"/> |
156 |
<packageset dir="${build.filter.src.dir}"/> |
157 |
|
158 |
</javadoc> |
159 |
</target> |
160 |
|
161 |
|
162 |
<!-- |
163 |
# javac -s doesn't reliably generate compilable code. It generates |
164 |
# bridge methods (marked as "synthetic") that can have identical |
165 |
# signatures to existing methods except for the return value. |
166 |
--> |
167 |
<target name="strip" depends="init"> |
168 |
<mkdir dir="${build.stripped.dir}"/> |
169 |
<javac srcdir="${src.dir}" |
170 |
destdir="${build.stripped.dir}" |
171 |
debug="${build.debug}" |
172 |
debuglevel="${build.debuglevel}" |
173 |
deprecation="${build.deprecation}" |
174 |
source="${build.sourcelevel}" |
175 |
fork="true"> |
176 |
|
177 |
<bootclasspath refid="javac.bootclasspath"/> |
178 |
<compilerarg line="${javac.args} ${build.warnings.option} -s"/> |
179 |
|
180 |
</javac> |
181 |
</target> |
182 |
|
183 |
|
184 |
<target name="dist" depends="init, dist-clean, dist-jar, dist-docs" |
185 |
description="Puts all distributable products in single hierarchy"/> |
186 |
|
187 |
|
188 |
<target name="clean" |
189 |
description="Removes all build products"> |
190 |
<delete dir="${build.dir}"/> |
191 |
<delete dir="${build.classes.dir}"/> |
192 |
<delete dir="${build.lib.dir}"/> |
193 |
</target> |
194 |
|
195 |
|
196 |
<target name="dist-clean" |
197 |
description="Removes all build and distribution products"> |
198 |
<delete dir="${dist.dir}"/> |
199 |
</target> |
200 |
|
201 |
|
202 |
<!-- Anthill targets --> |
203 |
|
204 |
<!-- Should really run the tests instead of just the jar target --> |
205 |
<target name="anthill-build" depends="jar, docs, dist-docs"/> |
206 |
|
207 |
<target name="anthill-publish"> |
208 |
<copy todir="${deployDir}/docs/private"> |
209 |
<fileset dir="${build.javadocs.dir}"/> |
210 |
</copy> |
211 |
<copy todir="${deployDir}/docs/public"> |
212 |
<fileset dir="${dist.javadocs.dir}"/> |
213 |
</copy> |
214 |
<copy tofile="${deployDir}/index.html" |
215 |
file="${basedir}/etc/anthill-index.html"/> |
216 |
<copy todir="${deployDir}/notes"> |
217 |
<fileset dir="${basedir}/etc/notes"/> |
218 |
</copy> |
219 |
</target> |
220 |
|
221 |
|
222 |
<!-- Internal targets --> |
223 |
|
224 |
<target name="set-warnings-if" if="build.warnings"> |
225 |
<property name="build.warnings.option" value="-warnunchecked"/> |
226 |
</target> |
227 |
|
228 |
|
229 |
<target name="set-warnings-unless" unless="build.warnings"> |
230 |
<property name="build.warnings.option" value=""/> |
231 |
</target> |
232 |
|
233 |
|
234 |
<target name="init" depends="set-warnings-if, set-warnings-unless"> |
235 |
<!-- Version is kept in a separate file --> |
236 |
<loadfile property="version" srcFile="version.properties"/> |
237 |
<echo>Building JSR-166 version ${version}</echo> |
238 |
</target> |
239 |
|
240 |
|
241 |
<target name="dist-jar" depends="clean, jar"> |
242 |
<copy file="${product.jar}" todir="${dist.dir}"/> |
243 |
</target> |
244 |
|
245 |
|
246 |
<target name="dist-docs" depends="filter-src" |
247 |
description="Builds javadocs without custom tags to dist folder"> |
248 |
<delete dir="${dist.javadocs.dir}"/> |
249 |
<mkdir dir="${dist.javadocs.dir}"/> |
250 |
<javadoc destdir="${dist.javadocs.dir}" |
251 |
link="http://java.sun.com/j2se/1.4.1/docs/api" |
252 |
overview="${src.dir}/intro.html" |
253 |
source="${build.docsourcelevel}"> |
254 |
|
255 |
<packageset dir="${build.filter.src.dir}"/> |
256 |
|
257 |
</javadoc> |
258 |
</target> |
259 |
|
260 |
|
261 |
<target name="compile-ant-filter" depends="init"> |
262 |
<mkdir dir="${build.ant.dir}"/> |
263 |
<javac srcdir="${ant.src.dir}" |
264 |
destdir="${build.ant.dir}" |
265 |
source="1.4" |
266 |
/> |
267 |
</target> |
268 |
|
269 |
|
270 |
<target name="filter-src" depends="compile-ant-filter"> |
271 |
<mkdir dir="${build.filter.src.dir}"/> |
272 |
<copy todir="${build.filter.src.dir}"> |
273 |
<fileset dir="${src.dir}"> |
274 |
<include name="**/*.java"/> |
275 |
</fileset> |
276 |
<filterchain> |
277 |
<filterreader classname="jsr166.ant.filters.ReplaceFilter" |
278 |
classpath="${build.ant.dir}"> |
279 |
<!-- |
280 |
# These arguments are to get rid of angle-bracketed type |
281 |
# parameters so that javadoc can run on the result. The |
282 |
# following heuristic that seems to work: |
283 |
# |
284 |
# For all lines not starting with space(s)-asterisk-space(s), |
285 |
# replace <something> with a space, where there may be more |
286 |
# than one right angle bracket at the end, and "something" |
287 |
# must not contain parens or pipes. (This may need some |
288 |
# tweaking.) |
289 |
--> |
290 |
<param name="notmatching" value="^\s+\*\s.*$"/> |
291 |
<param name="pattern" value="<[^|>()]+?>+"/> |
292 |
<param name="replacement" value=" "/> |
293 |
</filterreader> |
294 |
<filterreader classname="jsr166.ant.filters.ReplaceFilter" |
295 |
classpath="${build.ant.dir}"> |
296 |
<!-- |
297 |
# These arguments are to uncomment lines beginning with |
298 |
# "//@" so that javadoc can see imports that are needed |
299 |
# to resolve links but that shouldn't be in the compiled |
300 |
# code. |
301 |
--> |
302 |
<param name="matching" value="^//@.*$"/> |
303 |
<param name="pattern" value="^//@"/> |
304 |
<param name="replacement" value=""/> |
305 |
</filterreader> |
306 |
</filterchain> |
307 |
</copy> |
308 |
</target> |
309 |
|
310 |
|
311 |
<target name="compile-tests" depends="jar"> |
312 |
<mkdir dir="${build.testcases.dir}"/> |
313 |
<javac srcdir="${test.src.dir}" |
314 |
destdir="${build.testcases.dir}" |
315 |
debug="${build.debug}" |
316 |
debuglevel="${build.debuglevel}" |
317 |
deprecation="${build.deprecation}" |
318 |
source="${build.sourcelevel}" |
319 |
fork="true"> |
320 |
|
321 |
<bootclasspath refid="javac.bootclasspath"/> |
322 |
<compilerarg line="${javac.args} ${build.warnings.option}"/> |
323 |
<classpath refid="test.classpath"/> |
324 |
|
325 |
</javac> |
326 |
</target> |
327 |
|
328 |
|
329 |
<target name="run-tests" depends="compile-tests"> |
330 |
<mkdir dir="${build.reports.dir}"/> |
331 |
<junit printsummary="true" |
332 |
showoutput="true" |
333 |
errorProperty="junit.failed" |
334 |
failureProperty="junit.failed" |
335 |
dir="${build.reports.dir}" |
336 |
fork="true"> |
337 |
|
338 |
<!-- |
339 |
! This nastiness is so JUnit can test classes we are inserting |
340 |
! into the java.* packages. |
341 |
--> |
342 |
<jvmarg value="-Xbootclasspath/p:${product.jar};${build.testcases.dir};${junit.jar}"/> |
343 |
|
344 |
<formatter type="xml"/> |
345 |
|
346 |
<batchtest todir="${build.reports.dir}"> |
347 |
<fileset dir="${test.src.dir}"> |
348 |
<include name="**/${testcase}Test.java"/> |
349 |
</fileset> |
350 |
</batchtest> |
351 |
|
352 |
</junit> |
353 |
</target> |
354 |
|
355 |
|
356 |
<target name="report-tests" depends="run-tests"> |
357 |
<!-- Sets junit.report.format to frames if Xalan is present, |
358 |
otherwise sets it to noframes. --> |
359 |
<available property="junit.report.format" |
360 |
value="frames" |
361 |
classname="org.apache.xalan.lib.Redirect" |
362 |
/> |
363 |
<property name="junit.report.format" value="noframes"/> |
364 |
|
365 |
<junitreport todir="${build.reports.dir}"> |
366 |
<fileset dir="${build.reports.dir}"> |
367 |
<include name="TEST-*.xml"/> |
368 |
</fileset> |
369 |
<report styledir="${stylesheet.dir}" |
370 |
format="${junit.report.format}" |
371 |
todir="${build.reports.dir}" |
372 |
/> |
373 |
</junitreport> |
374 |
|
375 |
<fail message="Test Cases Failed" if="junit.failed"/> |
376 |
</target> |
377 |
|
378 |
|
379 |
<target name="check-junit"> |
380 |
<!-- FIXME: this test isn't specific enough --> |
381 |
<available property="junit.available" |
382 |
classname="junit.framework.TestCase"/> |
383 |
<fail message="Need JUnit 3.8 to run tests" unless="junit.available"/> |
384 |
</target> |
385 |
|
386 |
|
387 |
</project> |