Mon, 13 Dec 2010 17:35:57 -0800
6999460: Glassfish build with JDK 6 / 7 is 5x-10x slower on Windows than on Linux
Summary: Fixed JavacFileManager to not treat a non-existant pathname as a directory.
Reviewed-by: jjg
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!--
3 Copyright (c) 2007, 2009, Oracle and/or its affiliates. All rights reserved.
4 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 This code is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License version 2 only, as
8 published by the Free Software Foundation. Oracle designates this
9 particular file as subject to the "Classpath" exception as provided
10 by Oracle in the LICENSE file that accompanied this code.
12 This code is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 version 2 for more details (a copy is included in the LICENSE file that
16 accompanied this code).
18 You should have received a copy of the GNU General Public License version
19 2 along with this work; if not, write to the Free Software Foundation,
20 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
23 or visit www.oracle.com if you need additional information or have any
24 questions.
25 -->
27 <!--
28 This is the main build file for the complete langtools repository.
29 It is used when building JDK (in which case it is invoked from the
30 Makefile), and it can be used when working on the tools themselves,
31 in an IDE such as NetBeans.
33 External dependencies are specified via properties. These can be given
34 on the command line, or by providing a local build.properties file.
35 (They can also be edited into make/build.properties, although that is not
36 recommended.) At a minimum, boot.java.home must be set to the installed
37 location of the version of JDK used to build this repository. Additional
38 properties may be required, depending on the targets that are built.
39 For example, to run any of the jtreg tests you must set jtreg.home,
40 to run findbugs on the code you must set findbugs.home, and so on.
42 For the most part, javac can be built using the previous version of JDK.
43 However, a small number of javac files require access to the latest JDK,
44 which may not yet have been compiled. To compile these files, you can do
45 one of the following:
46 - Set boot.java.home to a recent build of the latest version of JDK.
47 - Set import.jdk to either a recent build (containing jre/lib/rt.jar)
48 or to jdk source repository. In the latter case, stub files will
49 automatically be generated and used for the required API, to avoid
50 unnecessary compilation of the source repository.
51 If you do neither, the relevant files will not be built.
53 The main build happens in two phases:
54 - First, javac and other tools as needed are built using ${boot.java.home}.
55 (This implies a constraint on the source code that they can be compiled
56 with the previous version of JDK.
57 - Second, all required classes are compiled with the latest javac, created
58 in the previous step.
59 The first phase is called the bootstrap phase. All targets, properties and
60 tasks that are specific to that phase have "bootstrap" in their name.
62 For more details on the JDK build, see
63 http://blogs.sun.com/kto/entry/anatomy_of_the_jdk_build
64 http://openjdk.java.net/groups/build/
65 For more details on the stub generator, see
66 http://blogs.sun.com/jjg/entry/building_javac_for_jdk7
68 Internal details ...
70 Interim build products are created in the build/ directory.
71 Final build products are created in the dist/ directory.
72 When building JDK, the dist/directory will contain:
73 - A bootstrap compiler suitable for running with ${boot.java.home}
74 suitable for compiling downstream parts of JDK
75 - Source files and class files for inclusion in the JDK being built
76 When building standalone, the dist/directory will contain:
77 - Separate jar files for each of the separate langtools components
78 - Simple scripts to invoke the tools by executing the corresponding
79 jar files.
80 These jar files and scripts are "for developer use only".
82 This file is organized into sections as follows:
83 - global property definitions
84 - general top level targets
85 - general diagnostic/debugging targets
86 - groups of targets for each tool: javac, javadoc, doclets, javah, javap, apt
87 Within each group, the following targets are provided, where applicable
88 build-bootstrap-TOOL build the bootstrap version of the tool
89 build-classes-TOOL build the classes for the tool
90 build-TOOL build the jar file and script for the tool
91 jtreg-TOOL build the tool and run the appropriate tests
92 findbugs-TOOL run findbugs on the tool's source oode
93 TOOL build the tool, run the tests, and run findbugs
94 - utility definitions
95 -->
97 <project name="langtools" default="build" basedir="..">
98 <!--
99 **** Global property definitions.
100 -->
102 <!-- Force full debuginfo for javac if the debug.classfiles
103 property is set. This must be BEFORE the include of
104 build.properties because it sets javac.debuglevel. -->
105 <condition property="javac.debuglevel" value="source,lines,vars">
106 <equals arg1="${debug.classfiles}" arg2="true"/>
107 </condition>
109 <!-- The following locations can be used to override default property values. -->
111 <!-- Use this location for customizations specific to this instance of this workspace -->
112 <property file="build.properties"/>
114 <!-- Use this location for customizations common to all OpenJDK langtools workspaces -->
115 <property file="${user.home}/.openjdk/${ant.project.name}-build.properties"/>
117 <!-- Use this location for customizations common to all OpenJDK workspaces -->
118 <property file="${user.home}/.openjdk/build.properties"/>
120 <!-- Convenient shorthands for standard locations within the workspace. -->
121 <property name="build.dir" location="build"/>
122 <property name="build.bootstrap.dir" location="${build.dir}/bootstrap"/>
123 <property name="build.coverage.dir" location="${build.dir}/coverage"/>
124 <property name="build.classes.dir" location="${build.dir}/classes"/>
125 <property name="build.gensrc.dir" location="${build.dir}/gensrc"/>
126 <property name="build.genstubs.dir" location="${build.dir}/genstubs"/>
127 <property name="build.javadoc.dir" location="${build.dir}/javadoc"/>
128 <property name="build.jtreg.dir" location="${build.dir}/jtreg"/>
129 <property name="build.toolclasses.dir" location="${build.dir}/toolclasses"/>
130 <property name="dist.dir" location="dist"/>
131 <property name="dist.bin.dir" location="${dist.dir}/bin"/>
132 <property name="dist.coverage.dir" location="${dist.dir}/coverage"/>
133 <property name="dist.findbugs.dir" location="${dist.dir}/findbugs"/>
134 <property name="dist.lib.dir" location="${dist.dir}/lib"/>
135 <property name="make.dir" location="make"/>
136 <property name="make.tools.dir" location="${make.dir}/tools"/>
137 <property name="src.dir" location="src"/>
138 <property name="src.bin.dir" location="${src.dir}/share/bin"/>
139 <property name="src.classes.dir" location="${src.dir}/share/classes"/>
140 <property name="test.dir" location="test"/>
142 <!-- java.marker is set to a marker file to check for within a Java install dir.
143 The best file to check for across Solaris/Linux/Windows/MacOS is one of the
144 executables; regrettably, that is OS-specific. -->
145 <condition property="java.marker" value="bin/java">
146 <os family="unix"/>
147 </condition>
148 <condition property="java.marker" value="bin/java.exe">
149 <os family="windows"/>
150 </condition>
152 <!-- Standard property values, if not overriden by earlier settings. -->
153 <property file="${make.dir}/build.properties"/>
155 <!-- launcher.java is used in the launcher scripts provided to run
156 the tools' jar files. If it has not already been set, then
157 default it to use ${target.java.home}, if available, otherwise
158 quietly default to simply use "java". -->
159 <condition property="launcher.java"
160 value="${target.java.home}/bin/java" else="java">
161 <isset property="target.java.home"/>
162 </condition>
164 <!-- Logic for handling access import jdk classes, if available.
165 import.jdk should be unset, or set to jdk home (to use rt.jar)
166 or to jdk repo (to use src/share/classes).
167 Based on the value, if any, set up default values for javac's sourcepath,
168 classpath and bootclasspath. Note: the default values are overridden
169 in the build-bootstrap-classes macro. -->
171 <available property="import.jdk.src.dir" value="${import.jdk}/src/share/classes"
172 filepath="${import.jdk}/src/share/classes" file="java/nio/file/Path.java"/>
173 <available property="import.jdk.jar" value="${import.jdk}/jre/lib/rt.jar"
174 ignoresystemclasses="true"
175 classpath="${import.jdk}/jre/lib/rt.jar" classname="java.nio.file.Path"/>
177 <!-- Set the default bootclasspath option used for javac.
178 Note that different variants of the option are used, meaning we can't just
179 define the value for the option.
180 Note the explicit use of the standard property ${path.separator} in the following.
181 This is because Ant is not clever enough to handle direct use of : or ; -->
182 <condition property="javac.bootclasspath.opt"
183 value="-Xbootclasspath:${build.classes.dir}${path.separator}${import.jdk.jar}"
184 else="-Xbootclasspath/p:${build.classes.dir}">
185 <isset property="import.jdk.jar"/>
186 </condition>
188 <condition property="boot.java.provides.latest.jdk">
189 <available
190 ignoresystemclasses="true"
191 classpath="${boot.java.home}/jre/lib/rt.jar" classname="java.nio.file.Path"/>
192 </condition>
194 <condition property="bootstrap.exclude.files" value="" else="${require.latest.jdk.files}">
195 <isset property="boot.java.provides.latest.jdk"/>
196 </condition>
198 <condition property="exclude.files" value="" else="${require.latest.jdk.files}">
199 <or>
200 <isset property="boot.java.provides.latest.jdk"/>
201 <isset property="import.jdk"/>
202 </or>
203 </condition>
205 <condition property="require.import.jdk.stubs">
206 <and>
207 <not>
208 <isset property="boot.java.provides.latest.jdk"/>
209 </not>
210 <isset property="import.jdk.src.dir"/>
211 </and>
212 </condition>
214 <!-- Set the default value of the sourcepath used for javac. -->
215 <condition property="javac.sourcepath" value="${build.genstubs.dir}" else="">
216 <isset property="require.import.jdk.stubs"/>
217 </condition>
219 <!-- Set the default value of the classpath used for javac. -->
220 <property name="javac.classpath" value=""/>
223 <!--
224 **** General top level targets.
225 -->
227 <!-- Standard target to build deliverables for JDK build. -->
229 <target name="build" depends="build-bootstrap-tools,build-all-classes">
230 <copy todir="${dist.dir}/bootstrap">
231 <fileset dir="${build.bootstrap.dir}" includes="bin/,lib/"/>
232 </copy>
233 <chmod dir="${dist.dir}/bootstrap/bin" perm="ugo+rx">
234 <include name="*"/>
235 </chmod>
236 <mkdir dir="${dist.lib.dir}"/>
237 <jar file="${dist.lib.dir}/classes.jar" basedir="${build.classes.dir}"/>
238 <zip file="${dist.lib.dir}/src.zip" basedir="${src.classes.dir}"/>
239 </target>
241 <target name="build-bootstrap-tools"
242 depends="build-bootstrap-javac,build-bootstrap-javadoc,build-bootstrap-doclets,build-bootstrap-javah"
243 />
245 <target name="build-all-tools"
246 depends="build-javac,build-javadoc,build-doclets,build-javah,build-javap,build-apt"
247 />
249 <target name="build-all-classes" depends="build-bootstrap-javac,-create-import-jdk-stubs">
250 <build-classes includes="${javac.includes} ${javadoc.includes} ${doclets.includes} ${javah.includes} ${javap.includes} ${apt.includes}"/>
251 </target>
253 <!-- clean -->
255 <target name="clean" description="Delete all generated files">
256 <delete dir="${build.dir}"/>
257 <delete dir="${dist.dir}"/>
258 </target>
260 <!-- Additional targets for running tools on the build -->
262 <target name="jtreg" depends="build-all-tools,-def-jtreg">
263 <jtreg-tool name="all" tests="${jtreg.tests}"/>
264 </target>
266 <target name="findbugs" depends="-def-findbugs,build-all-tools">
267 <property name="findbugs.reportLevel" value="medium"/>
268 <mkdir dir="${dist.findbugs.dir}"/>
269 <findbugs
270 home="${findbugs.home}"
271 projectName="JDK langtools ${full.version}"
272 output="xml"
273 outputFile="${dist.findbugs.dir}/findbugs.xml"
274 reportLevel="${findbugs.reportLevel}"
275 failOnError="false"
276 errorProperty="findbugs.all.errors"
277 warningsProperty="findbugs.all.warnings"
278 jvm="${target.java.home}/bin/java"
279 jvmargs="-Xmx512M">
280 <class location="${build.classes.dir}"/>
281 <sourcePath>
282 <pathelement location="${src.classes.dir}"/>
283 </sourcePath>
284 </findbugs>
285 <exec executable="sh">
286 <arg value="${findbugs.home}/bin/convertXmlToText"/>
287 <arg value="-longBugCodes"/>
288 <arg value="-html:${findbugs.home}/src/xsl/fancy.xsl"/>
289 <arg value="${dist.findbugs.dir}/findbugs.xml"/>
290 <redirector output="${dist.findbugs.dir}/findbugs.html"/>
291 </exec>
292 </target>
294 <target name="coverage" depends="-def-cobertura,build-all-classes,instrument-classes,jtreg,coverage-report"/>
296 <target name="instrument-classes" depends="-def-cobertura">
297 <!-- only define the following property when we want coverage info -->
298 <path id="coverage.classpath">
299 <pathelement location="${build.coverage.dir}/classes"/>
300 <path refid="cobertura.classpath"/>
301 </path>
302 <property name="coverage.options" value="-Dnet.sourceforge.cobertura.datafile=${build.coverage.dir}/cobertura.ser"/>
303 <property name="coverage.classpath" refid="coverage.classpath"/>
304 <mkdir dir="${build.coverage.dir}/classes"/>
305 <delete file="${build.coverage.dir}/cobertura.ser"/>
306 <cobertura-instrument todir="${build.coverage.dir}/classes"
307 datafile="${build.coverage.dir}/cobertura.ser">
308 <fileset dir="${build.classes.dir}"
309 includes="**/*.class" excludes="**/resources/*.class"/>
310 </cobertura-instrument>
311 </target>
313 <target name="coverage-report" depends="-def-cobertura">
314 <mkdir dir="${dist.coverage.dir}"/>
315 <cobertura-report
316 srcdir="${src.classes.dir}"
317 destdir="${dist.coverage.dir}"
318 datafile="${build.coverage.dir}/cobertura.ser"/>
319 <cobertura-report
320 format="xml"
321 srcdir="${src.classes.dir}"
322 destdir="${dist.coverage.dir}"
323 datafile="${build.coverage.dir}/cobertura.ser"/>
324 </target>
326 <target name="diags-examples" depends="build-javac">
327 <!-- can override the following on the command line if desired. -->
328 <property name="diags.examples.out" location="${build.dir}/diag-examples/diags-examples.html"/>
329 <mkdir dir="${build.dir}/diag-examples/classes"/>
330 <javac fork="true"
331 executable="${dist.bin.dir}/javac"
332 srcdir="test/tools/javac/diags"
333 destdir="${build.dir}/diag-examples/classes"
334 includes="Example.java,FileManager.java,HTMLWriter.java,RunExamples.java"
335 sourcepath=""
336 classpath="${dist.lib.dir}/javac.jar"
337 includeAntRuntime="no"
338 debug="${javac.debug}"
339 debuglevel="${javac.debuglevel}"/>
340 <java fork="true"
341 jvm="${target.java.home}/bin/java"
342 dir="test/tools/javac/diags"
343 classpath="${build.dir}/diag-examples/classes;${dist.lib.dir}/javac.jar"
344 classname="RunExamples">
345 <arg value="-examples"/>
346 <arg value="examples"/>
347 <arg value="-o"/>
348 <arg file="${diags.examples.out}"/>
349 <arg value="-showFiles"/>
350 <arg value="-title"/>
351 <arg value="Examples of javac diagnostics"/>
352 </java>
353 </target>
356 <!--
357 **** Debugging/diagnostic targets.
358 -->
360 <!-- standard JDK target -->
361 <target name="sanity"
362 description="display settings of configuration values">
363 <echo level="info">ant.home = ${ant.home}</echo>
364 <echo level="info">boot.java.home = ${boot.java.home}</echo>
365 <echo level="info">target.java.home = ${target.java.home}</echo>
366 <echo level="info">jtreg.home = ${jtreg.home}</echo>
367 <echo level="info">findbugs.home = ${findbugs.home}</echo>
368 </target>
370 <target name="post-sanity" depends="-def-jtreg,sanity,build"
371 description="perform basic validation after a standard build">
372 <jtreg
373 dir="make/test"
374 workDir="${build.jtreg.dir}/post-sanity/work"
375 reportDir="${build.jtreg.dir}/post-sanity/report"
376 jdk="${target.java.home}"
377 verbose="summary"
378 failonerror="false" resultproperty="jtreg.post-sanity.result">
379 </jtreg>
380 </target>
382 <!-- use vizant tool to generate graphical image of this Ant file.-->
383 <target name="vizant" depends="-def-vizant">
384 <mkdir dir="${build.dir}"/>
385 <echo message="Generating ${build.dir}/build.dot"/>
386 <vizant antfile="${make.dir}/build.xml" outfile="${build.dir}/build.dot"/>
387 <echo message="Generating ${build.dir}/build.png"/>
388 <exec executable="${dot}" >
389 <arg value="-Tpng"/>
390 <arg value="-o"/>
391 <arg file="${build.dir}/build.png"/>
392 <arg file="${build.dir}/build.dot"/>
393 </exec>
394 </target>
396 <target name="check-import.jdk">
397 <echo message="import.jdk: ${import.jdk}"/>
398 <echo message="import.jdk.jar: ${import.jdk.jar}"/>
399 <echo message="import.jdk.src.dir: ${import.jdk.src.dir}"/>
400 </target>
402 <target name="diagnostics">
403 <diagnostics/>
404 </target>
407 <!--
408 **** javac targets.
409 -->
411 <target name="build-bootstrap-javac"
412 depends="-def-build-bootstrap-classes,-def-build-bootstrap-jar,-def-build-bootstrap-tool">
413 <build-bootstrap-classes includes="${javac.includes}"/>
414 <build-bootstrap-jar name="javac" includes="${javac.includes}"/>
415 <build-bootstrap-tool name="javac"/>
416 </target>
418 <target name="build-classes-javac" depends="build-bootstrap-javac,-create-import-jdk-stubs">
419 <build-classes includes="${javac.includes}"/>
420 </target>
422 <target name="build-javac" depends="build-classes-javac">
423 <build-jar name="javac" includes="${javac.includes}"/>
424 <build-tool name="javac"/>
425 </target>
427 <target name="javadoc-javac" depends="build-javac,-def-javadoc-tool">
428 <javadoc-tool name="javac" includes="${javac.includes}" options="${javadoc.jls3.option}"/>
429 </target>
431 <target name="jtreg-javac" depends="build-javac,build-javap,-def-jtreg">
432 <jtreg-tool name="javac" tests="${javac.tests}"/>
433 </target>
435 <target name="findbugs-javac" depends="build-javac,-def-findbugs">
436 <findbugs-tool name="javac"/>
437 </target>
439 <target name="javac" depends="build-javac,jtreg-javac,findbugs-javac"/>
442 <!--
443 **** javadoc targets.
444 -->
446 <target name="build-bootstrap-javadoc" depends="build-bootstrap-javac">
447 <build-bootstrap-classes includes="${javadoc.includes}"/>
448 <build-bootstrap-jar name="javadoc" includes="${javadoc.includes}"
449 jarclasspath="javac.jar doclets.jar"/>
450 <build-bootstrap-tool name="javadoc"/>
451 </target>
453 <target name="build-classes-javadoc" depends="build-classes-javac">
454 <build-classes includes="${javadoc.includes}"/>
455 </target>
457 <target name="build-javadoc" depends="build-javac,build-classes-javadoc">
458 <build-jar name="javadoc" includes="${javadoc.includes}"
459 jarclasspath="javac.jar doclets.jar"/>
460 <build-tool name="javadoc"/>
461 </target>
463 <target name="javadoc-javadoc" depends="build-javadoc,-def-javadoc-tool">
464 <javadoc-tool name="javadoc" includes="${javadoc.includes}"/>
465 </target>
467 <target name="jtreg-javadoc" depends="build-javadoc,-def-jtreg">
468 <jtreg-tool name="javadoc" tests="${javadoc.tests}"/>
469 </target>
471 <target name="findbugs-javadoc" depends="build-javadoc,-def-findbugs">
472 <findbugs-tool name="javadoc"/>
473 </target>
475 <target name="javadoc" depends="build-javadoc,jtreg-javadoc,findbugs-javadoc"/>
478 <!--
479 **** doclets targets.
480 -->
482 <target name="build-bootstrap-doclets" depends="build-bootstrap-javadoc,-def-build-bootstrap-jar">
483 <build-bootstrap-classes includes="${doclets.includes}"/>
484 <build-bootstrap-jar name="doclets" includes="${doclets.includes}"
485 jarmainclass="com.sun.tools.javadoc.Main"
486 jarclasspath="javadoc.jar"/>
487 </target>
489 <target name="build-classes-doclets" depends="build-classes-javadoc">
490 <build-classes includes="${doclets.includes}"/>
491 </target>
493 <target name="build-doclets" depends="build-javadoc,build-classes-doclets">
494 <!-- just jar, no bin for doclets -->
495 <build-jar name="doclets" includes="${doclets.includes}" jarclasspath="javadoc.jar"/>
496 </target>
498 <!-- (no javadoc for doclets) -->
500 <target name="jtreg-doclets" depends="build-doclets,-def-jtreg">
501 <jtreg-tool name="doclets" tests="${doclets.tests}"/>
502 </target>
504 <target name="findbugs-doclets" depends="build-doclets,-def-findbugs">
505 <findbugs-tool name="doclets"/>
506 </target>
508 <target name="doclets" depends="build-doclets,jtreg-doclets,findbugs-doclets"/>
511 <!--
512 **** javah targets.
513 -->
515 <target name="build-bootstrap-javah" depends="build-bootstrap-javadoc">
516 <build-bootstrap-classes includes="${javah.includes}"/>
517 <build-bootstrap-jar name="javah" includes="${javah.includes}"
518 jarclasspath="javadoc.jar doclets.jar javac.jar"/>
519 <build-bootstrap-tool name="javah"/>
520 </target>
522 <target name="build-javah" depends="build-javac,build-classes-javah">
523 <build-jar name="javah" includes="${javah.includes}" jarclasspath="javac.jar"/>
524 <build-tool name="javah"/>
525 </target>
527 <target name="build-classes-javah" depends="build-classes-javadoc">
528 <build-classes includes="${javah.includes}"/>
529 </target>
531 <!-- (no javadoc for javah) -->
533 <target name="jtreg-javah" depends="build-javah,-def-jtreg">
534 <jtreg-tool name="javah" tests="${javah.tests}"/>
535 </target>
537 <target name="findbugs-javah" depends="build-javah,-def-findbugs">
538 <findbugs-tool name="javah"/>
539 </target>
541 <target name="javah" depends="build-javah,jtreg-javah,findbugs-javah"/>
544 <!--
545 **** javap targets.
546 -->
548 <target name="build-bootstrap-javap"
549 depends="-def-build-bootstrap-classes,-def-build-bootstrap-jar,-def-build-bootstrap-tool">
550 <build-bootstrap-classes includes="${javap.includes}"/>
551 <build-bootstrap-jar name="javap" includes="${javap.includes}"
552 jarmainclass="sun.tools.javap.Main"/>
553 <build-bootstrap-tool name="javap"/>
554 </target>
556 <target name="build-classes-javap" depends="build-classes-javac">
557 <build-classes includes="${javap.includes}"/>
558 </target>
560 <target name="build-javap" depends="build-javac,build-classes-javap">
561 <build-jar name="javap" includes="${javap.includes}"
562 jarmainclass="com.sun.tools.javap.Main"
563 jarclasspath="javac.jar"/>
564 <build-tool name="javap"/>
565 </target>
567 <!-- (no javadoc for javap) -->
569 <target name="jtreg-javap" depends="build-javap,-def-jtreg">
570 <jtreg-tool name="javap" tests="${javap.tests}"/>
571 </target>
573 <target name="findbugs-javap" depends="build-javap,-def-findbugs">
574 <findbugs-tool name="javap"/>
575 </target>
577 <target name="javap" depends="build-javap,jtreg-javap,findbugs-javap"/>
580 <!--
581 **** apt targets.
582 -->
584 <target name="build-bootstrap-apt" depends="build-bootstrap-javac">
585 <build-bootstrap-classes includes="${apt.includes}"/>
586 <build-bootstrap-jar name="apt" includes="${apt.includes}"
587 jarclasspath="javac.jar"/>
588 <build-bootstrap-tool name="apt"/>
589 </target>
591 <target name="build-apt" depends="build-javac,build-classes-apt">
592 <build-jar name="apt" includes="${apt.includes}" jarclasspath="javac.jar"/>
593 <build-tool name="apt"/>
594 </target>
596 <target name="build-classes-apt" depends="build-classes-javac">
597 <build-classes includes="${apt.includes}"/>
598 </target>
600 <target name="javadoc-apt" depends="build-apt,-def-javadoc-tool">
601 <javadoc-tool name="apt" includes="${apt.includes}"/>
602 </target>
605 <target name="jtreg-apt" depends="build-apt,-def-jtreg">
606 <jtreg-tool name="apt" tests="${apt.tests}"/>
607 </target>
609 <target name="findbugs-apt" depends="build-apt,-def-findbugs">
610 <findbugs-tool name="apt"/>
611 </target>
613 <target name="apt" depends="build-apt,jtreg-apt,findbugs-apt"/>
616 <!--
617 **** Create import JDK stubs.
618 -->
620 <target name="-create-import-jdk-stubs" depends="-def-genstubs" if="require.import.jdk.stubs">
621 <mkdir dir="${build.genstubs.dir}"/>
622 <genstubs
623 srcdir="${import.jdk.src.dir}" destdir="${build.genstubs.dir}"
624 includes="${import.jdk.stub.files}"
625 fork="true" classpath="${build.toolclasses.dir}:${build.bootstrap.dir}/classes:${ant.core.lib}"
626 />
627 </target>
630 <!--
631 **** Check targets.
632 **** "-check-*" targets check that a required property is set, and set to a reasonable value.
633 **** A user friendly message is generated if not, and the build exits.
634 -->
636 <target name="-check-boot.java.home" depends="-def-check">
637 <check name="bootstrap java" property="boot.java.home" marker="${java.marker}"/>
638 </target>
640 <target name="-check-target.java.home" depends="-def-check">
641 <check name="target java" property="target.java.home" marker="${java.marker}"/>
642 </target>
644 <target name="-check-cobertura.home" depends="-def-check">
645 <check name="cobertura" property="cobertura.home" marker="cobertura.jar"/>
646 </target>
648 <target name="-check-findbugs.home" depends="-def-check">
649 <check name="findbugs" property="findbugs.home" marker="lib/findbugs.jar"/>
650 </target>
652 <target name="-check-jtreg.home" depends="-def-check">
653 <check name="jtreg" property="jtreg.home" marker="lib/jtreg.jar"/>
654 </target>
656 <target name="-check-vizant" depends="-def-check">
657 <check name="vizant" property="vizant.jar"/>
658 <check name="dot" property="dot"/>
659 </target>
662 <!--
663 **** Targets for Ant macro and task definitions.
664 -->
666 <target name="-def-build-tool">
667 <macrodef name="build-tool">
668 <attribute name="name"/>
669 <attribute name="bin.dir" default="${dist.bin.dir}"/>
670 <attribute name="java" default="${launcher.java}"/>
671 <sequential>
672 <mkdir dir="@{bin.dir}"/>
673 <copy file="${src.bin.dir}/launcher.sh-template" tofile="@{bin.dir}/@{name}">
674 <filterset begintoken="#" endtoken="#">
675 <filter token="PROGRAM" value="@{name}"/>
676 <filter token="TARGET_JAVA" value="@{java}"/>
677 <filter token="PS" value="${path.separator}"/>
678 </filterset>
679 </copy>
680 <chmod file="@{bin.dir}/@{name}" perm="ugo+rx"/>
681 </sequential>
682 </macrodef>
683 </target>
685 <target name="-def-build-jar">
686 <macrodef name="build-jar">
687 <attribute name="name"/>
688 <attribute name="includes"/>
689 <attribute name="classes.dir" default="${build.classes.dir}"/>
690 <attribute name="lib.dir" default="${dist.lib.dir}"/>
691 <attribute name="jarmainclass" default="com.sun.tools.@{name}.Main"/>
692 <attribute name="jarclasspath" default=""/>
693 <sequential>
694 <mkdir dir="@{lib.dir}"/>
695 <jar destfile="@{lib.dir}/@{name}.jar"
696 basedir="@{classes.dir}"
697 includes="@{includes}">
698 <manifest>
699 <attribute name="Main-Class" value="@{jarmainclass}"/>
700 <attribute name="Class-Path" value="@{jarclasspath}"/>
701 </manifest>
702 </jar>
703 </sequential>
704 </macrodef>
705 </target>
707 <target name="-def-build-classes" depends="-def-pcompile">
708 <macrodef name="build-classes">
709 <attribute name="includes"/>
710 <attribute name="excludes" default="${exclude.files} **/package-info.java"/>
711 <attribute name="classes.dir" default="${build.classes.dir}"/>
712 <attribute name="gensrc.dir" default="${build.gensrc.dir}"/>
713 <attribute name="javac.bootclasspath" default="${build.bootstrap.dir}/classes"/>
714 <attribute name="bootclasspath.opt" default="${javac.bootclasspath.opt}"/>
715 <attribute name="classpath" default="${javac.classpath}"/>
716 <attribute name="sourcepath" default="${javac.sourcepath}"/>
717 <attribute name="java.home" default="${boot.java.home}"/>
718 <attribute name="source" default="${javac.source}"/>
719 <attribute name="target" default="${javac.target}"/>
720 <attribute name="release" default="${release}"/>
721 <attribute name="full.version" default="${full.version}"/>
722 <sequential>
723 <echo level="verbose" message="build-classes: excludes=@{excludes}"/>
724 <echo level="verbose" message="build-classes: bootclasspath.opt=@{bootclasspath.opt}"/>
725 <echo level="verbose" message="build-classes: classpath=@{classpath}"/>
726 <echo level="verbose" message="build-classes: sourcepath=@{sourcepath}"/>
727 <mkdir dir="@{gensrc.dir}"/>
728 <mkdir dir="@{classes.dir}"/>
729 <pcompile srcdir="${src.classes.dir}"
730 destdir="@{gensrc.dir}"
731 includes="@{includes}"/>
732 <copy todir="@{gensrc.dir}">
733 <fileset dir="${src.classes.dir}" includes="@{includes}"/>
734 <globmapper from="*.properties-template" to="*.properties"/>
735 <filterset begintoken="$(" endtoken=")">
736 <filter token="JDK_VERSION" value="${jdk.version}"/>
737 <filter token="RELEASE" value="@{release}"/>
738 <filter token="FULL_VERSION" value="@{full.version}"/>
739 </filterset>
740 </copy>
741 <pcompile srcdir="@{gensrc.dir}"
742 destdir="@{gensrc.dir}"
743 includes="**/*.properties"/>
744 <javac fork="true"
745 executable="@{java.home}/bin/javac"
746 srcdir="${src.classes.dir}:@{gensrc.dir}"
747 destdir="@{classes.dir}"
748 includes="@{includes}"
749 excludes="@{excludes}"
750 sourcepath="@{sourcepath}"
751 classpath="@{classpath}"
752 includeAntRuntime="no"
753 source="@{source}"
754 target="@{target}"
755 debug="${javac.debug}"
756 debuglevel="${javac.debuglevel}">
757 <compilerarg value="-implicit:none"/>
758 <compilerarg value="-Xprefer:source"/>
759 <compilerarg value="-J-Xbootclasspath/p:@{javac.bootclasspath}"/>
760 <compilerarg line="@{bootclasspath.opt}"/>
761 <compilerarg line="${javac.no.jdk.warnings}"/>
762 <compilerarg line="${javac.version.opt}"/>
763 <compilerarg line="${javac.lint.opts}"/>
764 </javac>
765 <copy todir="@{classes.dir}" includeemptydirs="false">
766 <fileset dir="${src.classes.dir}" includes="@{includes}" excludes="@{excludes}">
767 <exclude name="**/*.java"/>
768 <exclude name="**/*.properties"/>
769 <exclude name="**/*-template"/>
770 <exclude name="**/package.html"/>
771 </fileset>
772 </copy>
773 </sequential>
774 </macrodef>
775 </target>
777 <target name="-def-build-bootstrap-tool" depends="-check-boot.java.home,-def-build-tool">
778 <presetdef name="build-bootstrap-tool">
779 <build-tool
780 bin.dir="${build.bootstrap.dir}/bin"
781 java="${boot.java}"/>
782 </presetdef>
783 </target>
785 <target name="-def-build-bootstrap-jar" depends="-def-build-jar">
786 <presetdef name="build-bootstrap-jar">
787 <build-jar
788 classes.dir="${build.bootstrap.dir}/classes"
789 lib.dir="${build.bootstrap.dir}/lib"/>
790 </presetdef>
791 </target>
793 <target name="-def-build-bootstrap-classes" depends="-def-build-classes">
794 <presetdef name="build-bootstrap-classes">
795 <build-classes
796 source="${boot.javac.source}"
797 target="${boot.javac.target}"
798 gensrc.dir="${build.bootstrap.dir}/gensrc"
799 classes.dir="${build.bootstrap.dir}/classes"
800 javac.bootclasspath=""
801 bootclasspath.opt="-Xbootclasspath/p:${build.bootstrap.dir}/classes"
802 sourcepath=""
803 release="${bootstrap.release}"
804 full.version="${bootstrap.full.version}"
805 excludes="${bootstrap.exclude.files} **/package-info.java"/>
806 </presetdef>
807 </target>
809 <target name="-def-pcompile">
810 <mkdir dir="${build.toolclasses.dir}"/>
811 <javac fork="true"
812 source="${boot.javac.source}"
813 target="${boot.javac.target}"
814 executable="${boot.java.home}/bin/javac"
815 srcdir="${make.tools.dir}/CompileProperties"
816 destdir="${build.toolclasses.dir}/"
817 classpath="${ant.core.lib}"
818 includeantruntime="false"/>
819 <taskdef name="pcompile"
820 classname="CompilePropertiesTask"
821 classpath="${build.toolclasses.dir}/"/>
822 </target>
824 <target name="-def-genstubs" depends="build-bootstrap-javac" if="require.import.jdk.stubs">
825 <mkdir dir="${build.toolclasses.dir}"/>
826 <javac fork="true"
827 source="${boot.javac.source}"
828 target="${boot.javac.target}"
829 executable="${boot.java.home}/bin/javac"
830 srcdir="${make.tools.dir}/GenStubs"
831 destdir="${build.toolclasses.dir}/"
832 classpath="${build.bootstrap.dir}/classes:${ant.core.lib}"
833 includeantruntime="false"/>
834 <taskdef name="genstubs"
835 classname="GenStubs$$Ant"
836 classpath="${build.toolclasses.dir}/"/>
837 </target>
839 <target name="-def-javadoc-tool" depends="-check-target.java.home">
840 <macrodef name="javadoc-tool">
841 <attribute name="name"/>
842 <attribute name="includes"/>
843 <attribute name="options" default=""/>
844 <attribute name="source" default="1.5"/> <!-- FIXME -->
845 <sequential>
846 <property name="javadoc.options" value=""/> <!-- default, can be overridden per user or per project -->
847 <!-- Note: even with this default value, includes
848 from src.classes.dir get javadoc'd; see packageset below -->
849 <property name="javadoc.packagenames" value="none"/> <!-- default, can be overridden per user or per project -->
850 <javadoc
851 executable="${target.java.home}/bin/javadoc"
852 destdir="${build.javadoc.dir}/@{name}"
853 source="@{source}"
854 windowtitle="UNOFFICIAL"
855 failonerror="true"
856 use="true"
857 author="false"
858 version="false"
859 packagenames="${javadoc.packagenames}" >
860 <header><![CDATA[<strong>Unofficial Javadoc</strong> generated from developer sources for preview purposes only]]></header>
861 <arg line="@{options}"/>
862 <bootclasspath>
863 <path location="${build.classes.dir}"/>
864 <path location="${target.java.home}/jre/lib/rt.jar"/>
865 </bootclasspath>
866 <sourcepath>
867 <pathelement location="${src.classes.dir}"/>
868 </sourcepath>
869 <!-- XXX just <fileset> (restricted further to **/*.java) and no <packageset> -->
870 <!-- means that {@link some.package} will not work, which is no good. -->
871 <!-- (It correctly skips excluded single classes, but not if packageset is also included, -->
872 <!-- which also causes duplicates in the class index for included files.) -->
873 <packageset dir="${src.classes.dir}" includes="@{includes}">
874 <or>
875 <filename name="java/"/>
876 <filename name="javax/"/>
877 <filename name="com/sun/javadoc/"/>
878 <filename name="com/sun/mirror/"/>
879 <filename name="com/sun/source/"/>
880 </or>
881 </packageset>
882 </javadoc>
883 </sequential>
884 </macrodef>
885 </target>
887 <target name="-def-jtreg" unless="jtreg.defined" depends="-check-jtreg.home,-check-target.java.home">
888 <taskdef name="jtreg" classname="com.sun.javatest.regtest.Main$$Ant">
889 <classpath>
890 <pathelement location="${jtreg.home}/lib/jtreg.jar"/>
891 <pathelement location="${jtreg.home}/lib/javatest.jar"/>
892 </classpath>
893 </taskdef>
894 <macrodef name="jtreg-tool">
895 <attribute name="name"/>
896 <attribute name="tests"/>
897 <attribute name="jdk" default="${target.java.home}"/>
898 <attribute name="samevm" default="true"/>
899 <attribute name="verbose" default="${default.jtreg.verbose}"/>
900 <attribute name="options" default="${other.jtreg.options}"/>
901 <attribute name="keywords" default="-keywords:!ignore"/>
902 <attribute name="jpda.jvmargs" default=""/>
903 <sequential>
904 <property name="coverage.options" value=""/> <!-- default -->
905 <property name="coverage.classpath" value=""/> <!-- default -->
906 <property name="default.jtreg.verbose" value="summary"/> <!-- default -->
907 <property name="other.jtreg.options" value=""/> <!-- default -->
908 <jtreg
909 dir="${test.dir}"
910 workDir="${build.jtreg.dir}/@{name}/work"
911 reportDir="${build.jtreg.dir}/@{name}/report"
912 jdk="@{jdk}"
913 samevm="@{samevm}" verbose="@{verbose}"
914 failonerror="false" resultproperty="jtreg.@{name}.result"
915 javacoptions="-g"
916 vmoptions="${coverage.options} -Xbootclasspath/p:${coverage.classpath}:${build.classes.dir} @{jpda.jvmargs}">
917 <arg line="@{keywords}"/>
918 <arg line="@{options}"/>
919 <arg line="@{tests}"/>
920 </jtreg>
921 <!-- the next two properties are for convenience, when only
922 a single instance of jtreg will be invoked. -->
923 <condition property="jtreg.passed">
924 <equals arg1="${jtreg.@{name}.result}" arg2="0"/>
925 </condition>
926 <property name="jtreg.report" value="${build.jtreg.dir}/@{name}/report"/>
927 </sequential>
928 </macrodef>
929 <property name="jtreg.defined" value="true"/>
930 </target>
932 <target name="-def-cobertura" depends="-check-cobertura.home">
933 <path id="cobertura.classpath">
934 <fileset dir="${cobertura.home}">
935 <include name="cobertura.jar"/>
936 <include name="lib/**/*.jar"/>
937 </fileset>
938 </path>
939 <taskdef classpathref="cobertura.classpath" resource="tasks.properties"/>
940 </target>
942 <target name="-def-findbugs" unless="findbugs.defined"
943 depends="-check-findbugs.home,-check-target.java.home">
944 <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask">
945 <classpath>
946 <pathelement location="${findbugs.home}/lib/findbugs.jar"/>
947 </classpath>
948 </taskdef>
949 <macrodef name="findbugs-tool">
950 <attribute name="name"/>
951 <attribute name="output" default="emacs"/>
952 <attribute name="outputFile" default=""/>
953 <attribute name="reportLevel" default="high"/>
954 <sequential>
955 <findbugs
956 home="${findbugs.home}"
957 output="@{output}"
958 outputFile="@{outputFile}"
959 reportLevel="@{reportLevel}"
960 failOnError="false"
961 errorProperty="findbugs.@{name}.errors"
962 warningsProperty="findbugs.@{name}.warnings"
963 jvm="${target.java.home}/bin/java"
964 jvmargs="-Xmx512M" >
965 <class location="${dist.dir}/lib/@{name}.jar"/>
966 <auxClasspath>
967 <pathelement location="${build.classes.dir}"/>
968 </auxClasspath>
969 <sourcePath>
970 <pathelement location="${src.classes.dir}"/>
971 </sourcePath>
972 </findbugs>
973 </sequential>
974 </macrodef>
975 <property name="findbugs.defined" value="true"/>
976 </target>
978 <target name="-def-vizant" unless="vizant.defined" depends="-check-vizant">
979 <taskdef name="vizant" classname="net.sourceforge.vizant.Vizant" classpath="${vizant.jar}"/>
980 <property name="vizant.defined" value="true"/>
981 </target>
983 <target name="-def-check">
984 <macrodef name="check">
985 <attribute name="name"/>
986 <attribute name="property"/>
987 <attribute name="marker" default=""/>
988 <sequential>
989 <fail message="Cannot locate @{name}: please set @{property} to its location">
990 <condition>
991 <not>
992 <isset property="@{property}"/>
993 </not>
994 </condition>
995 </fail>
996 <fail message="@{name} is not installed in ${@{property}}">
997 <condition>
998 <and>
999 <not>
1000 <equals arg1="@{marker}" arg2=""/>
1001 </not>
1002 <not>
1003 <available file="${@{property}}/@{marker}"/>
1004 </not>
1005 </and>
1006 </condition>
1007 </fail>
1008 </sequential>
1009 </macrodef>
1010 </target>
1012 </project>