ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/build.xml
Revision: 1.32
Committed: Thu May 29 04:35:42 2003 UTC (20 years, 11 months ago) by tim
Content type: text/xml
Branch: MAIN
Changes since 1.31: +114 -81 lines
Log Message:
Allow configuring compiler for 1.3, 2.0-variance, and 2.0-novariance.

File Contents

# User Rev Content
1 tim 1.18 <project name="jsr166" default="usage">
2 tim 1.1
3     <description>
4 tim 1.29 ------------------------------------------------------------------------------
5     Build file for JSR-166
6 tim 1.18
7 tim 1.29 Usage: ant [target]
8    
9     User-specific settings are read from user.properties.
10 tim 1.32 See user.properties.sample for an explanation of some useful settings.
11 tim 1.29 ------------------------------------------------------------------------------
12 tim 1.18 </description>
13 tim 1.11
14 tim 1.29 <target name="usage" description="Advises user to run with -projecthelp">
15     <echo>Run "ant -projecthelp" for full usage information.</echo>
16     </target>
17 tim 1.3
18 tim 1.11
19 tim 1.27 <!-- User-specific settings -->
20 tim 1.23 <property file="user.properties"/>
21 tim 1.27
22 tim 1.1
23     <!-- Compilation options -->
24 tim 1.11 <property name="build.sourcelevel" value="1.5"/>
25 tim 1.25 <property name="build.docsourcelevel" value="1.4"/>
26 tim 1.1 <property name="build.debug" value="true"/>
27     <property name="build.debuglevel" value="source,lines,vars"/>
28 tim 1.13 <property name="build.deprecation" value="false"/>
29 tim 1.1
30     <!-- Build locations -->
31     <property name="build.dir" location="build"/>
32     <property name="build.classes.dir" location="${build.dir}/classes"/>
33 tim 1.27 <property name="build.emulation.dir" location="${build.dir}/emulation"/>
34 tim 1.1 <property name="build.testcases.dir" location="${build.dir}/testcases"/>
35     <property name="build.lib.dir" location="${build.dir}/lib"/>
36     <property name="build.ant.dir" location="${build.dir}/ant"/>
37 tim 1.9 <property name="build.javadocs.dir" location="${build.dir}/javadocs"/>
38 tim 1.16 <property name="build.stripped.dir" location="${build.dir}/stripped"/>
39 tim 1.1 <property name="build.reports.dir" location="${build.dir}/reports"/>
40 tim 1.16 <property name="build.doccheck.dir" location="${build.dir}/doccheck"/>
41 tim 1.1 <property name="build.filter.src.dir" location="${build.dir}/filtersrc"/>
42    
43     <!-- Source locations -->
44 tim 1.22 <property name="src.dir" location="${basedir}/src/main"/>
45 tim 1.27 <property name="emulation.src.dir" location="${basedir}/src/emulation"/>
46 tim 1.22 <property name="test.src.dir" location="${basedir}/src/test"/>
47 tim 1.1 <property name="ant.src.dir" location="${basedir}/etc/ant"/>
48     <property name="stylesheet.dir" location="${basedir}/etc/xsl"/>
49     <property name="lib.dir" location="${basedir}/lib"/>
50 tim 1.9 <property name="dist.dir" location="${basedir}/dist"/>
51    
52     <!-- Distribution locations -->
53     <property name="dist.javadocs.dir" location="${dist.dir}/docs"/>
54 tim 1.1
55     <!-- Jar locations -->
56     <property name="product.jar" location="${build.lib.dir}/jsr166.jar"/>
57     <property name="junit.jar" location="${lib.dir}/junit.jar"/>
58     <property name="rt.jar" location="${java.home}/lib/rt.jar"/>
59    
60 tim 1.27
61 tim 1.28
62     <!-- Files excluded from emulation and dist-docs -->
63     <patternset id="emulation.excludes">
64     <exclude name="java/util/Random.*"/>
65     <exclude name="sun/misc/Unsafe.*"/>
66     </patternset>
67    
68    
69    
70 tim 1.11 <!-- Main targets -->
71    
72 tim 1.28 <target name="compile"
73 tim 1.32 depends="init, configure-compiler"
74 tim 1.27 description="Compiles main sources to build folder">
75    
76 tim 1.1 <mkdir dir="${build.classes.dir}"/>
77 tim 1.27
78 tim 1.1 <javac srcdir="${src.dir}"
79     destdir="${build.classes.dir}"
80     debug="${build.debug}"
81     debuglevel="${build.debuglevel}"
82     deprecation="${build.deprecation}"
83     source="${build.sourcelevel}"
84     fork="true">
85    
86 tim 1.11 <bootclasspath refid="javac.bootclasspath"/>
87 tim 1.31 <compilerarg line="${build.javac.args}"/>
88 tim 1.1
89     </javac>
90 tim 1.27
91 tim 1.1 </target>
92    
93    
94 tim 1.28 <target name="jar"
95 tim 1.32 depends="configure-emulation, init-jar, native-jar, emulation-jar"
96 tim 1.28 description="Builds library jar from compiled sources"/>
97 tim 1.1
98    
99 tim 1.28 <target name="test"
100 tim 1.32 depends="init, configure-tests, report-tests"
101 tim 1.29 description="Runs all tests (requires JUnit 3.8.1 in ${ant.home}/lib)" />
102 tim 1.1
103    
104 tim 1.28 <target name="checkstyle"
105     depends="filter-src"
106 tim 1.18 description="Reports on style errors in Java source (verbose, mostly chaff)">
107 tim 1.27
108 tim 1.15 <taskdef resource="checkstyletask.properties"
109     classpath="${lib.dir}/checkstyle-all-2.4.jar"/>
110    
111     <checkstyle>
112 tim 1.16 <formatter type="plain"/> <!-- also available: type="xml" -->
113 tim 1.15 <fileset dir="${build.filter.src.dir}" includes="**/*.java"/>
114     </checkstyle>
115 tim 1.27
116 tim 1.15 </target>
117    
118 tim 1.16
119 tim 1.28 <target name="doccheck"
120     depends="filter-src"
121 tim 1.18 description="Reports on javadoc style errors (not working yet)">
122 tim 1.27
123 tim 1.16 <delete dir="${build.doccheck.dir}"/>
124     <mkdir dir="${build.doccheck.dir}"/>
125 tim 1.27
126 tim 1.16 <javadoc doclet="com.sun.tools.doclets.doccheck.DocCheck"
127     docletpath="${lib.dir}/doccheck.jar"
128     destdir="${build.doccheck.dir}">
129 tim 1.22 <packageset dir="${build.filter.src.dir}"/>
130 tim 1.16 </javadoc>
131 tim 1.27
132 tim 1.16 </target>
133    
134    
135 tim 1.28 <target name="docs"
136     depends="filter-src"
137 tim 1.9 description="Builds javadocs with custom tags to build folder">
138 tim 1.27
139 tim 1.9 <delete dir="${build.javadocs.dir}"/>
140     <mkdir dir="${build.javadocs.dir}"/>
141 tim 1.27
142 tim 1.9 <javadoc destdir="${build.javadocs.dir}"
143 tim 1.8 link="http://java.sun.com/j2se/1.4.1/docs/api"
144     overview="${src.dir}/intro.html"
145 dholmes 1.24 source="${build.docsourcelevel}">
146 tim 1.8
147 tim 1.9 <tag name="revised" description="Last revised:"/>
148 tim 1.29 <tag name="spec" description="Specified by:"/>
149     <tag name="editor" description="Last edited by:"/>
150     <tag name="fixme" description="FIX ME:"/>
151    
152 tim 1.22 <packageset dir="${build.filter.src.dir}"/>
153 tim 1.8
154     </javadoc>
155 tim 1.27
156 tim 1.8 </target>
157    
158    
159 tim 1.28 <target name="strip"
160 tim 1.32 depends="init, configure-compiler"
161 tim 1.31 description="Strip generics from java source (not working yet)">
162 tim 1.27
163 tim 1.16 <mkdir dir="${build.stripped.dir}"/>
164 tim 1.27
165 tim 1.31 <!--
166     # javac -s doesn't reliably generate compilable code. It generates
167     # bridge methods (marked as "synthetic") that can have identical
168     # signatures to existing methods except for the return value.
169     -->
170 tim 1.16 <javac srcdir="${src.dir}"
171     destdir="${build.stripped.dir}"
172     debug="${build.debug}"
173     debuglevel="${build.debuglevel}"
174     deprecation="${build.deprecation}"
175     source="${build.sourcelevel}"
176     fork="true">
177    
178     <bootclasspath refid="javac.bootclasspath"/>
179 tim 1.31 <compilerarg line="${build.javac.args} -s"/>
180 tim 1.16
181     </javac>
182 tim 1.27
183 tim 1.16 </target>
184    
185    
186 tim 1.28 <target name="dist"
187     depends="init, dist-clean, dist-jar, dist-docs"
188 tim 1.16 description="Puts all distributable products in single hierarchy"/>
189 tim 1.1
190    
191 tim 1.11 <target name="clean"
192     description="Removes all build products">
193 tim 1.27
194 tim 1.11 <delete dir="${build.dir}"/>
195     <delete dir="${build.classes.dir}"/>
196     <delete dir="${build.lib.dir}"/>
197 tim 1.27
198 tim 1.1 </target>
199    
200    
201 tim 1.11 <target name="dist-clean"
202     description="Removes all build and distribution products">
203 tim 1.27
204 tim 1.11 <delete dir="${dist.dir}"/>
205 tim 1.27
206 tim 1.9 </target>
207 tim 1.10
208    
209 tim 1.28 <target name="dist-docs"
210     depends="filter-src"
211     description="Builds javadocs without custom tags to dist folder">
212    
213     <delete dir="${dist.javadocs.dir}"/>
214     <mkdir dir="${dist.javadocs.dir}"/>
215    
216     <javadoc destdir="${dist.javadocs.dir}"
217     link="http://java.sun.com/j2se/1.4.1/docs/api"
218     overview="${src.dir}/intro.html"
219     source="${build.docsourcelevel}">
220    
221     <packageset dir="${build.filter.src.dir}"/>
222 tim 1.14
223 tim 1.28 </javadoc>
224 tim 1.14
225     </target>
226    
227    
228 tim 1.28
229 tim 1.11 <!-- Internal targets -->
230 tim 1.9
231 tim 1.16
232 tim 1.32 <target name="init">
233 tim 1.27
234 tim 1.11 <!-- Version is kept in a separate file -->
235     <loadfile property="version" srcFile="version.properties"/>
236     <echo>Building JSR-166 version ${version}</echo>
237 tim 1.27
238     </target>
239    
240    
241 tim 1.28 <target name="init-jar">
242 tim 1.27
243     <mkdir dir="${build.lib.dir}"/>
244    
245 tim 1.28 </target>
246    
247    
248     <target name="native-jar"
249 tim 1.30 depends="compile"
250     unless="build.emulation.true">
251 tim 1.28
252 tim 1.27 <jar destfile="${product.jar}">
253     <fileset dir="${build.classes.dir}"/>
254     </jar>
255    
256     </target>
257    
258    
259 tim 1.28 <target name="compile-emulation"
260 tim 1.32 depends="init, configure-compiler"
261 tim 1.30 if="build.emulation.true">
262 tim 1.27
263     <mkdir dir="${build.emulation.dir}"/>
264    
265     <javac srcdir="${emulation.src.dir}"
266     destdir="${build.emulation.dir}"
267     debug="${build.debug}"
268     debuglevel="${build.debuglevel}"
269     deprecation="${build.deprecation}"
270     source="${build.sourcelevel}"
271     fork="true">
272    
273     <bootclasspath refid="javac.bootclasspath"/>
274 tim 1.31 <compilerarg line="${build.javac.args}"/>
275 tim 1.27
276     </javac>
277    
278     </target>
279    
280    
281 tim 1.28 <target name="emulation-jar"
282 tim 1.30 depends="compile-emulation"
283     if="build.emulation.true">
284 tim 1.27
285 tim 1.29
286     <jar destfile="${product.jar}" duplicate="add">
287     <fileset dir="${build.classes.dir}">
288     <patternset refid="emulation.excludes"/>
289     </fileset>
290 tim 1.27 <fileset dir="${build.emulation.dir}"/>
291     </jar>
292    
293 tim 1.9 </target>
294    
295    
296 tim 1.28 <target name="dist-jar"
297     depends="clean, jar">
298 tim 1.27
299 tim 1.11 <copy file="${product.jar}" todir="${dist.dir}"/>
300 tim 1.27
301 tim 1.11 </target>
302    
303    
304 tim 1.28 <target name="compile-ant-filter"
305     depends="init">
306 tim 1.27
307 tim 1.1 <mkdir dir="${build.ant.dir}"/>
308 tim 1.27
309 tim 1.1 <javac srcdir="${ant.src.dir}"
310     destdir="${build.ant.dir}"
311     source="1.4"
312     />
313 tim 1.27
314 tim 1.1 </target>
315    
316    
317 tim 1.28 <target name="filter-src"
318     depends="compile-ant-filter">
319 tim 1.27
320 tim 1.1 <mkdir dir="${build.filter.src.dir}"/>
321 tim 1.27
322 tim 1.1 <copy todir="${build.filter.src.dir}">
323     <fileset dir="${src.dir}">
324 tim 1.31 <include name="**/*.html"/>
325     </fileset>
326     </copy>
327    
328     <copy todir="${build.filter.src.dir}">
329     <fileset dir="${src.dir}">
330     <exclude name="**/*.html"/>
331 tim 1.28 <patternset refid="emulation.excludes"/>
332 tim 1.1 </fileset>
333     <filterchain>
334     <filterreader classname="jsr166.ant.filters.ReplaceFilter"
335     classpath="${build.ant.dir}">
336     <!--
337     # These arguments are to get rid of angle-bracketed type
338     # parameters so that javadoc can run on the result. The
339     # following heuristic that seems to work:
340     #
341     # For all lines not starting with space(s)-asterisk-space(s),
342     # replace <something> with a space, where there may be more
343     # than one right angle bracket at the end, and "something"
344     # must not contain parens or pipes. (This may need some
345     # tweaking.)
346     -->
347     <param name="notmatching" value="^\s+\*\s.*$"/>
348     <param name="pattern" value="&lt;[^|>()]+?>+"/>
349     <param name="replacement" value=" "/>
350     </filterreader>
351     <filterreader classname="jsr166.ant.filters.ReplaceFilter"
352     classpath="${build.ant.dir}">
353     <!--
354     # These arguments are to uncomment lines beginning with
355     # "//@" so that javadoc can see imports that are needed
356     # to resolve links but that shouldn't be in the compiled
357     # code.
358     -->
359     <param name="matching" value="^//@.*$"/>
360     <param name="pattern" value="^//@"/>
361     <param name="replacement" value=""/>
362     </filterreader>
363     </filterchain>
364     </copy>
365 tim 1.27
366 tim 1.1 </target>
367    
368    
369 tim 1.28 <target name="compile-tests"
370     depends="jar">
371 tim 1.27
372 tim 1.1 <mkdir dir="${build.testcases.dir}"/>
373 tim 1.27
374 tim 1.1 <javac srcdir="${test.src.dir}"
375     destdir="${build.testcases.dir}"
376     debug="${build.debug}"
377     debuglevel="${build.debuglevel}"
378     deprecation="${build.deprecation}"
379     source="${build.sourcelevel}"
380     fork="true">
381    
382 tim 1.31 <classpath refid="test.classpath"/>
383 tim 1.11 <bootclasspath refid="javac.bootclasspath"/>
384 tim 1.31 <compilerarg line="${build.javac.args}"/>
385 tim 1.1
386     </javac>
387 tim 1.27
388 tim 1.1 </target>
389 tim 1.11
390 tim 1.1
391 tim 1.28 <target name="run-tests"
392     depends="compile-tests">
393 tim 1.27
394     <!-- May be overridden by user.properties -->
395     <property name="testcase" value="*"/>
396    
397 tim 1.1 <mkdir dir="${build.reports.dir}"/>
398 tim 1.27
399 tim 1.1 <junit printsummary="true"
400     showoutput="true"
401     errorProperty="junit.failed"
402     failureProperty="junit.failed"
403 tim 1.12 dir="${build.reports.dir}"
404     fork="true">
405    
406 tim 1.31 <jvmarg value="${test.bootclasspath.arg}"/>
407 tim 1.1
408     <formatter type="xml"/>
409    
410     <batchtest todir="${build.reports.dir}">
411     <fileset dir="${test.src.dir}">
412 tim 1.23 <include name="**/${testcase}Test.java"/>
413 tim 1.1 </fileset>
414     </batchtest>
415    
416     </junit>
417 tim 1.27
418 tim 1.1 </target>
419    
420    
421 tim 1.28 <target name="report-tests"
422     depends="run-tests">
423    
424 tim 1.1 <!-- Sets junit.report.format to frames if Xalan is present,
425     otherwise sets it to noframes. -->
426     <available property="junit.report.format"
427     value="frames"
428     classname="org.apache.xalan.lib.Redirect"
429     />
430     <property name="junit.report.format" value="noframes"/>
431    
432     <junitreport todir="${build.reports.dir}">
433     <fileset dir="${build.reports.dir}">
434     <include name="TEST-*.xml"/>
435     </fileset>
436     <report styledir="${stylesheet.dir}"
437     format="${junit.report.format}"
438     todir="${build.reports.dir}"
439     />
440     </junitreport>
441    
442     <fail message="Test Cases Failed" if="junit.failed"/>
443 tim 1.28
444 tim 1.18 </target>
445    
446    
447 tim 1.32 <target name="configure-compiler">
448    
449     <property name="gjc.version"
450     value="1.3"/>
451    
452     <condition property="build.novariance" value="-novariance">
453     <and>
454     <equals arg1="${gjc.version}" arg2="2.0"/>
455     <or>
456     <not><isset property="gjc.novariance"/></not>
457     <istrue value="${gjc.novariance}"/>
458     </or>
459     </and>
460     </condition>
461    
462     <property name="build.novariance"
463     value=""/>
464    
465     <property name="gjc.dir"
466     value="${lib.dir}/gjc"/>
467    
468     <property name="javac.jar"
469     location="${gjc.dir}/${gjc.version}/javac.jar"/>
470    
471     <property name="collect.jar"
472     location="${gjc.dir}/${gjc.version}/collect${build.novariance}.jar"/>
473    
474    
475     <condition property="build.warnunchecked" value="-warnunchecked">
476     <istrue value="${gjc.warnunchecked}"/>
477     </condition>
478    
479     <property name="build.warnunchecked" value=""/>
480    
481    
482     <!--
483     ! Bootclasspath munging for source compilation.
484     -->
485    
486     <path id="javac.bootclasspath.prefix">
487     <!-- <pathelement location="${src.dir}"/> -->
488     <pathelement location="${javac.jar}"/>
489     </path>
490    
491     <path id="javac.bootclasspath">
492     <!-- <pathelement location="${src.dir}"/> -->
493     <pathelement location="${collect.jar}"/>
494     <pathelement location="${rt.jar}"/>
495     </path>
496    
497     <!-- Flatten bootclasspath prefix into a platform-appropriate string -->
498     <property name="javac.bootclasspath.prefix"
499     refid="javac.bootclasspath.prefix"/>
500    
501     <!-- Turn the flattened bootclasspath prefix into a javac argument -->
502     <property name="build.bootclasspath.arg"
503     value='-J-Xbootclasspath/p:${javac.bootclasspath.prefix}'/>
504    
505     <!-- Flatten bootclasspath for trace message -->
506     <property name="javac.bootclasspath"
507     refid="javac.bootclasspath"/>
508    
509     <!-- Common options in javac invocations -->
510     <property name="build.javac.args"
511     value="${build.bootclasspath.arg} ${build.warnunchecked} ${build.novariance}"/>
512    
513     <echo>javac ${build.javac.args}
514     bootclasspath is ${javac.bootclasspath}</echo>
515    
516     </target>
517    
518    
519     <target name="configure-emulation">
520    
521     <condition property="build.emulation.true">
522     <or>
523     <and>
524     <os family="windows"/>
525     <not>
526     <isset property="build.emulation"/>
527     </not>
528     </and>
529     <istrue value="${build.emulation}"/>
530     </or>
531     </condition>
532    
533     </target>
534    
535    
536     <target name="configure-tests">
537 tim 1.28
538     <!-- junit.framework.Protectable is in JUnit 3.8.1 but not in 3.7 -->
539 tim 1.18 <available property="junit.available"
540 tim 1.28 classname="junit.framework.Protectable"/>
541    
542     <fail message="Need JUnit 3.8.1 in ${ant.home}${file.separator}lib to run tests"
543     unless="junit.available"/>
544    
545 tim 1.30
546 tim 1.32 <!--
547     ! Bootclasspath munging for testing, so JUnit can test our local
548     ! modifications to java.*.
549     -->
550    
551     <path id="test.classpath">
552     <pathelement location="${product.jar}"/>
553     <pathelement location="${build.testcases.dir}"/>
554     <pathelement location="${junit.jar}"/>
555     </path>
556    
557     <!-- Flatten test classpath into a platform-appropriate string -->
558     <property name="test.classpath" refid="test.classpath"/>
559    
560     <!-- Turn the flattened test classpath into a javac argument -->
561     <property name="test.bootclasspath.arg"
562     value='-Xbootclasspath/p:${test.classpath}'/>
563 tim 1.30
564 tim 1.28 </target>
565    
566    
567    
568     <!-- Anthill targets -->
569    
570     <target name="anthill-build"
571     depends="jar, test, docs, dist-docs"/>
572    
573     <target name="anthill-publish">
574    
575     <copy todir="${deployDir}/docs/private">
576     <fileset dir="${build.javadocs.dir}"/>
577     </copy>
578    
579     <copy todir="${deployDir}/docs/public">
580     <fileset dir="${dist.javadocs.dir}"/>
581     </copy>
582    
583     <copy tofile="${deployDir}/index.html"
584     file="${basedir}/etc/anthill-index.html"/>
585    
586     <copy todir="${deployDir}/notes">
587     <fileset dir="${basedir}/etc/notes"/>
588     </copy>
589    
590 tim 1.1 </target>
591    
592    
593     </project>