build.xml revision 2571:10fc81ac75b4
1<?xml version="1.0" encoding="UTF-8"?>
2<!--
3 Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
4 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5
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.
11
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).
17
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.
21
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-->
26
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.
32
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.
41
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.
52
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.
61
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
67
68 Internal details ...
69
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".
81
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
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 code
93      TOOL                      build the tool, run the tests, and run findbugs
94 - utility definitions
95 -->
96
97<project name="langtools" default="build" basedir="..">
98    <!--
99    **** Global property definitions.
100    -->
101
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>
108
109    <!-- The following locations can be used to override default property values. -->
110
111    <!-- Use this location for customizations specific to this instance of this workspace -->
112    <property file="build.properties"/>
113
114    <!-- Use this location for customizations common to all OpenJDK langtools workspaces -->
115    <property file="${user.home}/.openjdk/${ant.project.name}-build.properties"/>
116
117    <!-- Use this location for customizations common to all OpenJDK workspaces -->
118    <property file="${user.home}/.openjdk/build.properties"/>
119
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.checkstyle.dir" location="${dist.dir}/checkstyle"/>
135    <property name="dist.lib.dir" location="${dist.dir}/lib"/>
136    <property name="make.dir" location="make"/>
137    <property name="make.conf.dir" location="${make.dir}/conf"/>
138    <property name="make.tools.dir" location="${make.dir}/tools"/>
139    <property name="src.dir" location="src"/>
140    <property name="src.bin.dir" location="${src.dir}/share/bin"/>
141    <property name="test.dir" location="test"/>
142
143    <path id="src.dirs">
144      <pathelement path="${src.dir}/java.base/share/classes"/>
145      <pathelement path="${src.dir}/java.compiler/share/classes"/>
146      <pathelement path="${src.dir}/jdk.compiler/share/classes"/>
147      <pathelement path="${src.dir}/jdk.dev/share/classes"/>
148      <pathelement path="${src.dir}/jdk.javadoc/share/classes"/>
149    </path>
150
151    <pathconvert pathsep="," property="src.dirs.property" refid="src.dirs" />
152
153    <!-- java.marker is set to a marker file to check for within a Java install dir.
154         The best file to check for across Solaris/Linux/Windows/MacOS is one of the
155         executables; regrettably, that is OS-specific. -->
156    <condition property="java.marker" value="bin/java">
157        <os family="unix"/>
158    </condition>
159    <condition property="java.marker" value="bin/java.exe">
160        <os family="windows"/>
161    </condition>
162
163    <!-- Standard property values, if not overriden by earlier settings. -->
164    <property file="${make.dir}/build.properties"/>
165
166    <!-- launcher.java is used in the launcher scripts provided to run
167        the tools' jar files.  If it has not already been set, then
168        default it to use ${target.java.home}, if available, otherwise
169        quietly default to simply use "java". -->
170    <condition property="launcher.java"
171        value="${target.java.home}/bin/java" else="java">
172        <isset property="target.java.home"/>
173    </condition>
174
175    <!-- Logic for handling access import jdk classes, if available.
176        import.jdk should be unset, or set to jdk home (to use rt.jar)
177        or to jdk repo (to use src/share/classes).
178        Based on the value, if any, set up default values for javac's sourcepath,
179        classpath and bootclasspath. Note: the default values are overridden
180        in the build-bootstrap-classes macro. -->
181
182    <available property="import.jdk.src.dir" value="${import.jdk}/src/share/classes"
183        filepath="${import.jdk}/src/share/classes" file="java/nio/file/Path.java"/>
184    <available property="import.jdk.jar" value="${import.jdk}/jre/lib/rt.jar"
185        ignoresystemclasses="true"
186        classpath="${import.jdk}/jre/lib/rt.jar" classname="java.nio.file.Path"/>
187
188    <!-- Set the default bootclasspath option used for javac.
189        Note that different variants of the option are used, meaning we can't just
190        define the value for the option.
191        Note the explicit use of the standard property ${path.separator} in the following.
192        This is because Ant is not clever enough to handle direct use of : or ; -->
193    <condition property="javac.bootclasspath.opt"
194            value="-Xbootclasspath:${build.classes.dir}${path.separator}${import.jdk.jar}"
195            else="-Xbootclasspath/p:${build.classes.dir}">
196        <isset property="import.jdk.jar"/>
197    </condition>
198
199    <condition property="boot.java.provides.latest.jdk">
200        <available
201            ignoresystemclasses="true"
202            classpath="${boot.java.home}/jre/lib/rt.jar" classname="java.nio.file.Path"/>
203    </condition>
204
205    <condition property="bootstrap.exclude.files" value="" else="${require.latest.jdk.files}">
206        <isset property="boot.java.provides.latest.jdk"/>
207    </condition>
208
209    <condition property="exclude.files" value="" else="${require.latest.jdk.files}">
210        <or>
211            <isset property="boot.java.provides.latest.jdk"/>
212            <isset property="import.jdk"/>
213        </or>
214    </condition>
215
216    <condition property="require.import.jdk.stubs">
217        <and>
218            <not>
219                <isset property="boot.java.provides.latest.jdk"/>
220            </not>
221            <isset property="import.jdk.src.dir"/>
222        </and>
223    </condition>
224
225    <!-- Set the default value of the sourcepath used for javac. -->
226    <condition property="javac.sourcepath" value="${build.genstubs.dir}" else="">
227        <isset property="require.import.jdk.stubs"/>
228    </condition>
229
230    <!-- Set the default value of the classpath used for javac. -->
231    <property name="javac.classpath" value=""/>
232
233
234    <!--
235    **** General top level targets.
236    -->
237
238    <!-- Standard target to build deliverables for JDK build. -->
239
240    <target name="build" depends="build-bootstrap-tools,build-all-classes">
241        <copy todir="${dist.dir}/bootstrap">
242            <fileset dir="${build.bootstrap.dir}" includes="bin/,lib/"/>
243        </copy>
244        <chmod dir="${dist.dir}/bootstrap/bin" perm="ugo+rx">
245            <include name="*"/>
246        </chmod>
247        <mkdir dir="${dist.lib.dir}"/>
248        <jar file="${dist.lib.dir}/classes.jar" basedir="${build.classes.dir}"/>
249        <zip file="${dist.lib.dir}/src.zip">
250            <multirootfileset basedirs="${src.dirs.property}" />
251        </zip>
252    </target>
253
254    <target name="build-bootstrap-tools"
255        depends="build-bootstrap-javac,build-bootstrap-javadoc,build-bootstrap-doclets,build-bootstrap-javah,build-bootstrap-sjavac"
256    />
257
258    <target name="build-all-tools"
259        depends="build-javac,build-javadoc,build-doclets,build-javah,build-javap,build-sjavac"
260    />
261
262    <target name="build-all-classes" depends="build-bootstrap-javac,-create-import-jdk-stubs">
263        <build-classes includes="${javac.includes} ${javadoc.includes} ${doclets.includes} ${javah.includes} ${javap.includes} ${sjavac.includes}"/>
264    </target>
265
266    <!-- clean -->
267
268    <target name="clean" description="Delete all generated files">
269        <delete dir="${build.dir}"/>
270        <delete dir="${dist.dir}"/>
271    </target>
272
273    <!-- Additional targets for running tools on the build -->
274
275    <target name="jtreg" depends="build-all-tools,-def-jtreg">
276        <jtreg-tool name="all" tests="${jtreg.tests}"/>
277    </target>
278
279    <target name="checkstyle" depends="-def-checkstyle"
280        description="Generates reports for code convention violations.">
281        <mkdir dir="${dist.checkstyle.dir}"/>
282        <checkstyle config="${make.conf.dir}/checkstyle-langtools.xml"
283              failureProperty="checkstyle.failure"
284              failOnViolation="false">
285            <formatter type="xml" tofile="${dist.checkstyle.dir}/checkstyle_report.xml"/>
286            <fileset dir="src" includes="**/*.java, **/*.properties"/>
287        </checkstyle>
288        <!-- transform the output to a simple html -->
289        <xslt  in="${dist.checkstyle.dir}/checkstyle_report.xml"
290               out="${dist.checkstyle.dir}/checkstyle_report.html"
291               style="${checkstyle.home}/contrib/checkstyle-simple.xsl"/>
292        <!-- transform the output to a very simple emacs friendly text file -->
293        <xslt  in="${dist.checkstyle.dir}/checkstyle_report.xml"
294               out="${dist.checkstyle.dir}/checkstyle_report.tmp"
295               style="${make.conf.dir}/checkstyle-emacs.xsl"/>
296        <!-- beautify remove extra lines -->
297        <move file="${dist.checkstyle.dir}/checkstyle_report.tmp"
298             toFile="${dist.checkstyle.dir}/checkstyle_report.emacs.txt">
299            <filterchain>
300                <ignoreblank/>
301                <replaceregex byline="true" pattern="^File:" replace="${line.separator}File:"/>
302            </filterchain>
303        </move>
304    </target>
305    <!-- target can be invoked from an ide, the output of which can be used
306         to access and fix the errors directly.
307     -->
308    <target name="checkstyle-ide" depends="checkstyle">
309        <concat>
310            <fileset file="${dist.checkstyle.dir}/checkstyle_report.emacs.txt"/>
311        </concat>
312    </target>
313
314    <target name="findbugs" depends="-def-findbugs,build-all-tools">
315        <property name="findbugs.reportLevel" value="medium"/>
316        <mkdir dir="${dist.findbugs.dir}"/>
317        <findbugs
318            home="${findbugs.home}"
319            projectName="JDK langtools ${full.version}"
320            output="xml"
321            outputFile="${dist.findbugs.dir}/findbugs.xml"
322            reportLevel="${findbugs.reportLevel}"
323            failOnError="false"
324            errorProperty="findbugs.all.errors"
325            warningsProperty="findbugs.all.warnings"
326            jvm="${target.java.home}/bin/java"
327            jvmargs="-Xmx512M">
328            <class location="${build.classes.dir}"/>
329            <sourcePath>
330                <path refid="src.dirs"/>
331            </sourcePath>
332        </findbugs>
333        <exec executable="sh">
334            <arg value="${findbugs.home}/bin/convertXmlToText"/>
335            <arg value="-longBugCodes"/>
336            <arg value="-html:${findbugs.home}/src/xsl/fancy.xsl"/>
337            <arg value="${dist.findbugs.dir}/findbugs.xml"/>
338            <redirector output="${dist.findbugs.dir}/findbugs.html"/>
339        </exec>
340    </target>
341
342    <target name="coverage" depends="-def-cobertura,build-all-classes,instrument-classes,jtreg,coverage-report"/>
343
344    <target name="instrument-classes" depends="-def-cobertura">
345        <!-- only define the following property when we want coverage info -->
346        <path id="coverage.classpath">
347            <pathelement location="${build.coverage.dir}/classes"/>
348            <path refid="cobertura.classpath"/>
349        </path>
350        <property name="coverage.options" value="-Dnet.sourceforge.cobertura.datafile=${build.coverage.dir}/cobertura.ser"/>
351        <property name="coverage.classpath" refid="coverage.classpath"/>
352        <mkdir dir="${build.coverage.dir}/classes"/>
353        <delete file="${build.coverage.dir}/cobertura.ser"/>
354        <cobertura-instrument todir="${build.coverage.dir}/classes"
355            datafile="${build.coverage.dir}/cobertura.ser">
356            <fileset dir="${build.classes.dir}"
357               includes="**/*.class" excludes="**/resources/*.class"/>
358        </cobertura-instrument>
359    </target>
360
361    <target name="coverage-report" depends="-def-cobertura">
362        <mkdir dir="${dist.coverage.dir}"/>
363        <cobertura-report
364            destdir="${dist.coverage.dir}"
365            datafile="${build.coverage.dir}/cobertura.ser">
366            <fileset dir="${src.dir}/java.base/share/classes"/>
367            <fileset dir="${src.dir}/java.compiler/share/classes"/>
368            <fileset dir="${src.dir}/jdk.compiler/share/classes"/>
369            <fileset dir="${src.dir}/jdk.dev/share/classes"/>
370            <fileset dir="${src.dir}/jdk.javadoc/share/classes"/>
371        </cobertura-report>
372        <cobertura-report
373            format="xml"
374            destdir="${dist.coverage.dir}"
375            datafile="${build.coverage.dir}/cobertura.ser">
376            <fileset dir="${src.dir}/java.base/share/classes"/>
377            <fileset dir="${src.dir}/java.compiler/share/classes"/>
378            <fileset dir="${src.dir}/jdk.compiler/share/classes"/>
379            <fileset dir="${src.dir}/jdk.dev/share/classes"/>
380            <fileset dir="${src.dir}/jdk.javadoc/share/classes"/>
381        </cobertura-report>
382    </target>
383
384    <target name="diags-examples" depends="build-javac,build-javap">
385        <!-- can override the following on the command line if desired. -->
386        <property name="diags.examples.out" location="${build.dir}/diag-examples/diags-examples.html"/>
387        <mkdir dir="${build.dir}/diag-examples/classes"/>
388        <javac fork="true"
389            executable="${dist.bin.dir}/javac"
390            srcdir="test/tools/javac/diags"
391            destdir="${build.dir}/diag-examples/classes"
392            includes="ArgTypeCompilerFactory.java,Example.java,FileManager.java,HTMLWriter.java,RunExamples.java,DocCommentProcessor.java"
393            sourcepath=""
394            classpath="${dist.lib.dir}/javac.jar;${dist.lib.dir}/javap.jar"
395            includeAntRuntime="no"
396            debug="${javac.debug}"
397            debuglevel="${javac.debuglevel}">
398            <compilerarg line="${javac.lint.opts}"/>
399        </javac>
400        <java fork="true"
401            jvm="${target.java.home}/bin/java"
402            dir="test/tools/javac/diags"
403            classpath="${build.dir}/diag-examples/classes;${dist.lib.dir}/javac.jar;${dist.lib.dir}/javap.jar"
404            classname="RunExamples">
405            <jvmarg value="-Dtest.classes=${build.dir}/diag-examples/classes"/>
406            <arg value="-examples"/>
407            <arg value="examples"/>
408            <arg value="-o"/>
409            <arg file="${diags.examples.out}"/>
410            <arg value="-showFiles"/>
411            <arg value="-title"/>
412            <arg value="Examples of javac diagnostics"/>
413        </java>
414    </target>
415
416    <!-- a patching facility to speed up incorporating the langtools' classfiles
417         into a jdk of your choice. Either target.java.home or patch.jdk can be
418         set on the command line; setting target.java.home has the advantage of
419         patching the jdk used for jtreg and other tests.
420    -->
421    <target name="patch" depends="build-all-classes">
422        <condition property="patch.jdk" value="${target.java.home}">
423            <available file="${target.java.home}" type="dir"/>
424        </condition>
425        <fail message="patch.jdk or target.java.home is not set, please set target.java.home, or patch.jdk for an alternate jdk image to patch">
426            <condition>
427                <not>
428                    <isset property="patch.jdk"/>
429                </not>
430            </condition>
431        </fail>
432        <property name="patch.tools.jar" location="${patch.jdk}/lib/tools.jar"/>
433        <property name="patch.rt.jar" location="${patch.jdk}/jre/lib/rt.jar"/>
434        <fail message="patch.jdk or target.java.home must point to a valid jdk image: missing tools.jar">
435            <condition>
436                <not>
437                    <available file="${patch.tools.jar}" type="file"/>
438                </not>
439            </condition>
440        </fail>
441        <fail message="patch.jdk or target.java.home must point to a valid jdk image: missing rt.jar">
442            <condition>
443                <not>
444                    <available file="${patch.rt.jar}" type="file"/>
445                </not>
446            </condition>
447        </fail>
448        <zip zipfile="${patch.tools.jar}" update="true">
449            <zipfileset dir="${build.classes.dir}" includes="com/**"/>
450        </zip>
451        <zip zipfile="${patch.rt.jar}" update="true">
452            <zipfileset dir="${build.classes.dir}" includes="javax/**"/>
453        </zip>
454    </target>
455
456    <target name="doclint-api" depends="build-all-classes">
457        <delete dir="${build.dir}/doclint/classes"/>
458        <mkdir dir="${build.dir}/doclint/classes"/>
459        <javac fork="true"
460               executable="${boot.javac}"
461               destdir="${build.dir}/doclint/classes"
462               includes="javax/lang/model/** com/sun/javadoc/** com/sun/source/**"
463               excludes=""
464               sourcepath="${javac.sourcepath}"
465               classpath="${javac.classpath}"
466               includeAntRuntime="no"
467               source="${javac.source}"
468               target="${javac.target}"
469               debug="${javac.debug}"
470               debuglevel="${javac.debuglevel}">
471            <compilerarg value="-implicit:none"/>
472            <compilerarg value="-Xprefer:source"/>
473            <compilerarg value="-J-Xbootclasspath/p:${build.bootstrap.dir}/classes"/>
474            <compilerarg line="${javac.no.jdk.warnings}"/>
475            <compilerarg line="${javac.version.opt}"/>
476            <compilerarg line="-Xdoclint:all/protected,-missing"/>
477            <src>
478                <path refid="src.dirs"/>
479                <path location="${build.gensrc.dir}"/>
480            </src>
481        </javac>
482    </target>
483
484    <!-- Generate API docs for "important" test classes that are used by
485         multiple tests.
486    -->
487    <target name="test-framework-docs" depends="build-all-classes">
488        <javadoc executable="${target.java.home}/bin/javadoc"
489                destdir="${build.dir}/testframeworkdocs">
490            <!-- disable doclint for now; it might be good to enable -Xdoclint:missing -->
491            <arg value="-Xdoclint:none"/>
492            <!-- source files to be documented -->
493            <sourcefiles>
494                <fileset dir="${test.dir}">
495                    <include name="**/ToolBox.java"/>
496                    <include name="**/*Tester.java"/>
497                    <include name="**/*TestBase.java"/>
498                    <include name="**/*Testing*.java"/>
499                </fileset>
500            </sourcefiles>
501            <!-- source path used for documentation -->
502            <sourcepath>
503                <pathelement path="${test.dir}/lib"/>
504                <pathelement path="${test.dir}/lib/combo"/>
505                <pathelement path="${test.dir}/tools/javac/lib"/>
506                <pathelement path="${test.dir}/tools/javac/classfiles/attributes/LocalVariableTable"/>
507            </sourcepath>
508            <!-- exclude the following "packages" found by <javadoc>
509                on the sourcepath -->
510            <excludepackage name="combo.tools.javac.combo"/>
511            <excludepackage name="tools.javac.combo"/>
512            <!-- library classes used for documentation -->
513            <classpath>
514                <pathelement path="${jtreg.home}/lib/testng.jar"/>
515            </classpath>
516            <!-- platform classes used for documentation -->
517            <bootclasspath>
518                <pathelement path="${build.dir}/classes"/>
519                <pathelement path="${target.java.home}/jre/lib/rt.jar"/>
520            </bootclasspath>
521        </javadoc>
522    </target>
523
524    <!--
525    **** Debugging/diagnostic targets.
526    -->
527
528    <!-- standard JDK target -->
529    <target name="sanity"
530        description="display settings of configuration values">
531        <echo level="info">ant.home = ${ant.home}</echo>
532        <echo level="info">boot.java.home = ${boot.java.home}</echo>
533        <echo level="info">target.java.home = ${target.java.home}</echo>
534        <echo level="info">jtreg.home = ${jtreg.home}</echo>
535        <echo level="info">findbugs.home = ${findbugs.home}</echo>
536        <echo level="info">checkstyle.home = ${checkstyle.home}</echo>
537    </target>
538
539    <target name="post-sanity" depends="-def-jtreg,sanity,build"
540        description="perform basic validation after a standard build">
541        <jtreg
542            dir="make/test"
543            workDir="${build.jtreg.dir}/post-sanity/work"
544            reportDir="${build.jtreg.dir}/post-sanity/report"
545            jdk="${target.java.home}"
546            verbose="summary"
547            failonerror="false" resultproperty="jtreg.post-sanity.result">
548        </jtreg>
549    </target>
550
551    <!-- use vizant tool to generate graphical image of this Ant file.-->
552    <target name="vizant" depends="-def-vizant">
553        <mkdir dir="${build.dir}"/>
554        <echo message="Generating ${build.dir}/build.dot"/>
555        <vizant antfile="${make.dir}/build.xml" outfile="${build.dir}/build.dot"/>
556        <echo message="Generating ${build.dir}/build.png"/>
557        <exec executable="${dot}" >
558            <arg value="-Tpng"/>
559            <arg value="-o"/>
560            <arg file="${build.dir}/build.png"/>
561            <arg file="${build.dir}/build.dot"/>
562        </exec>
563    </target>
564
565    <target name="check-import.jdk">
566        <echo message="import.jdk: ${import.jdk}"/>
567        <echo message="import.jdk.jar: ${import.jdk.jar}"/>
568        <echo message="import.jdk.src.dir: ${import.jdk.src.dir}"/>
569    </target>
570
571    <target name="diagnostics">
572        <diagnostics/>
573    </target>
574
575
576    <!--
577    **** javac targets.
578    -->
579
580    <target name="build-bootstrap-javac"
581            depends="-def-build-bootstrap-classes,-def-build-bootstrap-jar,-def-build-bootstrap-tool">
582        <build-bootstrap-classes includes="${javac.includes}"/>
583        <build-bootstrap-jar     name="javac" includes="${javac.includes}"/>
584        <build-bootstrap-tool    name="javac"/>
585    </target>
586
587    <target name="build-classes-javac" depends="build-bootstrap-javac,-create-import-jdk-stubs">
588        <build-classes includes="${javac.includes}"/>
589    </target>
590
591    <target name="build-javac" depends="build-classes-javac">
592        <build-jar  name="javac" includes="${javac.includes}"/>
593        <build-tool name="javac"/>
594    </target>
595
596    <target name="javadoc-javac" depends="build-javac,-def-javadoc-tool">
597        <javadoc-tool name="javac" includes="${javac.includes}" options="${javadoc.jls.option}"/>
598    </target>
599
600    <target name="jtreg-javac" depends="build-javac,build-javap,-def-jtreg">
601        <jtreg-tool name="javac" tests="${javac.tests}"/>
602    </target>
603
604    <target name="findbugs-javac" depends="build-javac,-def-findbugs">
605        <findbugs-tool name="javac"/>
606    </target>
607
608    <target name="javac" depends="build-javac,jtreg-javac,findbugs-javac"/>
609
610
611    <!--
612    **** javadoc targets.
613    -->
614
615    <target name="build-bootstrap-javadoc" depends="build-bootstrap-javac">
616        <build-bootstrap-classes includes="${javadoc.includes}"/>
617        <build-bootstrap-jar     name="javadoc" includes="${javadoc.includes}"
618                                 jarclasspath="javac.jar doclets.jar"/>
619        <build-bootstrap-tool    name="javadoc"/>
620    </target>
621
622    <target name="build-classes-javadoc" depends="build-classes-javac">
623        <build-classes includes="${javadoc.includes}"/>
624    </target>
625
626    <target name="build-javadoc" depends="build-javac,build-classes-javadoc">
627        <build-jar  name="javadoc" includes="${javadoc.includes}"
628                    jarclasspath="javac.jar doclets.jar"/>
629        <build-tool name="javadoc"/>
630    </target>
631
632    <target name="javadoc-javadoc" depends="build-javadoc,-def-javadoc-tool">
633        <javadoc-tool name="javadoc" includes="${javadoc.includes}"/>
634    </target>
635
636    <target name="jtreg-javadoc" depends="build-javadoc,-def-jtreg">
637        <jtreg-tool name="javadoc" tests="${javadoc.tests}"/>
638    </target>
639
640    <target name="findbugs-javadoc" depends="build-javadoc,-def-findbugs">
641        <findbugs-tool name="javadoc"/>
642    </target>
643
644    <target name="javadoc" depends="build-javadoc,jtreg-javadoc,findbugs-javadoc"/>
645
646
647    <!--
648    **** doclets targets.
649    -->
650
651    <target name="build-bootstrap-doclets" depends="build-bootstrap-javadoc,-def-build-bootstrap-jar">
652        <build-bootstrap-classes includes="${doclets.includes}"/>
653        <build-bootstrap-jar     name="doclets" includes="${doclets.includes}"
654                                 jarmainclass="com.sun.tools.javadoc.Main"
655                                 jarclasspath="javadoc.jar"/>
656    </target>
657
658    <target name="build-classes-doclets" depends="build-classes-javadoc">
659        <build-classes includes="${doclets.includes}"/>
660    </target>
661
662    <target name="build-doclets" depends="build-javadoc,build-classes-doclets">
663        <!-- just jar, no bin for doclets -->
664        <build-jar name="doclets" includes="${doclets.includes}" jarclasspath="javadoc.jar"/>
665    </target>
666
667    <!-- (no javadoc for doclets) -->
668
669    <target name="jtreg-doclets" depends="build-doclets,-def-jtreg">
670        <jtreg-tool name="doclets" tests="${doclets.tests}"/>
671    </target>
672
673    <target name="findbugs-doclets" depends="build-doclets,-def-findbugs">
674        <findbugs-tool name="doclets"/>
675    </target>
676
677    <target name="doclets" depends="build-doclets,jtreg-doclets,findbugs-doclets"/>
678
679
680    <!--
681    **** javah targets.
682    -->
683
684    <target name="build-bootstrap-javah" depends="build-bootstrap-javadoc">
685        <build-bootstrap-classes includes="${javah.includes}"/>
686        <build-bootstrap-jar     name="javah" includes="${javah.includes}"
687                                 jarclasspath="javadoc.jar doclets.jar javac.jar"/>
688        <build-bootstrap-tool    name="javah"/>
689    </target>
690
691    <target name="build-javah" depends="build-javac,build-classes-javah">
692        <build-jar  name="javah" includes="${javah.includes}" jarclasspath="javac.jar"/>
693        <build-tool name="javah"/>
694    </target>
695
696    <target name="build-classes-javah" depends="build-classes-javadoc">
697        <build-classes includes="${javah.includes}"/>
698    </target>
699
700    <!-- (no javadoc for javah) -->
701
702    <target name="jtreg-javah" depends="build-javah,-def-jtreg">
703        <jtreg-tool name="javah" tests="${javah.tests}"/>
704    </target>
705
706    <target name="findbugs-javah" depends="build-javah,-def-findbugs">
707        <findbugs-tool name="javah"/>
708    </target>
709
710    <target name="javah" depends="build-javah,jtreg-javah,findbugs-javah"/>
711
712
713    <!--
714    **** javap targets.
715    -->
716
717    <target name="build-bootstrap-javap"
718            depends="-def-build-bootstrap-classes,-def-build-bootstrap-jar,-def-build-bootstrap-tool">
719        <build-bootstrap-classes includes="${javap.includes}"/>
720        <build-bootstrap-jar     name="javap" includes="${javap.includes}"
721                                 jarmainclass="sun.tools.javap.Main"/>
722        <build-bootstrap-tool    name="javap"/>
723    </target>
724
725    <target name="build-classes-javap" depends="build-classes-javac">
726        <build-classes includes="${javap.includes}"/>
727    </target>
728
729    <target name="build-javap" depends="build-javac,build-classes-javap">
730        <build-jar  name="javap" includes="${javap.includes}"
731                    jarmainclass="com.sun.tools.javap.Main"
732                    jarclasspath="javac.jar"/>
733        <build-tool name="javap"/>
734    </target>
735
736    <!-- (no javadoc for javap) -->
737
738    <target name="jtreg-javap" depends="build-javap,-def-jtreg">
739        <jtreg-tool name="javap" tests="${javap.tests}"/>
740    </target>
741
742    <target name="findbugs-javap" depends="build-javap,-def-findbugs">
743        <findbugs-tool name="javap"/>
744    </target>
745
746    <target name="javap" depends="build-javap,jtreg-javap,findbugs-javap"/>
747
748    <!--
749    **** sjavac targets.
750    -->
751
752    <target name="build-bootstrap-sjavac"
753            depends="-def-build-bootstrap-classes,-def-build-bootstrap-jar,-def-build-bootstrap-tool">
754        <build-bootstrap-classes includes="${sjavac.includes}"/>
755        <build-bootstrap-jar     name="sjavac" includes="${sjavac.includes}"
756                                 jarmainclass="com.sun.tools.sjavac.Main"/>
757        <build-bootstrap-tool    name="sjavac"/>
758    </target>
759
760    <target name="build-classes-sjavac" depends="build-classes-javac">
761        <build-classes includes="${sjavac.includes}"/>
762    </target>
763
764    <target name="build-sjavac" depends="build-classes-sjavac">
765        <build-jar  name="sjavac" includes="${sjavac.includes}"
766                    jarmainclass="com.sun.tools.sjavac.Main"
767                    jarclasspath="sjavac.jar"/>
768        <build-tool name="sjavac"/>
769    </target>
770
771    <!-- (no javadoc for javap) -->
772
773    <target name="jtreg-sjavac" depends="build-sjavac,-def-jtreg">
774        <jtreg-tool name="sjavac" tests="${sjavac.tests}"/>
775    </target>
776
777    <target name="findbugs-sjavac" depends="build-sjavac,-def-findbugs">
778        <findbugs-tool name="sjavac"/>
779    </target>
780
781    <target name="sjavac" depends="build-sjavac,jtreg-sjavac,findbugs-sjavac"/>
782
783    <!--
784    **** crules targets.
785    -->
786
787    <target name="build-crules"
788            depends="-def-compilecrules,-def-build-jar-with-services,build-bootstrap-javac,-create-import-jdk-stubs">
789        <compilecrules/>
790        <build-jar-with-services
791                    name="crules"
792                    includes="crules/* crules/resources/*"
793                    classes.dir="${build.toolclasses.dir}"
794                    lib.dir="${build.toolclasses.dir}"
795                    jarmainclass=""
796                    jarclasspath="crules.jar"
797                    service.type="com.sun.source.util.Plugin"
798                    service.provider="crules.CodingRulesAnalyzerPlugin"/>
799        <build-tool name="crules"/>
800    </target>
801
802    <target name="jtreg-crules" depends="build-javac,build-crules,-def-jtreg">
803        <jtreg-tool name="crules"
804                    tests="${crules.tests}"
805                    extra.jvmargs="-Xbootclasspath/a:${build.toolclasses.dir}/crules.jar" />
806    </target>
807
808    <target name="check-coding-rules" depends="build-bootstrap-javac,-create-import-jdk-stubs,build-crules">
809        <build-classes includes="${javac.includes}"
810            plugin.options="-J-Xbootclasspath/a:${build.toolclasses.dir}/crules.jar -Xplugin:coding_rules" />
811    </target>
812
813    <!--
814    **** Create import JDK stubs.
815    -->
816
817    <target name="-create-import-jdk-stubs" depends="-def-genstubs" if="require.import.jdk.stubs">
818        <mkdir dir="${build.genstubs.dir}"/>
819        <genstubs
820            srcdir="${import.jdk.src.dir}" destdir="${build.genstubs.dir}"
821            includes="${import.jdk.stub.files}"
822            fork="true" classpath="${build.toolclasses.dir}:${build.bootstrap.dir}/classes:${ant.core.lib}"
823        />
824    </target>
825
826    <!--
827    **** IDE support
828    -->
829
830    <target name="idea">
831        <mkdir dir=".idea"/>
832        <copy todir=".idea" >
833            <fileset dir="make/intellij" excludes="**/src/**"/>
834        </copy>
835        <condition property="jtreg.idea.home" value="${jtreg.home}" else = "[jtreg.home]">
836            <isset property="jtreg.home"/>
837        </condition>
838        <replace file=".idea/ant.xml" token="@@@" value="${jtreg.idea.home}"/>
839        <mkdir dir=".idea/classes"/>
840        <javac srcdir="make/intellij/src"
841               destdir=".idea/classes"/>
842    </target>
843
844    <!--
845    **** Check targets.
846    **** "-check-*" targets check that a required property is set, and set to a reasonable value.
847    **** A user friendly message is generated if not, and the build exits.
848    -->
849
850    <target name="-check-boot.java.home" depends="-def-check">
851        <check name="bootstrap java" property="boot.java.home" marker="${java.marker}"/>
852    </target>
853
854    <target name="-check-target.java.home" depends="-def-check">
855        <check name="target java" property="target.java.home" marker="${java.marker}"/>
856    </target>
857
858    <target name="-check-cobertura.home" depends="-def-check">
859        <check name="cobertura" property="cobertura.home" marker="cobertura.jar"/>
860    </target>
861
862    <target name="-check-findbugs.home" depends="-def-check">
863        <check name="findbugs" property="findbugs.home" marker="lib/findbugs.jar"/>
864    </target>
865
866    <target name="-check-checkstyle.home" depends="-def-check">
867        <check name="checkstyle" property="checkstyle.home" marker="${checkstyle.name.version}.jar"/>
868    </target>
869
870    <target name="-check-jtreg.home" depends="-def-check">
871        <check name="jtreg" property="jtreg.home" marker="lib/jtreg.jar"/>
872    </target>
873
874    <target name="-check-vizant" depends="-def-check">
875        <check name="vizant" property="vizant.jar"/>
876        <check name="dot" property="dot"/>
877    </target>
878
879
880    <!--
881    **** Targets for Ant macro and task definitions.
882    -->
883
884    <target name="-def-build-tool">
885        <macrodef name="build-tool">
886            <attribute name="name"/>
887            <attribute name="bin.dir" default="${dist.bin.dir}"/>
888            <attribute name="java" default="${launcher.java}"/>
889            <sequential>
890                <mkdir dir="@{bin.dir}"/>
891                <copy file="${make.dir}/launcher.sh-template" tofile="@{bin.dir}/@{name}">
892                    <filterset begintoken="#" endtoken="#">
893                        <filter token="PROGRAM" value="@{name}"/>
894                        <filter token="TARGET_JAVA" value="@{java}"/>
895                        <filter token="PS" value="${path.separator}"/>
896                    </filterset>
897                </copy>
898                <chmod file="@{bin.dir}/@{name}" perm="ugo+rx"/>
899            </sequential>
900        </macrodef>
901    </target>
902
903    <target name="-def-build-jar">
904        <macrodef name="build-jar">
905            <attribute name="name"/>
906            <attribute name="includes"/>
907            <attribute name="classes.dir" default="${build.classes.dir}"/>
908            <attribute name="lib.dir" default="${dist.lib.dir}"/>
909            <attribute name="jarmainclass" default="com.sun.tools.@{name}.Main"/>
910            <attribute name="jarclasspath" default=""/>
911            <sequential>
912                <mkdir dir="@{lib.dir}"/>
913                <jar destfile="@{lib.dir}/@{name}.jar"
914                     basedir="@{classes.dir}"
915                     includes="@{includes}">
916                    <manifest>
917                        <attribute name="Main-Class" value="@{jarmainclass}"/>
918                        <attribute name="Class-Path" value="@{jarclasspath}"/>
919                    </manifest>
920                </jar>
921            </sequential>
922        </macrodef>
923    </target>
924
925    <target name="-def-build-jar-with-services">
926        <macrodef name="build-jar-with-services">
927            <attribute name="name"/>
928            <attribute name="includes"/>
929            <attribute name="classes.dir" default="${build.classes.dir}"/>
930            <attribute name="lib.dir" default="${dist.lib.dir}"/>
931            <attribute name="jarmainclass" default="com.sun.tools.@{name}.Main"/>
932            <attribute name="jarclasspath" default=""/>
933            <attribute name="service.type" default=""/>
934            <attribute name="service.provider" default=""/>
935            <sequential>
936                <mkdir dir="${build.toolclasses.dir}"/>
937                <jar destfile="@{lib.dir}/@{name}.jar"
938                     basedir="@{classes.dir}"
939                     includes="@{includes}">
940                    <service type="@{service.type}" provider="@{service.provider}"/>
941                    <manifest>
942                        <attribute name="Main-Class" value="@{jarmainclass}"/>
943                        <attribute name="Class-Path" value="@{jarclasspath}"/>
944                    </manifest>
945                </jar>
946            </sequential>
947        </macrodef>
948    </target>
949
950    <target name="-def-build-classes" depends="-def-pcompile">
951        <macrodef name="build-classes">
952            <attribute name="includes"/>
953            <attribute name="excludes" default="${exclude.files} **/package-info.java"/>
954            <attribute name="classes.dir" default="${build.classes.dir}"/>
955            <attribute name="gensrc.dir" default="${build.gensrc.dir}"/>
956            <attribute name="javac.bootclasspath" default="${build.bootstrap.dir}/classes"/>
957            <attribute name="bootclasspath.opt" default="${javac.bootclasspath.opt}"/>
958            <attribute name="classpath" default="${javac.classpath}"/>
959            <attribute name="sourcepath" default="${javac.sourcepath}"/>
960            <attribute name="java.home" default="${boot.java.home}"/>
961            <attribute name="source" default="${javac.source}"/>
962            <attribute name="target" default="${javac.target}"/>
963            <attribute name="release" default="${release}"/>
964            <attribute name="full.version" default="${full.version}"/>
965            <attribute name="plugin.options" default=""/>
966            <sequential>
967                <echo level="verbose" message="build-classes: excludes=@{excludes}"/>
968                <echo level="verbose" message="build-classes: bootclasspath.opt=@{bootclasspath.opt}"/>
969                <echo level="verbose" message="build-classes: classpath=@{classpath}"/>
970                <echo level="verbose" message="build-classes: sourcepath=@{sourcepath}"/>
971                <mkdir dir="@{gensrc.dir}"/>
972                <mkdir dir="@{classes.dir}"/>
973                <pcompile destdir="@{gensrc.dir}"
974                          includes="@{includes}">
975                    <src>
976                        <path refid="src.dirs"/>
977                    </src>
978                </pcompile>
979                <copy todir="@{gensrc.dir}">
980                    <multirootfileset basedirs="${src.dirs.property}" includes="@{includes}" />
981                    <globmapper from="*.properties-template" to="*.properties"/>
982                    <filterset begintoken="$(" endtoken=")">
983                        <filter token="JDK_VERSION" value="${jdk.version}"/>
984                        <filter token="RELEASE" value="@{release}"/>
985                        <filter token="FULL_VERSION" value="@{full.version}"/>
986                    </filterset>
987                </copy>
988                <pcompile destdir="@{gensrc.dir}"
989                          includes="**/*.properties">
990                    <src>
991                        <pathelement location="@{gensrc.dir}"/>
992                    </src>
993                </pcompile>
994                <javac fork="true"
995                       executable="@{java.home}/bin/javac"
996                       destdir="@{classes.dir}"
997                       includes="@{includes}"
998                       excludes="@{excludes}"
999                       sourcepath="@{sourcepath}"
1000                       classpath="@{classpath}"
1001                       includeAntRuntime="no"
1002                       source="@{source}"
1003                       target="@{target}"
1004                       debug="${javac.debug}"
1005                       debuglevel="${javac.debuglevel}">
1006                    <compilerarg value="-implicit:none"/>
1007                    <compilerarg value="-Xprefer:source"/>
1008                    <compilerarg value="-J-Xbootclasspath/p:@{javac.bootclasspath}"/>
1009                    <compilerarg line="@{bootclasspath.opt}"/>
1010                    <compilerarg line="${javac.no.jdk.warnings}"/>
1011                    <compilerarg line="${javac.version.opt}"/>
1012                    <compilerarg line="${javac.lint.opts}"/>
1013                    <compilerarg line="@{plugin.options}"/>
1014                    <src>
1015                        <path refid="src.dirs"/>
1016                        <path location="@{gensrc.dir}"/>
1017                    </src>
1018                </javac>
1019                <copy todir="@{classes.dir}" includeemptydirs="false">
1020                    <multirootfileset basedirs="${src.dirs.property}" includes="@{includes}" excludes="@{excludes}">
1021                        <exclude name="**/*.java"/>
1022                        <exclude name="**/*.properties"/>
1023                        <exclude name="**/*-template"/>
1024                        <exclude name="**/*.rej"/>
1025                        <exclude name="**/*.orig"/>
1026                        <exclude name="**/overview.html"/>
1027                        <exclude name="**/package.html"/>
1028                    </multirootfileset>
1029                </copy>
1030            </sequential>
1031        </macrodef>
1032    </target>
1033
1034    <target name="-def-build-bootstrap-tool" depends="-check-boot.java.home,-def-build-tool">
1035        <presetdef name="build-bootstrap-tool">
1036            <build-tool
1037                bin.dir="${build.bootstrap.dir}/bin"
1038                java="${boot.java}"/>
1039        </presetdef>
1040    </target>
1041
1042    <target name="-def-build-bootstrap-jar" depends="-def-build-jar">
1043        <presetdef name="build-bootstrap-jar">
1044            <build-jar
1045                classes.dir="${build.bootstrap.dir}/classes"
1046                lib.dir="${build.bootstrap.dir}/lib"/>
1047        </presetdef>
1048    </target>
1049
1050    <target name="-def-build-bootstrap-classes" depends="-def-build-classes">
1051        <presetdef name="build-bootstrap-classes">
1052            <build-classes
1053                source="${boot.javac.source}"
1054                target="${boot.javac.target}"
1055                gensrc.dir="${build.bootstrap.dir}/gensrc"
1056                classes.dir="${build.bootstrap.dir}/classes"
1057                javac.bootclasspath=""
1058                bootclasspath.opt="-Xbootclasspath/p:${build.bootstrap.dir}/classes"
1059                sourcepath=""
1060                release="${bootstrap.release}"
1061                full.version="${bootstrap.full.version}"
1062                excludes="${bootstrap.exclude.files} **/package-info.java"/>
1063        </presetdef>
1064    </target>
1065
1066    <target name="-def-pcompile">
1067        <mkdir dir="${build.toolclasses.dir}"/>
1068        <javac fork="true"
1069               source="${boot.javac.source}"
1070               target="${boot.javac.target}"
1071               executable="${boot.java.home}/bin/javac"
1072               srcdir="${make.tools.dir}"
1073               includes="compileproperties/* anttasks/CompileProperties* anttasks/PathFileSet*"
1074               destdir="${build.toolclasses.dir}/"
1075               classpath="${ant.core.lib}"
1076               bootclasspath="${boot.java.home}/jre/lib/rt.jar"
1077               includeantruntime="false">
1078            <compilerarg line="${javac.lint.opts}"/>
1079        </javac>
1080        <taskdef name="pcompile"
1081                 classname="anttasks.CompilePropertiesTask"
1082                 classpath="${build.toolclasses.dir}/"/>
1083    </target>
1084
1085    <target name="-def-compilecrules">
1086        <macrodef name="compilecrules">
1087            <sequential>
1088                <mkdir dir="${build.toolclasses.dir}"/>
1089                <javac fork="true"
1090                       source="${boot.javac.source}"
1091                       target="${boot.javac.target}"
1092                       executable="${boot.java.home}/bin/javac"
1093                       srcdir="${make.tools.dir}"
1094                       includes="crules/*"
1095                       destdir="${build.toolclasses.dir}/"
1096                       classpath="${ant.core.lib}"
1097                       bootclasspath="${boot.java.home}/jre/lib/rt.jar"
1098                       includeantruntime="false">
1099                    <compilerarg value="-Xbootclasspath/p:${build.bootstrap.dir}/classes"/>
1100                    <compilerarg line="${javac.lint.opts}"/>
1101                </javac>
1102                <copy todir="${build.toolclasses.dir}/" includeemptydirs="false">
1103                    <fileset dir="${make.tools.dir}">
1104                        <include name="**/*.properties"/>
1105                    </fileset>
1106                </copy>
1107            </sequential>
1108        </macrodef>
1109    </target>
1110
1111    <target name="-def-genstubs" depends="build-bootstrap-javac" if="require.import.jdk.stubs">
1112        <mkdir dir="${build.toolclasses.dir}"/>
1113        <javac fork="true"
1114               source="${boot.javac.source}"
1115               target="${boot.javac.target}"
1116               executable="${boot.java.home}/bin/javac"
1117               srcdir="${make.tools.dir}"
1118               includes="genstubs/* anttasks/GenStubs*"
1119               destdir="${build.toolclasses.dir}/"
1120               classpath="${ant.core.lib}"
1121               includeantruntime="false">
1122            <compilerarg value="-Xbootclasspath/p:${build.bootstrap.dir}/classes"/>
1123            <compilerarg line="${javac.lint.opts}"/>
1124        </javac>
1125        <taskdef name="genstubs"
1126                 classname="anttasks.GenStubsTask"
1127                 classpath="${build.toolclasses.dir}/"/>
1128    </target>
1129
1130    <target name="-def-javadoc-tool" depends="-check-target.java.home">
1131        <macrodef name="javadoc-tool">
1132            <attribute name="name"/>
1133            <attribute name="includes"/>
1134            <attribute name="options" default=""/>
1135            <attribute name="source" default="${javac.source}"/>
1136            <sequential>
1137                <property name="javadoc.options" value=""/> <!-- default, can be overridden per user or per project -->
1138                <!-- Note: even with this default value, includes
1139                from source directories get javadoc'd; see packageset below -->
1140                <property name="javadoc.packagenames" value="none"/> <!-- default, can be overridden per user or per project -->
1141                <javadoc
1142                    executable="${target.java.home}/bin/javadoc"
1143                    destdir="${build.javadoc.dir}/@{name}"
1144                    source="@{source}"
1145                    windowtitle="UNOFFICIAL"
1146                    failonerror="true"
1147                    use="true"
1148                    author="false"
1149                    version="false"
1150                    packagenames="${javadoc.packagenames}" >
1151                    <header><![CDATA[<strong>Unofficial Javadoc</strong> generated from developer sources for preview purposes only]]></header>
1152                    <arg line="@{options}"/>
1153                    <arg value="-tag" />
1154                    <arg value="implNote:a:Implementation Note:"/>
1155                    <bootclasspath>
1156                        <path location="${build.classes.dir}"/>
1157                        <path location="${target.java.home}/jre/lib/rt.jar"/>
1158                    </bootclasspath>
1159                    <sourcepath>
1160                        <path refid="src.dirs"/>
1161                    </sourcepath>
1162                    <!-- XXX just <fileset> (restricted further to **/*.java) and no <packageset> -->
1163                    <!-- means that {@link some.package} will not work, which is no good. -->
1164                    <!-- (It correctly skips excluded single classes, but not if packageset is also included, -->
1165                    <!-- which also causes duplicates in the class index for included files.) -->
1166                    <packageset dir="${src.dir}/java.base/share/classes" includes="@{includes}">
1167                        <or>
1168                            <filename name="java/"/>
1169                            <filename name="javax/"/>
1170                            <filename name="com/sun/javadoc/"/>
1171                            <filename name="com/sun/source/"/>
1172                        </or>
1173                    </packageset>
1174                    <packageset dir="${src.dir}/java.compiler/share/classes" includes="@{includes}">
1175                        <or>
1176                            <filename name="java/"/>
1177                            <filename name="javax/"/>
1178                            <filename name="com/sun/javadoc/"/>
1179                            <filename name="com/sun/source/"/>
1180                        </or>
1181                    </packageset>
1182                    <packageset dir="${src.dir}/jdk.compiler/share/classes" includes="@{includes}">
1183                        <or>
1184                            <filename name="java/"/>
1185                            <filename name="javax/"/>
1186                            <filename name="com/sun/javadoc/"/>
1187                            <filename name="com/sun/source/"/>
1188                        </or>
1189                    </packageset>
1190                    <packageset dir="${src.dir}/jdk.dev/share/classes" includes="@{includes}">
1191                        <or>
1192                            <filename name="java/"/>
1193                            <filename name="javax/"/>
1194                            <filename name="com/sun/javadoc/"/>
1195                            <filename name="com/sun/source/"/>
1196                        </or>
1197                    </packageset>
1198                    <packageset dir="${src.dir}/jdk.javadoc/share/classes" includes="@{includes}">
1199                        <or>
1200                            <filename name="java/"/>
1201                            <filename name="javax/"/>
1202                            <filename name="com/sun/javadoc/"/>
1203                            <filename name="com/sun/source/"/>
1204                        </or>
1205                    </packageset>
1206                </javadoc>
1207            </sequential>
1208        </macrodef>
1209    </target>
1210
1211    <target name="-def-jtreg" unless="jtreg.defined" depends="-check-jtreg.home,-check-target.java.home">
1212        <taskdef name="jtreg" classname="com.sun.javatest.regtest.Main$$Ant">
1213            <classpath>
1214                <pathelement location="${jtreg.home}/lib/jtreg.jar"/>
1215                <pathelement location="${jtreg.home}/lib/javatest.jar"/>
1216            </classpath>
1217        </taskdef>
1218        <macrodef name="jtreg-tool">
1219            <attribute name="name"/>
1220            <attribute name="tests"/>
1221            <attribute name="jdk" default="${target.java.home}"/>
1222            <attribute name="samevm" default="true"/>
1223            <attribute name="verbose" default="${default.jtreg.verbose}"/>
1224            <attribute name="options" default="${other.jtreg.options}"/>
1225            <attribute name="keywords" default="-keywords:!ignore"/>
1226            <attribute name="jpda.jvmargs" default=""/>
1227            <attribute name="extra.jvmargs" default=""/>
1228            <sequential>
1229                <property name="coverage.options" value=""/>              <!-- default -->
1230                <property name="coverage.classpath" value=""/>            <!-- default -->
1231                <property name="default.jtreg.verbose" value="summary"/>  <!-- default -->
1232                <property name="other.jtreg.options" value=""/>           <!-- default -->
1233                <jtreg
1234                    dir="${test.dir}"
1235                    workDir="${build.jtreg.dir}/@{name}/work"
1236                    reportDir="${build.jtreg.dir}/@{name}/report"
1237                    jdk="@{jdk}"
1238                    samevm="@{samevm}" verbose="@{verbose}"
1239                    failonerror="false" resultproperty="jtreg.@{name}.result"
1240                    javacoptions="-g"
1241                    vmoptions="${coverage.options} -Xbootclasspath/p:${coverage.classpath}${path.separator}${build.classes.dir} @{jpda.jvmargs} @{extra.jvmargs}">
1242                    <arg line="@{keywords}"/>
1243                    <arg line="@{options}"/>
1244                    <arg line="@{tests}"/>
1245                </jtreg>
1246                <!-- the next two properties are for convenience, when only
1247                     a single instance of jtreg will be invoked. -->
1248                <condition property="jtreg.passed">
1249                    <equals arg1="${jtreg.@{name}.result}" arg2="0"/>
1250                </condition>
1251                <property name="jtreg.report" value="${build.jtreg.dir}/@{name}/report"/>
1252            </sequential>
1253        </macrodef>
1254        <property name="jtreg.defined" value="true"/>
1255    </target>
1256
1257    <target name="-def-cobertura" depends="-check-cobertura.home">
1258        <path id="cobertura.classpath">
1259            <fileset dir="${cobertura.home}">
1260                <include name="cobertura.jar"/>
1261                <include name="lib/**/*.jar"/>
1262            </fileset>
1263        </path>
1264        <taskdef classpathref="cobertura.classpath" resource="tasks.properties"/>
1265    </target>
1266
1267    <target name="-def-checkstyle" unless="checkstyle.defined"
1268        depends="-check-checkstyle.home">
1269        <taskdef resource="checkstyletask.properties">
1270            <classpath>
1271                <pathelement location="${checkstyle.home}/${checkstyle.name.version}-all.jar"/>
1272            </classpath>
1273        </taskdef>
1274        <property name="checkstyle.defined" value="true"/>
1275    </target>
1276
1277    <target name="-def-findbugs" unless="findbugs.defined"
1278        depends="-check-findbugs.home,-check-target.java.home">
1279        <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask">
1280            <classpath>
1281                <pathelement location="${findbugs.home}/lib/findbugs.jar"/>
1282            </classpath>
1283        </taskdef>
1284        <macrodef name="findbugs-tool">
1285            <attribute name="name"/>
1286            <attribute name="output" default="emacs"/>
1287            <attribute name="outputFile" default=""/>
1288            <attribute name="reportLevel" default="high"/>
1289            <sequential>
1290                <findbugs
1291                    home="${findbugs.home}"
1292                    output="@{output}"
1293                    outputFile="@{outputFile}"
1294                    reportLevel="@{reportLevel}"
1295                    failOnError="false"
1296                    errorProperty="findbugs.@{name}.errors"
1297                    warningsProperty="findbugs.@{name}.warnings"
1298                    jvm="${target.java.home}/bin/java"
1299                    jvmargs="-Xmx512M" >
1300                    <class location="${dist.dir}/lib/@{name}.jar"/>
1301                    <auxClasspath>
1302                        <pathelement location="${build.classes.dir}"/>
1303                    </auxClasspath>
1304                    <sourcePath>
1305                        <path refid="src.dirs"/>
1306                    </sourcePath>
1307                </findbugs>
1308            </sequential>
1309        </macrodef>
1310        <property name="findbugs.defined" value="true"/>
1311    </target>
1312
1313    <target name="-def-vizant" unless="vizant.defined" depends="-check-vizant">
1314        <taskdef name="vizant" classname="net.sourceforge.vizant.Vizant" classpath="${vizant.jar}"/>
1315        <property name="vizant.defined" value="true"/>
1316    </target>
1317
1318    <target name="-def-check">
1319        <macrodef name="check">
1320            <attribute name="name"/>
1321            <attribute name="property"/>
1322            <attribute name="marker" default=""/>
1323            <sequential>
1324                <fail message="Cannot locate @{name}: please set @{property} to its location">
1325                    <condition>
1326                        <not>
1327                            <isset property="@{property}"/>
1328                        </not>
1329                    </condition>
1330                </fail>
1331                <fail message="@{name} is not installed in ${@{property}}">
1332                    <condition>
1333                        <and>
1334                            <not>
1335                                <equals arg1="@{marker}" arg2=""/>
1336                            </not>
1337                            <not>
1338                                <available file="${@{property}}/@{marker}"/>
1339                            </not>
1340                        </and>
1341                    </condition>
1342                </fail>
1343            </sequential>
1344        </macrodef>
1345    </target>
1346
1347</project>
1348
1349