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