1 |
<project name="jsr166" default="jar"> |
2 |
|
3 |
<description> |
4 |
|
5 |
Build file for JSR-166 |
6 |
|
7 |
Note that junit.jar must be in ${ant.home}/lib for the |
8 |
test target to work. [FIXME: This should be automatically |
9 |
enforced by this build file by failing with a message if |
10 |
junit.jar is not in the right place.] |
11 |
|
12 |
</description> |
13 |
|
14 |
<!-- Compilation options --> |
15 |
<property name="build.sourcelevel" value="1.5"/> |
16 |
<property name="build.debug" value="true"/> |
17 |
<property name="build.debuglevel" value="source,lines,vars"/> |
18 |
<property name="build.deprecation" value="false"/> |
19 |
<!-- |
20 |
<property name="build.warnings" value="true"/> |
21 |
--> |
22 |
|
23 |
<!-- Build locations --> |
24 |
<property name="build.dir" location="build"/> |
25 |
<property name="build.classes.dir" location="${build.dir}/classes"/> |
26 |
<property name="build.testcases.dir" location="${build.dir}/testcases"/> |
27 |
<property name="build.lib.dir" location="${build.dir}/lib"/> |
28 |
<property name="build.ant.dir" location="${build.dir}/ant"/> |
29 |
<property name="build.javadocs.dir" location="${build.dir}/javadocs"/> |
30 |
<property name="build.reports.dir" location="${build.dir}/reports"/> |
31 |
<property name="build.filter.src.dir" location="${build.dir}/filtersrc"/> |
32 |
|
33 |
<!-- Source locations --> |
34 |
<property name="src.dir" location="${basedir}"/> |
35 |
<property name="test.src.dir" location="${basedir}/etc/testcases"/> |
36 |
<property name="ant.src.dir" location="${basedir}/etc/ant"/> |
37 |
<property name="stylesheet.dir" location="${basedir}/etc/xsl"/> |
38 |
<property name="lib.dir" location="${basedir}/lib"/> |
39 |
<property name="dist.dir" location="${basedir}/dist"/> |
40 |
|
41 |
<!-- Distribution locations --> |
42 |
<property name="dist.javadocs.dir" location="${dist.dir}/docs"/> |
43 |
|
44 |
<!-- Jar locations --> |
45 |
<property name="product.jar" location="${build.lib.dir}/jsr166.jar"/> |
46 |
<property name="javac.jar" location="${lib.dir}/javac.jar"/> |
47 |
<property name="collect.jar" location="${lib.dir}/collect.jar"/> |
48 |
<property name="junit.jar" location="${lib.dir}/junit.jar"/> |
49 |
<property name="rt.jar" location="${java.home}/lib/rt.jar"/> |
50 |
|
51 |
<property name="javac.args" value='-J-Xbootclasspath/p:${javac.jar}'/> |
52 |
|
53 |
<path id="javac.bootclasspath"> |
54 |
<pathelement location="${collect.jar}"/> |
55 |
<pathelement location="${rt.jar}"/> |
56 |
</path> |
57 |
|
58 |
<path id="test.classpath"> |
59 |
<pathelement location="${product.jar}"/> |
60 |
</path> |
61 |
|
62 |
|
63 |
<!-- Main targets --> |
64 |
|
65 |
<target name="compile" depends="init" |
66 |
description="Compiles all sources to build folder"> |
67 |
<mkdir dir="${build.classes.dir}"/> |
68 |
<javac srcdir="${src.dir}" |
69 |
destdir="${build.classes.dir}" |
70 |
debug="${build.debug}" |
71 |
debuglevel="${build.debuglevel}" |
72 |
deprecation="${build.deprecation}" |
73 |
source="${build.sourcelevel}" |
74 |
fork="true"> |
75 |
|
76 |
<bootclasspath refid="javac.bootclasspath"/> |
77 |
<compilerarg line="${javac.args} ${build.warnings.option}"/> |
78 |
|
79 |
<!-- need this because srcdir is basedir! --> |
80 |
<include name="java/**/*.java"/> |
81 |
|
82 |
</javac> |
83 |
</target> |
84 |
|
85 |
|
86 |
<target name="jar" depends="compile" |
87 |
description="Builds library jar from compiled sources"> |
88 |
<mkdir dir="${build.lib.dir}"/> |
89 |
<jar basedir="${build.classes.dir}" |
90 |
destfile="${product.jar}" |
91 |
/> |
92 |
</target> |
93 |
|
94 |
|
95 |
<target name="test" depends="init, report-tests" |
96 |
description="Runs all tests"/> |
97 |
|
98 |
|
99 |
<target name="docs" depends="init, clean-filtered-src, filter-src" |
100 |
description="Builds javadocs with custom tags to build folder"> |
101 |
<delete dir="${build.javadocs.dir}"/> |
102 |
<mkdir dir="${build.javadocs.dir}"/> |
103 |
<javadoc destdir="${build.javadocs.dir}" |
104 |
link="http://java.sun.com/j2se/1.4.1/docs/api" |
105 |
overview="${src.dir}/intro.html" |
106 |
source="${build.sourcelevel}"> |
107 |
|
108 |
<tag name="revised" description="Last revised:"/> |
109 |
<tag name="spec" description="Specified by:"/> |
110 |
<tag name="editor" description="Last edited by:"/> |
111 |
<tag name="fixme" description="FIX ME:"/> |
112 |
<packageset dir="${build.filter.src.dir}"> |
113 |
<include name="java/**"/> |
114 |
</packageset> |
115 |
|
116 |
</javadoc> |
117 |
</target> |
118 |
|
119 |
|
120 |
<target name="dist" depends="init, dist-clean, dist-jar, dist-docs"/> |
121 |
|
122 |
|
123 |
<target name="clean" |
124 |
description="Removes all build products"> |
125 |
<delete dir="${build.dir}"/> |
126 |
<delete dir="${build.classes.dir}"/> |
127 |
<delete dir="${build.lib.dir}"/> |
128 |
</target> |
129 |
|
130 |
|
131 |
<target name="dist-clean" |
132 |
description="Removes all build and distribution products"> |
133 |
<delete dir="${dist.dir}"/> |
134 |
</target> |
135 |
|
136 |
|
137 |
<!-- Internal targets --> |
138 |
|
139 |
<target name="set-warnings-if" if="build.warnings"> |
140 |
<property name="build.warnings.option" value="-warnunchecked"/> |
141 |
</target> |
142 |
|
143 |
<target name="set-warnings-unless" unless="build.warnings"> |
144 |
<property name="build.warnings.option" value=""/> |
145 |
</target> |
146 |
|
147 |
<target name="init" depends="set-warnings-if, set-warnings-unless"> |
148 |
<!-- Version is kept in a separate file --> |
149 |
<loadfile property="version" srcFile="version.properties"/> |
150 |
<echo>Building JSR-166 version ${version}</echo> |
151 |
</target> |
152 |
|
153 |
|
154 |
<target name="clean-filtered-src"> |
155 |
<delete dir="${build.filter.src.dir}"/> |
156 |
</target> |
157 |
|
158 |
|
159 |
<target name="dist-jar" depends="clean, jar"> |
160 |
<copy file="${product.jar}" todir="${dist.dir}"/> |
161 |
</target> |
162 |
|
163 |
|
164 |
<target name="dist-docs" depends="clean-filtered-src, filter-src" |
165 |
description="Builds javadocs without custom tags to dist folder"> |
166 |
<delete dir="${dist.javadocs.dir}"/> |
167 |
<mkdir dir="${dist.javadocs.dir}"/> |
168 |
<javadoc destdir="${dist.javadocs.dir}" |
169 |
link="http://java.sun.com/j2se/1.4.1/docs/api" |
170 |
overview="${src.dir}/intro.html" |
171 |
source="${build.sourcelevel}"> |
172 |
|
173 |
<packageset dir="${build.filter.src.dir}"> |
174 |
<include name="java/**"/> |
175 |
</packageset> |
176 |
|
177 |
</javadoc> |
178 |
</target> |
179 |
|
180 |
|
181 |
<target name="compile-ant-filter"> |
182 |
<mkdir dir="${build.ant.dir}"/> |
183 |
<javac srcdir="${ant.src.dir}" |
184 |
destdir="${build.ant.dir}" |
185 |
source="1.4" |
186 |
/> |
187 |
</target> |
188 |
|
189 |
|
190 |
<target name="filter-src" depends="compile-ant-filter"> |
191 |
<mkdir dir="${build.filter.src.dir}"/> |
192 |
<copy todir="${build.filter.src.dir}"> |
193 |
<fileset dir="${src.dir}"> |
194 |
<include name="**/*.java"/> |
195 |
</fileset> |
196 |
<filterchain> |
197 |
<filterreader classname="jsr166.ant.filters.ReplaceFilter" |
198 |
classpath="${build.ant.dir}"> |
199 |
<!-- |
200 |
# These arguments are to get rid of angle-bracketed type |
201 |
# parameters so that javadoc can run on the result. The |
202 |
# following heuristic that seems to work: |
203 |
# |
204 |
# For all lines not starting with space(s)-asterisk-space(s), |
205 |
# replace <something> with a space, where there may be more |
206 |
# than one right angle bracket at the end, and "something" |
207 |
# must not contain parens or pipes. (This may need some |
208 |
# tweaking.) |
209 |
--> |
210 |
<param name="notmatching" value="^\s+\*\s.*$"/> |
211 |
<param name="pattern" value="<[^|>()]+?>+"/> |
212 |
<param name="replacement" value=" "/> |
213 |
</filterreader> |
214 |
<filterreader classname="jsr166.ant.filters.ReplaceFilter" |
215 |
classpath="${build.ant.dir}"> |
216 |
<!-- |
217 |
# These arguments are to uncomment lines beginning with |
218 |
# "//@" so that javadoc can see imports that are needed |
219 |
# to resolve links but that shouldn't be in the compiled |
220 |
# code. |
221 |
--> |
222 |
<param name="matching" value="^//@.*$"/> |
223 |
<param name="pattern" value="^//@"/> |
224 |
<param name="replacement" value=""/> |
225 |
</filterreader> |
226 |
</filterchain> |
227 |
</copy> |
228 |
</target> |
229 |
|
230 |
|
231 |
<target name="compile-tests" depends="jar"> |
232 |
<mkdir dir="${build.testcases.dir}"/> |
233 |
<javac srcdir="${test.src.dir}" |
234 |
destdir="${build.testcases.dir}" |
235 |
debug="${build.debug}" |
236 |
debuglevel="${build.debuglevel}" |
237 |
deprecation="${build.deprecation}" |
238 |
source="${build.sourcelevel}" |
239 |
fork="true"> |
240 |
|
241 |
<bootclasspath refid="javac.bootclasspath"/> |
242 |
<compilerarg line="${javac.args} ${build.warnings.option}"/> |
243 |
<classpath refid="test.classpath"/> |
244 |
<include name="**/*Test.java"/> |
245 |
|
246 |
</javac> |
247 |
</target> |
248 |
|
249 |
|
250 |
<target name="run-tests" depends="compile-tests"> |
251 |
<mkdir dir="${build.reports.dir}"/> |
252 |
<junit printsummary="true" |
253 |
showoutput="true" |
254 |
errorProperty="junit.failed" |
255 |
failureProperty="junit.failed" |
256 |
dir="${build.reports.dir}" |
257 |
fork="true"> |
258 |
|
259 |
<jvmarg value="-Xbootclasspath/p:${product.jar}"/> |
260 |
|
261 |
<classpath> |
262 |
<!-- <path refid="test.classpath"/> --> |
263 |
<pathelement location="${build.testcases.dir}"/> |
264 |
</classpath> |
265 |
|
266 |
<formatter type="xml"/> |
267 |
|
268 |
<batchtest todir="${build.reports.dir}"> |
269 |
<fileset dir="${test.src.dir}"> |
270 |
<include name="**/*Test.java"/> |
271 |
</fileset> |
272 |
</batchtest> |
273 |
|
274 |
</junit> |
275 |
</target> |
276 |
|
277 |
|
278 |
<target name="report-tests" depends="run-tests"> |
279 |
<!-- Sets junit.report.format to frames if Xalan is present, |
280 |
otherwise sets it to noframes. --> |
281 |
<available property="junit.report.format" |
282 |
value="frames" |
283 |
classname="org.apache.xalan.lib.Redirect" |
284 |
/> |
285 |
<property name="junit.report.format" value="noframes"/> |
286 |
|
287 |
<junitreport todir="${build.reports.dir}"> |
288 |
<fileset dir="${build.reports.dir}"> |
289 |
<include name="TEST-*.xml"/> |
290 |
</fileset> |
291 |
<report styledir="${stylesheet.dir}" |
292 |
format="${junit.report.format}" |
293 |
todir="${build.reports.dir}" |
294 |
/> |
295 |
</junitreport> |
296 |
|
297 |
<fail message="Test Cases Failed" if="junit.failed"/> |
298 |
</target> |
299 |
|
300 |
|
301 |
</project> |