ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/build.xml
(Generate patch)

Comparing jsr166/build.xml (file contents):
Revision 1.5 by tim, Sun Dec 8 19:06:09 2002 UTC vs.
Revision 1.28 by tim, Wed May 28 13:37:59 2003 UTC

# Line 1 | Line 1
1 < <project name="jsr166" default="jar">
1 > <project name="jsr166" default="usage">
2  
3    <description>
4      Build file for JSR-166
5  
6 <    Note that junit.jar must be in ${ant.home}/lib for the
7 <    test target to work. [FIXME: This should be automatically
8 <    enforced by this build file by failing with a message if
9 <    junit.jar is not in the right place.]
6 >    JUnit 3.8 or better 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 +  <!-- User-specific settings -->
31 +  <property file="user.properties"/>
32 +
33 +  <!-- Set build.warnings in user.properties to turn on -warnunchecked -->
34 +  <!-- <property name="build.warnings" value=""/> -->
35 +
36 +
37    <!-- Compilation options -->
38 +  <property name="build.sourcelevel"    value="1.5"/>
39 +  <property name="build.docsourcelevel" value="1.4"/>
40    <property name="build.debug"          value="true"/>
41    <property name="build.debuglevel"     value="source,lines,vars"/>
42    <property name="build.deprecation"    value="false"/>
16  <property name="build.sourcelevel"    value="1.5"/>
43  
44    <!-- Build locations -->
45    <property name="build.dir"            location="build"/>
46    <property name="build.classes.dir"    location="${build.dir}/classes"/>
47 +  <property name="build.emulation.dir"  location="${build.dir}/emulation"/>
48    <property name="build.testcases.dir"  location="${build.dir}/testcases"/>
49    <property name="build.lib.dir"        location="${build.dir}/lib"/>
50    <property name="build.ant.dir"        location="${build.dir}/ant"/>
51    <property name="build.javadocs.dir"   location="${build.dir}/javadocs"/>
52 +  <property name="build.stripped.dir"   location="${build.dir}/stripped"/>
53    <property name="build.reports.dir"    location="${build.dir}/reports"/>
54 +  <property name="build.doccheck.dir"   location="${build.dir}/doccheck"/>
55    <property name="build.filter.src.dir" location="${build.dir}/filtersrc"/>
56  
57    <!-- Source locations -->
58 <  <property name="src.dir"              location="${basedir}"/>
59 <  <property name="test.src.dir"         location="${basedir}/etc/testcases"/>
58 >  <property name="src.dir"              location="${basedir}/src/main"/>
59 >  <property name="emulation.src.dir"    location="${basedir}/src/emulation"/>
60 >  <property name="test.src.dir"         location="${basedir}/src/test"/>
61    <property name="ant.src.dir"          location="${basedir}/etc/ant"/>
62    <property name="stylesheet.dir"       location="${basedir}/etc/xsl"/>
63    <property name="lib.dir"              location="${basedir}/lib"/>
64 +  <property name="dist.dir"             location="${basedir}/dist"/>
65 +
66 +  <!-- Distribution locations -->
67 +  <property name="dist.javadocs.dir"    location="${dist.dir}/docs"/>
68  
69    <!-- Jar locations -->
70    <property name="product.jar"          location="${build.lib.dir}/jsr166.jar"/>
# Line 39 | Line 73
73    <property name="junit.jar"            location="${lib.dir}/junit.jar"/>
74    <property name="rt.jar"               location="${java.home}/lib/rt.jar"/>
75  
42  <property name="gj.compiler.args"
43           value='-J-Xbootclasspath/p:${javac.jar}'
44  />
76  
77 <  <path id="gj.compiler.bootclasspath">
77 >
78 >  <!--
79 >   ! Bootclasspath munging for source compilation.
80 >   -->
81 >
82 >  <path id="javac.bootclasspath.prefix">
83 >    <!-- <pathelement location="${src.dir}"/> -->
84 >    <pathelement location="${javac.jar}"/>
85 >  </path>
86 >
87 >  <path id="javac.bootclasspath">
88 >    <!-- <pathelement location="${src.dir}"/> -->
89      <pathelement location="${collect.jar}"/>
90      <pathelement location="${rt.jar}"/>
91    </path>
92  
93 +  <!-- Flatten bootclasspath prefix into a platform-appropriate string -->
94 +  <property name="javac.bootclasspath.prefix" refid="javac.bootclasspath.prefix"/>
95 +
96 +  <!-- Turn the flattened bootclasspath prefix into a javac argument -->
97 +  <property name="javac.args" value='-J-Xbootclasspath/p:${javac.bootclasspath.prefix}'/>
98 +
99 +
100 +
101 +  <!--
102 +   ! Bootclasspath munging for testing, so JUnit can test our local
103 +   ! modifications to java.*.
104 +   -->
105 +
106    <path id="test.classpath">
107      <pathelement location="${product.jar}"/>
108 +    <pathelement location="${build.testcases.dir}"/>
109 +    <pathelement location="${junit.jar}"/>
110    </path>
111  
112 +  <!-- Flatten test classpath into a platform-appropriate string -->
113 +  <property name="test.classpath" refid="test.classpath"/>
114 +
115 +  <!-- Turn the flattened test classpath into a javac argument -->
116 +  <property name="test.javac.args" value='-Xbootclasspath/p:${test.classpath}'/>
117 +
118 +
119 +
120 +  <!-- Files excluded from emulation and dist-docs -->
121 +  <patternset id="emulation.excludes">
122 +    <exclude name="java/util/Random.*"/>
123 +    <exclude name="sun/misc/Unsafe.*"/>
124 +  </patternset>
125 +
126 +
127 +
128 +  <!-- Main targets -->
129 +
130 +  <target name="compile"
131 +          depends="init"
132 +          description="Compiles main sources to build folder">
133  
56  <target name="compile">
134      <mkdir dir="${build.classes.dir}"/>
135 +
136      <javac srcdir="${src.dir}"
137            destdir="${build.classes.dir}"
138              debug="${build.debug}"
# Line 63 | Line 141
141             source="${build.sourcelevel}"
142               fork="true">
143  
144 <      <bootclasspath refid="gj.compiler.bootclasspath"/>
145 <      <compilerarg line="${gj.compiler.args}"/>
68 <
69 <      <!-- need this because srcdir is basedir! -->
70 <      <include name="java/**/*.java"/>
144 >      <bootclasspath refid="javac.bootclasspath"/>
145 >      <compilerarg line="${javac.args} ${build.warnings.option}"/>
146  
147      </javac>
148 +
149    </target>
150  
151  
152 <  <target name="jar" depends="compile">
153 <    <mkdir dir="${build.lib.dir}"/>
154 <    <jar basedir="${build.classes.dir}"
155 <        destfile="${product.jar}"
156 <    />
152 >  <target name="jar"
153 >          depends="native-jar, emulation-jar"
154 >          description="Builds library jar from compiled sources"/>
155 >
156 >
157 >  <target name="test"
158 >          depends="init, check-junit, report-tests"
159 >          description="Runs all tests (requires JUnit 3.8+ in ${ant.home}/lib)" />
160 >
161 >
162 >  <target name="checkstyle"
163 >          depends="filter-src"
164 >          description="Reports on style errors in Java source (verbose, mostly chaff)">
165 >
166 >    <taskdef resource="checkstyletask.properties"
167 >            classpath="${lib.dir}/checkstyle-all-2.4.jar"/>
168 >
169 >    <checkstyle>
170 >      <formatter type="plain"/>  <!-- also available: type="xml" -->
171 >      <fileset dir="${build.filter.src.dir}" includes="**/*.java"/>
172 >    </checkstyle>
173 >
174    </target>
175  
176  
177 <  <target name="test" depends="report-tests"/>
177 >  <target name="doccheck"
178 >          depends="filter-src"
179 >          description="Reports on javadoc style errors (not working yet)">
180 >
181 >    <delete dir="${build.doccheck.dir}"/>
182 >    <mkdir dir="${build.doccheck.dir}"/>
183 >
184 >    <javadoc doclet="com.sun.tools.doclets.doccheck.DocCheck"
185 >         docletpath="${lib.dir}/doccheck.jar"
186 >            destdir="${build.doccheck.dir}">
187 >      <packageset dir="${build.filter.src.dir}"/>
188 >    </javadoc>
189 >
190 >  </target>
191 >
192  
193 +  <target name="docs"
194 +          depends="filter-src"
195 +          description="Builds javadocs with custom tags to build folder">
196  
87  <target name="docs" depends="filter-src">
197      <delete dir="${build.javadocs.dir}"/>
198      <mkdir dir="${build.javadocs.dir}"/>
199 +
200      <javadoc destdir="${build.javadocs.dir}"
201                  link="http://java.sun.com/j2se/1.4.1/docs/api"
202              overview="${src.dir}/intro.html"
203 <              source="${build.sourcelevel}">
203 >              source="${build.docsourcelevel}">
204  
205        <tag name="revised" description="Last revised:"/>
206        <tag name="spec" description="Specified by:"/>
207        <tag name="editor" description="Last edited by:"/>
208        <tag name="fixme" description="FIX ME:"/>
209 <      <packageset dir="${build.filter.src.dir}">
100 <        <include name="java/**"/>
101 <      </packageset>
209 >      <packageset dir="${build.filter.src.dir}"/>
210  
211      </javadoc>
212 +
213    </target>
214  
215  
216 <  <target name="clean">
216 >  <!--
217 >   # javac -s doesn't reliably generate compilable code. It generates
218 >   # bridge methods (marked as "synthetic") that can have identical
219 >   # signatures to existing methods except for the return value.
220 >   -->
221 >  <target name="strip"
222 >          depends="init">
223 >
224 >    <mkdir dir="${build.stripped.dir}"/>
225 >
226 >    <javac srcdir="${src.dir}"
227 >          destdir="${build.stripped.dir}"
228 >            debug="${build.debug}"
229 >       debuglevel="${build.debuglevel}"
230 >      deprecation="${build.deprecation}"
231 >           source="${build.sourcelevel}"
232 >             fork="true">
233 >
234 >      <bootclasspath refid="javac.bootclasspath"/>
235 >      <compilerarg line="${javac.args} ${build.warnings.option} -s"/>
236 >
237 >    </javac>
238 >
239 >  </target>
240 >
241 >
242 >  <target name="dist"
243 >          depends="init, dist-clean, dist-jar, dist-docs"
244 >          description="Puts all distributable products in single hierarchy"/>
245 >
246 >
247 >  <target name="clean"
248 >          description="Removes all build products">
249 >
250      <delete dir="${build.dir}"/>
251      <delete dir="${build.classes.dir}"/>
252      <delete dir="${build.lib.dir}"/>
253 <    <delete dir="${build.javadocs.dir}"/>
253 >
254 >  </target>
255 >
256 >
257 >  <target name="dist-clean"
258 >          description="Removes all build and distribution products">
259 >
260 >    <delete dir="${dist.dir}"/>
261 >
262    </target>
263  
264  
265 <  <!-- Internal targets used by docs target -->
265 >  <target name="dist-docs"
266 >          depends="filter-src"
267 >          description="Builds javadocs without custom tags to dist folder">
268 >
269 >    <delete dir="${dist.javadocs.dir}"/>
270 >    <mkdir dir="${dist.javadocs.dir}"/>
271 >
272 >    <javadoc destdir="${dist.javadocs.dir}"
273 >                link="http://java.sun.com/j2se/1.4.1/docs/api"
274 >            overview="${src.dir}/intro.html"
275 >              source="${build.docsourcelevel}">
276 >
277 >      <packageset dir="${build.filter.src.dir}"/>
278 >
279 >    </javadoc>
280 >
281 >  </target>
282 >
283 >
284 >
285 >  <!-- Internal targets -->
286 >
287 >  <target name="set-warnings-if" if="build.warnings">
288 >
289 >    <property name="build.warnings.option" value="-warnunchecked"/>
290 >
291 >  </target>
292 >
293 >
294 >  <target name="set-warnings-unless" unless="build.warnings">
295 >
296 >    <property name="build.warnings.option" value=""/>
297 >
298 >  </target>
299 >
300 >
301 >  <target name="init"
302 >          depends="set-warnings-if, set-warnings-unless">
303 >
304 >    <!-- Version is kept in a separate file -->
305 >    <loadfile property="version" srcFile="version.properties"/>
306 >    <echo>Building JSR-166 version ${version}</echo>
307 >
308 >  </target>
309 >
310 >
311 >  <target name="init-jar">
312 >
313 >    <mkdir dir="${build.lib.dir}"/>
314 >
315 >  </target>
316 >
317 >
318 >  <target name="native-jar"
319 >          depends="compile, init-jar"
320 >          unless="build.emulation">
321 >
322 >    <jar destfile="${product.jar}">
323 >      <fileset dir="${build.classes.dir}"/>
324 >    </jar>
325 >
326 >  </target>
327 >
328 >
329 >  <target name="base-jar"
330 >          depends="compile, init-jar">
331 >
332 >    <jar destfile="${product.jar}">
333 >      <fileset dir="${build.classes.dir}">
334 >        <patternset refid="emulation.excludes"/>
335 >      </fileset>
336 >    </jar>
337 >
338 >  </target>
339 >
340 >
341 >  <target name="compile-emulation"
342 >          depends="init"
343 >          if="build.emulation">
344 >
345 >    <mkdir dir="${build.emulation.dir}"/>
346 >
347 >    <javac srcdir="${emulation.src.dir}"
348 >          destdir="${build.emulation.dir}"
349 >            debug="${build.debug}"
350 >       debuglevel="${build.debuglevel}"
351 >      deprecation="${build.deprecation}"
352 >           source="${build.sourcelevel}"
353 >             fork="true">
354 >
355 >      <bootclasspath refid="javac.bootclasspath"/>
356 >      <compilerarg line="${javac.args} ${build.warnings.option}"/>
357 >
358 >    </javac>
359 >
360 >  </target>
361 >
362 >
363 >  <target name="emulation-jar"
364 >          depends="base-jar, compile-emulation"
365 >          if="build.emulation">
366 >
367 >    <jar destfile="${product.jar}" update="true" duplicate="add">
368 >      <fileset dir="${build.emulation.dir}"/>
369 >    </jar>
370 >
371 >  </target>
372 >
373 >
374 >  <target name="dist-jar"
375 >          depends="clean, jar">
376 >
377 >    <copy file="${product.jar}" todir="${dist.dir}"/>
378 >
379 >  </target>
380 >
381 >
382 >  <target name="compile-ant-filter"
383 >          depends="init">
384  
117  <target name="compile-ant">
385      <mkdir dir="${build.ant.dir}"/>
386 +
387      <javac srcdir="${ant.src.dir}"
388            destdir="${build.ant.dir}"
389             source="1.4"
390      />
391 +
392    </target>
393  
394  
395 <  <target name="filter-src" depends="compile-ant">
395 >  <target name="filter-src"
396 >          depends="compile-ant-filter">
397 >
398      <mkdir dir="${build.filter.src.dir}"/>
399 +
400      <copy todir="${build.filter.src.dir}">
401        <fileset dir="${src.dir}">
402 <        <include name="**/*.java"/>
402 >        <patternset refid="emulation.excludes"/>
403        </fileset>
404        <filterchain>
405          <filterreader classname="jsr166.ant.filters.ReplaceFilter"
# Line 161 | Line 433
433          </filterreader>
434        </filterchain>
435      </copy>
436 +
437    </target>
438  
439  
440 <  <!-- Internal targets used by test target -->
440 >  <target name="compile-tests"
441 >          depends="jar">
442  
169  <target name="compile-tests" depends="jar">
443      <mkdir dir="${build.testcases.dir}"/>
444 +
445      <javac srcdir="${test.src.dir}"
446            destdir="${build.testcases.dir}"
447              debug="${build.debug}"
# Line 176 | Line 450
450             source="${build.sourcelevel}"
451               fork="true">
452  
453 <      <bootclasspath refid="gj.compiler.bootclasspath"/>
454 <      <compilerarg line="${gj.compiler.args}"/>
453 >      <bootclasspath refid="javac.bootclasspath"/>
454 >      <compilerarg line="${javac.args} ${build.warnings.option}"/>
455        <classpath refid="test.classpath"/>
182      <include name="**/*Test.java"/>
456  
457      </javac>
458 +
459    </target>
460  
461 <  <target name="run-tests" depends="compile-tests">
461 >
462 >  <target name="run-tests"
463 >          depends="compile-tests">
464 >
465 >    <!-- May be overridden by user.properties -->
466 >    <property name="testcase" value="*"/>
467 >
468      <mkdir dir="${build.reports.dir}"/>
469 +
470      <junit printsummary="true"
471               showoutput="true"
472            errorProperty="junit.failed"
473          failureProperty="junit.failed"
474 <                    dir="${build.reports.dir}">
474 >                    dir="${build.reports.dir}"
475 >                   fork="true">
476  
477 <      <classpath>
196 <        <path refid="test.classpath"/>
197 <        <pathelement location="${build.testcases.dir}"/>
198 <      </classpath>
477 >      <jvmarg value="${test.javac.args}"/>
478  
479        <formatter type="xml"/>
480  
481        <batchtest todir="${build.reports.dir}">
482          <fileset dir="${test.src.dir}">
483 <          <include name="**/*Test.java"/>
483 >          <include name="**/${testcase}Test.java"/>
484          </fileset>
485        </batchtest>
486  
487      </junit>
488 +
489    </target>
490  
491  
492 <  <target name="report-tests" depends="run-tests">
492 >  <target name="report-tests"
493 >          depends="run-tests">
494 >
495      <!-- Sets junit.report.format to frames if Xalan is present,
496           otherwise sets it to noframes. -->
497      <available property="junit.report.format"
# Line 229 | Line 511
511      </junitreport>
512  
513      <fail message="Test Cases Failed" if="junit.failed"/>
514 +
515 +  </target>
516 +
517 +
518 +  <target name="check-junit">
519 +
520 +    <!-- junit.framework.Protectable is in JUnit 3.8.1 but not in 3.7 -->
521 +    <available property="junit.available"
522 +               classname="junit.framework.Protectable"/>
523 +
524 +    <fail message="Need JUnit 3.8.1 in ${ant.home}${file.separator}lib to run tests"
525 +          unless="junit.available"/>
526 +
527 +  </target>
528 +
529 +
530 +
531 +  <!-- Anthill targets -->
532 +
533 +  <target name="anthill-build"
534 +          depends="jar, test, docs, dist-docs"/>
535 +
536 +  <target name="anthill-publish">
537 +
538 +    <copy todir="${deployDir}/docs/private">
539 +      <fileset dir="${build.javadocs.dir}"/>
540 +    </copy>
541 +
542 +    <copy todir="${deployDir}/docs/public">
543 +      <fileset dir="${dist.javadocs.dir}"/>
544 +    </copy>
545 +
546 +    <copy tofile="${deployDir}/index.html"
547 +          file="${basedir}/etc/anthill-index.html"/>
548 +
549 +    <copy todir="${deployDir}/notes">
550 +      <fileset dir="${basedir}/etc/notes"/>
551 +    </copy>
552 +
553    </target>
554  
555  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines