build.xml revision 2487:f935f27abaef
1231200Smm<?xml version="1.0" encoding="UTF-8"?>
2231200Smm<!--
3231200Smm Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
4231200Smm DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5231200Smm
6231200Smm This code is free software; you can redistribute it and/or modify it
7231200Smm under the terms of the GNU General Public License version 2 only, as
8231200Smm published by the Free Software Foundation.  Oracle designates this
9231200Smm particular file as subject to the "Classpath" exception as provided
10231200Smm by Oracle in the LICENSE file that accompanied this code.
11231200Smm
12231200Smm This code is distributed in the hope that it will be useful, but WITHOUT
13231200Smm ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14231200Smm FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15231200Smm version 2 for more details (a copy is included in the LICENSE file that
16231200Smm accompanied this code).
17231200Smm
18231200Smm You should have received a copy of the GNU General Public License version
19231200Smm 2 along with this work; if not, write to the Free Software Foundation,
20231200Smm Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21231200Smm
22231200Smm Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
23231200Smm or visit www.oracle.com if you need additional information or have any
24231200Smm questions.
25231200Smm-->
26231200Smm
27231200Smm<!--
28231200Smm This is the main build file for the complete langtools repository.
29231200Smm It is used when building JDK (in which case it is invoked from the
30231200Smm Makefile), and it can be used when working on the tools themselves,
31231200Smm in an IDE such as NetBeans.
32231200Smm
33231200Smm External dependencies are specified via properties. These can be given
34231200Smm on the command line, or by providing a local build.properties file.
35231200Smm (They can also be edited into make/build.properties, although that is not
36231200Smm recommended.)  At a minimum, boot.java.home must be set to the installed
37231200Smm location of the version of JDK used to build this repository. Additional
38231200Smm properties may be required, depending on the targets that are built.
39231200Smm For example, to run any of the jtreg tests you must set jtreg.home,
40231200Smm to run findbugs on the code you must set findbugs.home, and so on.
41231200Smm
42231200Smm For the most part, javac can be built using the previous version of JDK.
43231200Smm However, a small number of javac files require access to the latest JDK,
44231200Smm which may not yet have been compiled. To compile these files, you can do
45231200Smm one of the following:
46231200Smm - Set boot.java.home to a recent build of the latest version of JDK.
47231200Smm - Set import.jdk to either a recent build (containing jre/lib/rt.jar)
48231200Smm   or to jdk source repository.  In the latter case, stub files will
49231200Smm   automatically be generated and used for the required API, to avoid
50231200Smm   unnecessary compilation of the source repository.
51231200Smm If you do neither, the relevant files will not be built.
52231200Smm
53231200Smm The main build happens in two phases:
54231200Smm - First, javac and other tools as needed are built using ${boot.java.home}.
55231200Smm   (This implies a constraint on the source code that they can be compiled
56231200Smm   with the previous version of JDK.
57231200Smm - Second, all required classes are compiled with the latest javac, created
58231200Smm   in the previous step.
59231200Smm The first phase is called the bootstrap phase. All targets, properties and
60231200Smm tasks that are specific to that phase have "bootstrap" in their name.
61231200Smm
62231200Smm For more details on the JDK build, see
63231200Smm    http://blogs.sun.com/kto/entry/anatomy_of_the_jdk_build
64231200Smm    http://openjdk.java.net/groups/build/
65231200Smm For more details on the stub generator, see
66231200Smm    http://blogs.sun.com/jjg/entry/building_javac_for_jdk7
67231200Smm
68231200Smm Internal details ...
69231200Smm
70231200Smm Interim build products are created in the build/ directory.
71231200Smm Final build products are created in the dist/ directory.
72231200Smm When building JDK, the dist/directory will contain:
73231200Smm - A bootstrap compiler suitable for running with ${boot.java.home}
74231200Smm   suitable for compiling downstream parts of JDK
75231200Smm - Source files and class files for inclusion in the JDK being built
76231200Smm When building standalone, the dist/directory will contain:
77231200Smm - Separate jar files for each of the separate langtools components
78231200Smm - Simple scripts to invoke the tools by executing the corresponding
79231200Smm   jar files.
80231200Smm These jar files and scripts are "for developer use only".
81231200Smm
82231200Smm This file is organized into sections as follows:
83231200Smm - global property definitions
84231200Smm - general top level targets
85231200Smm - general diagnostic/debugging targets
86231200Smm - groups of targets for each tool: javac, javadoc, doclets, javah, javap
87231200Smm    Within each group, the following targets are provided, where applicable
88231200Smm      build-bootstrap-TOOL      build the bootstrap version of the tool
89231200Smm      build-classes-TOOL        build the classes for the tool
90231200Smm      build-TOOL                build the jar file and script for the tool
91231200Smm      jtreg-TOOL                build the tool and run the appropriate tests
92231200Smm      findbugs-TOOL             run findbugs on the tool's source code
93231200Smm      TOOL                      build the tool, run the tests, and run findbugs
94231200Smm - utility definitions
95231200Smm -->
96231200Smm
97231200Smm<project name="langtools" default="build" basedir="..">
98231200Smm    <!--
99231200Smm    **** Global property definitions.
100231200Smm    -->
101231200Smm
102231200Smm    <!-- Force full debuginfo for javac if the debug.classfiles
103231200Smm    property is set.  This must be BEFORE the include of
104231200Smm    build.properties because it sets javac.debuglevel.  -->
105231200Smm    <condition property="javac.debuglevel" value="source,lines,vars">
106231200Smm        <equals arg1="${debug.classfiles}" arg2="true"/>
107231200Smm    </condition>
108231200Smm
109231200Smm    <!-- The following locations can be used to override default property values. -->
110231200Smm
111231200Smm    <!-- Use this location for customizations specific to this instance of this workspace -->
112231200Smm    <property file="build.properties"/>
113231200Smm
114231200Smm    <!-- Use this location for customizations common to all OpenJDK langtools workspaces -->
115231200Smm    <property file="${user.home}/.openjdk/${ant.project.name}-build.properties"/>
116231200Smm
117231200Smm    <!-- Use this location for customizations common to all OpenJDK workspaces -->
118231200Smm    <property file="${user.home}/.openjdk/build.properties"/>
119231200Smm
120231200Smm    <!-- Convenient shorthands for standard locations within the workspace. -->
121231200Smm    <property name="build.dir" location="build"/>
122231200Smm    <property name="build.bootstrap.dir" location="${build.dir}/bootstrap"/>
123231200Smm    <property name="build.coverage.dir" location="${build.dir}/coverage"/>
124231200Smm    <property name="build.classes.dir" location="${build.dir}/classes"/>
125231200Smm    <property name="build.gensrc.dir" location="${build.dir}/gensrc"/>
126231200Smm    <property name="build.genstubs.dir" location="${build.dir}/genstubs"/>
127231200Smm    <property name="build.javadoc.dir" location="${build.dir}/javadoc"/>
128231200Smm    <property name="build.jtreg.dir" location="${build.dir}/jtreg"/>
129231200Smm    <property name="build.toolclasses.dir" location="${build.dir}/toolclasses"/>
130231200Smm    <property name="dist.dir" location="dist"/>
131231200Smm    <property name="dist.bin.dir" location="${dist.dir}/bin"/>
132231200Smm    <property name="dist.coverage.dir" location="${dist.dir}/coverage"/>
133231200Smm    <property name="dist.findbugs.dir" location="${dist.dir}/findbugs"/>
134231200Smm    <property name="dist.checkstyle.dir" location="${dist.dir}/checkstyle"/>
135231200Smm    <property name="dist.lib.dir" location="${dist.dir}/lib"/>
136231200Smm    <property name="make.dir" location="make"/>
137231200Smm    <property name="make.conf.dir" location="${make.dir}/conf"/>
138231200Smm    <property name="make.tools.dir" location="${make.dir}/tools"/>
139231200Smm    <property name="src.dir" location="src"/>
140231200Smm    <property name="src.bin.dir" location="${src.dir}/share/bin"/>
141231200Smm    <property name="src.classes.dir" location="${src.dir}/share/classes"/>
142231200Smm    <property name="test.dir" location="test"/>
143231200Smm
144231200Smm    <!-- java.marker is set to a marker file to check for within a Java install dir.
145231200Smm         The best file to check for across Solaris/Linux/Windows/MacOS is one of the
146231200Smm         executables; regrettably, that is OS-specific. -->
147231200Smm    <condition property="java.marker" value="bin/java">
148231200Smm        <os family="unix"/>
149231200Smm    </condition>
150231200Smm    <condition property="java.marker" value="bin/java.exe">
151231200Smm        <os family="windows"/>
152231200Smm    </condition>
153231200Smm
154231200Smm    <!-- Standard property values, if not overriden by earlier settings. -->
155231200Smm    <property file="${make.dir}/build.properties"/>
156231200Smm
157231200Smm    <!-- launcher.java is used in the launcher scripts provided to run
158231200Smm        the tools' jar files.  If it has not already been set, then
159231200Smm        default it to use ${target.java.home}, if available, otherwise
160231200Smm        quietly default to simply use "java". -->
161231200Smm    <condition property="launcher.java"
162231200Smm        value="${target.java.home}/bin/java" else="java">
163231200Smm        <isset property="target.java.home"/>
164231200Smm    </condition>
165231200Smm
166231200Smm    <!-- Logic for handling access import jdk classes, if available.
167231200Smm        import.jdk should be unset, or set to jdk home (to use rt.jar)
168231200Smm        or to jdk repo (to use src/share/classes).
169231200Smm        Based on the value, if any, set up default values for javac's sourcepath,
170231200Smm        classpath and bootclasspath. Note: the default values are overridden
171231200Smm        in the build-bootstrap-classes macro. -->
172231200Smm
173231200Smm    <available property="import.jdk.src.dir" value="${import.jdk}/src/share/classes"
174231200Smm        filepath="${import.jdk}/src/share/classes" file="java/nio/file/Path.java"/>
175231200Smm    <available property="import.jdk.jar" value="${import.jdk}/jre/lib/rt.jar"
176231200Smm        ignoresystemclasses="true"
177231200Smm        classpath="${import.jdk}/jre/lib/rt.jar" classname="java.nio.file.Path"/>
178231200Smm
179231200Smm    <!-- Set the default bootclasspath option used for javac.
180231200Smm        Note that different variants of the option are used, meaning we can't just
181231200Smm        define the value for the option.
182231200Smm        Note the explicit use of the standard property ${path.separator} in the following.
183231200Smm        This is because Ant is not clever enough to handle direct use of : or ; -->
184231200Smm    <condition property="javac.bootclasspath.opt"
185231200Smm            value="-Xbootclasspath:${build.classes.dir}${path.separator}${import.jdk.jar}"
186231200Smm            else="-Xbootclasspath/p:${build.classes.dir}">
187231200Smm        <isset property="import.jdk.jar"/>
188231200Smm    </condition>
189231200Smm
190231200Smm    <condition property="boot.java.provides.latest.jdk">
191231200Smm        <available
192231200Smm            ignoresystemclasses="true"
193231200Smm            classpath="${boot.java.home}/jre/lib/rt.jar" classname="java.nio.file.Path"/>
194231200Smm    </condition>
195231200Smm
196231200Smm    <condition property="bootstrap.exclude.files" value="" else="${require.latest.jdk.files}">
197231200Smm        <isset property="boot.java.provides.latest.jdk"/>
198231200Smm    </condition>
199231200Smm
200231200Smm    <condition property="exclude.files" value="" else="${require.latest.jdk.files}">
201231200Smm        <or>
202231200Smm            <isset property="boot.java.provides.latest.jdk"/>
203231200Smm            <isset property="import.jdk"/>
204231200Smm        </or>
205231200Smm    </condition>
206231200Smm
207231200Smm    <condition property="require.import.jdk.stubs">
208231200Smm        <and>
209231200Smm            <not>
210231200Smm                <isset property="boot.java.provides.latest.jdk"/>
211231200Smm            </not>
212231200Smm            <isset property="import.jdk.src.dir"/>
213231200Smm        </and>
214231200Smm    </condition>
215231200Smm
216231200Smm    <!-- Set the default value of the sourcepath used for javac. -->
217231200Smm    <condition property="javac.sourcepath" value="${build.genstubs.dir}" else="">
218231200Smm        <isset property="require.import.jdk.stubs"/>
219231200Smm    </condition>
220231200Smm
221231200Smm    <!-- Set the default value of the classpath used for javac. -->
222231200Smm    <property name="javac.classpath" value=""/>
223231200Smm
224231200Smm
225231200Smm    <!--
226231200Smm    **** General top level targets.
227231200Smm    -->
228231200Smm
229231200Smm    <!-- Standard target to build deliverables for JDK build. -->
230231200Smm
231231200Smm    <target name="build" depends="build-bootstrap-tools,build-all-classes">
232231200Smm        <copy todir="${dist.dir}/bootstrap">
233231200Smm            <fileset dir="${build.bootstrap.dir}" includes="bin/,lib/"/>
234231200Smm        </copy>
235231200Smm        <chmod dir="${dist.dir}/bootstrap/bin" perm="ugo+rx">
236231200Smm            <include name="*"/>
237231200Smm        </chmod>
238231200Smm        <mkdir dir="${dist.lib.dir}"/>
239231200Smm        <jar file="${dist.lib.dir}/classes.jar" basedir="${build.classes.dir}"/>
240231200Smm        <zip file="${dist.lib.dir}/src.zip" basedir="${src.classes.dir}"/>
241231200Smm    </target>
242231200Smm
243231200Smm    <target name="build-bootstrap-tools"
244231200Smm        depends="build-bootstrap-javac,build-bootstrap-javadoc,build-bootstrap-doclets,build-bootstrap-javah,build-bootstrap-sjavac"
245231200Smm    />
246231200Smm
247231200Smm    <target name="build-all-tools"
248231200Smm        depends="build-javac,build-javadoc,build-doclets,build-javah,build-javap,build-sjavac"
249231200Smm    />
250231200Smm
251231200Smm    <target name="build-all-classes" depends="build-bootstrap-javac,-create-import-jdk-stubs">
252231200Smm        <build-classes includes="${javac.includes} ${javadoc.includes} ${doclets.includes} ${javah.includes} ${javap.includes} ${sjavac.includes}"/>
253231200Smm    </target>
254231200Smm
255231200Smm    <!-- clean -->
256231200Smm
257231200Smm    <target name="clean" description="Delete all generated files">
258231200Smm        <delete dir="${build.dir}"/>
259231200Smm        <delete dir="${dist.dir}"/>
260231200Smm    </target>
261231200Smm
262231200Smm    <!-- Additional targets for running tools on the build -->
263231200Smm
264231200Smm    <target name="jtreg" depends="build-all-tools,-def-jtreg">
265231200Smm        <jtreg-tool name="all" tests="${jtreg.tests}"/>
266231200Smm    </target>
267231200Smm
268231200Smm    <target name="checkstyle" depends="-def-checkstyle"
269231200Smm        description="Generates reports for code convention violations.">
270231200Smm        <mkdir dir="${dist.checkstyle.dir}"/>
271231200Smm        <checkstyle config="${make.conf.dir}/checkstyle-langtools.xml"
272231200Smm              failureProperty="checkstyle.failure"
273231200Smm              failOnViolation="false">
274231200Smm            <formatter type="xml" tofile="${dist.checkstyle.dir}/checkstyle_report.xml"/>
275231200Smm            <fileset dir="src" includes="**/*.java, **/*.properties"/>
276231200Smm        </checkstyle>
277231200Smm        <!-- transform the output to a simple html -->
278231200Smm        <xslt  in="${dist.checkstyle.dir}/checkstyle_report.xml"
279231200Smm               out="${dist.checkstyle.dir}/checkstyle_report.html"
280231200Smm               style="${checkstyle.home}/contrib/checkstyle-simple.xsl"/>
281231200Smm        <!-- transform the output to a very simple emacs friendly text file -->
282231200Smm        <xslt  in="${dist.checkstyle.dir}/checkstyle_report.xml"
283231200Smm               out="${dist.checkstyle.dir}/checkstyle_report.tmp"
284231200Smm               style="${make.conf.dir}/checkstyle-emacs.xsl"/>
285231200Smm        <!-- beautify remove extra lines -->
286231200Smm        <move file="${dist.checkstyle.dir}/checkstyle_report.tmp"
287231200Smm             toFile="${dist.checkstyle.dir}/checkstyle_report.emacs.txt">
288231200Smm            <filterchain>
289231200Smm                <ignoreblank/>
290231200Smm                <replaceregex byline="true" pattern="^File:" replace="${line.separator}File:"/>
291231200Smm            </filterchain>
292231200Smm        </move>
293231200Smm    </target>
294231200Smm    <!-- target can be invoked from an ide, the output of which can be used
295231200Smm         to access and fix the errors directly.
296231200Smm     -->
297231200Smm    <target name="checkstyle-ide" depends="checkstyle">
298231200Smm        <concat>
299231200Smm            <fileset file="${dist.checkstyle.dir}/checkstyle_report.emacs.txt"/>
300231200Smm        </concat>
301231200Smm    </target>
302231200Smm
303231200Smm    <target name="findbugs" depends="-def-findbugs,build-all-tools">
304231200Smm        <property name="findbugs.reportLevel" value="medium"/>
305231200Smm        <mkdir dir="${dist.findbugs.dir}"/>
306231200Smm        <findbugs
307231200Smm            home="${findbugs.home}"
308231200Smm            projectName="JDK langtools ${full.version}"
309231200Smm            output="xml"
310231200Smm            outputFile="${dist.findbugs.dir}/findbugs.xml"
311231200Smm            reportLevel="${findbugs.reportLevel}"
312231200Smm            failOnError="false"
313231200Smm            errorProperty="findbugs.all.errors"
314231200Smm            warningsProperty="findbugs.all.warnings"
315231200Smm            jvm="${target.java.home}/bin/java"
316231200Smm            jvmargs="-Xmx512M">
317231200Smm            <class location="${build.classes.dir}"/>
318231200Smm            <sourcePath>
319231200Smm                <pathelement location="${src.classes.dir}"/>
320231200Smm            </sourcePath>
321231200Smm        </findbugs>
322231200Smm        <exec executable="sh">
323231200Smm            <arg value="${findbugs.home}/bin/convertXmlToText"/>
324231200Smm            <arg value="-longBugCodes"/>
325231200Smm            <arg value="-html:${findbugs.home}/src/xsl/fancy.xsl"/>
326231200Smm            <arg value="${dist.findbugs.dir}/findbugs.xml"/>
327231200Smm            <redirector output="${dist.findbugs.dir}/findbugs.html"/>
328231200Smm        </exec>
329231200Smm    </target>
330231200Smm
331231200Smm    <target name="coverage" depends="-def-cobertura,build-all-classes,instrument-classes,jtreg,coverage-report"/>
332231200Smm
333231200Smm    <target name="instrument-classes" depends="-def-cobertura">
334231200Smm        <!-- only define the following property when we want coverage info -->
335231200Smm        <path id="coverage.classpath">
336231200Smm            <pathelement location="${build.coverage.dir}/classes"/>
337231200Smm            <path refid="cobertura.classpath"/>
338231200Smm        </path>
339231200Smm        <property name="coverage.options" value="-Dnet.sourceforge.cobertura.datafile=${build.coverage.dir}/cobertura.ser"/>
340231200Smm        <property name="coverage.classpath" refid="coverage.classpath"/>
341231200Smm        <mkdir dir="${build.coverage.dir}/classes"/>
342231200Smm        <delete file="${build.coverage.dir}/cobertura.ser"/>
343231200Smm        <cobertura-instrument todir="${build.coverage.dir}/classes"
344231200Smm            datafile="${build.coverage.dir}/cobertura.ser">
345231200Smm            <fileset dir="${build.classes.dir}"
346231200Smm               includes="**/*.class" excludes="**/resources/*.class"/>
347231200Smm        </cobertura-instrument>
348231200Smm    </target>
349231200Smm
350231200Smm    <target name="coverage-report" depends="-def-cobertura">
351231200Smm        <mkdir dir="${dist.coverage.dir}"/>
352231200Smm        <cobertura-report
353231200Smm            srcdir="${src.classes.dir}"
354231200Smm            destdir="${dist.coverage.dir}"
355231200Smm            datafile="${build.coverage.dir}/cobertura.ser"/>
356231200Smm        <cobertura-report
357231200Smm            format="xml"
358231200Smm            srcdir="${src.classes.dir}"
359231200Smm            destdir="${dist.coverage.dir}"
360231200Smm            datafile="${build.coverage.dir}/cobertura.ser"/>
361231200Smm    </target>
362231200Smm
363231200Smm    <target name="diags-examples" depends="build-javac,build-javap">
364231200Smm        <!-- can override the following on the command line if desired. -->
365231200Smm        <property name="diags.examples.out" location="${build.dir}/diag-examples/diags-examples.html"/>
366231200Smm        <mkdir dir="${build.dir}/diag-examples/classes"/>
367231200Smm        <javac fork="true"
368231200Smm            executable="${dist.bin.dir}/javac"
369231200Smm            srcdir="test/tools/javac/diags"
370231200Smm            destdir="${build.dir}/diag-examples/classes"
371231200Smm            includes="ArgTypeCompilerFactory.java,Example.java,FileManager.java,HTMLWriter.java,RunExamples.java,DocCommentProcessor.java"
372231200Smm            sourcepath=""
373231200Smm            classpath="${dist.lib.dir}/javac.jar;${dist.lib.dir}/javap.jar"
374231200Smm            includeAntRuntime="no"
375231200Smm            debug="${javac.debug}"
376231200Smm            debuglevel="${javac.debuglevel}">
377231200Smm            <compilerarg line="${javac.lint.opts}"/>
378231200Smm        </javac>
379231200Smm        <java fork="true"
380231200Smm            jvm="${target.java.home}/bin/java"
381231200Smm            dir="test/tools/javac/diags"
382231200Smm            classpath="${build.dir}/diag-examples/classes;${dist.lib.dir}/javac.jar;${dist.lib.dir}/javap.jar"
383231200Smm            classname="RunExamples">
384231200Smm            <jvmarg value="-Dtest.classes=${build.dir}/diag-examples/classes"/>
385231200Smm            <arg value="-examples"/>
386231200Smm            <arg value="examples"/>
387231200Smm            <arg value="-o"/>
388231200Smm            <arg file="${diags.examples.out}"/>
389231200Smm            <arg value="-showFiles"/>
390231200Smm            <arg value="-title"/>
391231200Smm            <arg value="Examples of javac diagnostics"/>
392231200Smm        </java>
393231200Smm    </target>
394231200Smm
395231200Smm    <!-- a patching facility to speed up incorporating the langtools' classfiles
396231200Smm         into a jdk of your choice. Either target.java.home or patch.jdk can be
397231200Smm         set on the command line; setting target.java.home has the advantage of
398231200Smm         patching the jdk used for jtreg and other tests.
399231200Smm    -->
400231200Smm    <target name="patch" depends="build-all-classes">
401231200Smm        <condition property="patch.jdk" value="${target.java.home}">
402231200Smm            <available file="${target.java.home}" type="dir"/>
403231200Smm        </condition>
404231200Smm        <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">
405231200Smm            <condition>
406231200Smm                <not>
407231200Smm                    <isset property="patch.jdk"/>
408231200Smm                </not>
409231200Smm            </condition>
410231200Smm        </fail>
411231200Smm        <property name="patch.tools.jar" location="${patch.jdk}/lib/tools.jar"/>
412231200Smm        <property name="patch.rt.jar" location="${patch.jdk}/jre/lib/rt.jar"/>
413231200Smm        <fail message="patch.jdk or target.java.home must point to a valid jdk image: missing tools.jar">
414231200Smm            <condition>
415231200Smm                <not>
416231200Smm                    <available file="${patch.tools.jar}" type="file"/>
417231200Smm                </not>
418231200Smm            </condition>
419231200Smm        </fail>
420231200Smm        <fail message="patch.jdk or target.java.home must point to a valid jdk image: missing rt.jar">
421231200Smm            <condition>
422231200Smm                <not>
423231200Smm                    <available file="${patch.rt.jar}" type="file"/>
424231200Smm                </not>
425231200Smm            </condition>
426231200Smm        </fail>
427231200Smm        <zip zipfile="${patch.tools.jar}" update="true">
428231200Smm            <zipfileset dir="${build.classes.dir}" includes="com/**"/>
429231200Smm        </zip>
430231200Smm        <zip zipfile="${patch.rt.jar}" update="true">
431231200Smm            <zipfileset dir="${build.classes.dir}" includes="javax/**"/>
432231200Smm        </zip>
433231200Smm    </target>
434231200Smm
435231200Smm    <target name="doclint-api" depends="build-all-classes">
436231200Smm        <delete dir="${build.dir}/doclint/classes"/>
437231200Smm        <mkdir dir="${build.dir}/doclint/classes"/>
438231200Smm        <javac fork="true"
439231200Smm               executable="${boot.javac}"
440231200Smm               srcdir="${src.classes.dir}:${build.gensrc.dir}"
441231200Smm               destdir="${build.dir}/doclint/classes"
442231200Smm               includes="javax/lang/model/** com/sun/javadoc/** com/sun/source/**"
443231200Smm               excludes=""
444231200Smm               sourcepath="${javac.sourcepath}"
445231200Smm               classpath="${javac.classpath}"
446231200Smm               includeAntRuntime="no"
447231200Smm               source="${javac.source}"
448231200Smm               target="${javac.target}"
449231200Smm               debug="${javac.debug}"
450231200Smm               debuglevel="${javac.debuglevel}">
451231200Smm            <compilerarg value="-implicit:none"/>
452231200Smm            <compilerarg value="-Xprefer:source"/>
453231200Smm            <compilerarg value="-J-Xbootclasspath/p:${build.bootstrap.dir}/classes"/>
454231200Smm            <compilerarg line="${javac.no.jdk.warnings}"/>
455231200Smm            <compilerarg line="${javac.version.opt}"/>
456231200Smm            <compilerarg line="-Xdoclint:all/protected,-missing"/>
457231200Smm        </javac>
458231200Smm    </target>
459231200Smm
460231200Smm    <!--
461231200Smm    **** Debugging/diagnostic targets.
462231200Smm    -->
463231200Smm
464231200Smm    <!-- standard JDK target -->
465231200Smm    <target name="sanity"
466231200Smm        description="display settings of configuration values">
467231200Smm        <echo level="info">ant.home = ${ant.home}</echo>
468231200Smm        <echo level="info">boot.java.home = ${boot.java.home}</echo>
469231200Smm        <echo level="info">target.java.home = ${target.java.home}</echo>
470231200Smm        <echo level="info">jtreg.home = ${jtreg.home}</echo>
471231200Smm        <echo level="info">findbugs.home = ${findbugs.home}</echo>
472231200Smm        <echo level="info">checkstyle.home = ${checkstyle.home}</echo>
473231200Smm    </target>
474231200Smm
475231200Smm    <target name="post-sanity" depends="-def-jtreg,sanity,build"
476231200Smm        description="perform basic validation after a standard build">
477231200Smm        <jtreg
478231200Smm            dir="make/test"
479231200Smm            workDir="${build.jtreg.dir}/post-sanity/work"
480231200Smm            reportDir="${build.jtreg.dir}/post-sanity/report"
481231200Smm            jdk="${target.java.home}"
482231200Smm            verbose="summary"
483231200Smm            failonerror="false" resultproperty="jtreg.post-sanity.result">
484231200Smm        </jtreg>
485231200Smm    </target>
486231200Smm
487231200Smm    <!-- use vizant tool to generate graphical image of this Ant file.-->
488231200Smm    <target name="vizant" depends="-def-vizant">
489231200Smm        <mkdir dir="${build.dir}"/>
490231200Smm        <echo message="Generating ${build.dir}/build.dot"/>
491231200Smm        <vizant antfile="${make.dir}/build.xml" outfile="${build.dir}/build.dot"/>
492231200Smm        <echo message="Generating ${build.dir}/build.png"/>
493231200Smm        <exec executable="${dot}" >
494231200Smm            <arg value="-Tpng"/>
495231200Smm            <arg value="-o"/>
496231200Smm            <arg file="${build.dir}/build.png"/>
497231200Smm            <arg file="${build.dir}/build.dot"/>
498231200Smm        </exec>
499231200Smm    </target>
500231200Smm
501231200Smm    <target name="check-import.jdk">
502231200Smm        <echo message="import.jdk: ${import.jdk}"/>
503231200Smm        <echo message="import.jdk.jar: ${import.jdk.jar}"/>
504231200Smm        <echo message="import.jdk.src.dir: ${import.jdk.src.dir}"/>
505231200Smm    </target>
506231200Smm
507231200Smm    <target name="diagnostics">
508231200Smm        <diagnostics/>
509231200Smm    </target>
510231200Smm
511231200Smm
512231200Smm    <!--
513    **** javac targets.
514    -->
515
516    <target name="build-bootstrap-javac"
517            depends="-def-build-bootstrap-classes,-def-build-bootstrap-jar,-def-build-bootstrap-tool">
518        <build-bootstrap-classes includes="${javac.includes}"/>
519        <build-bootstrap-jar     name="javac" includes="${javac.includes}"/>
520        <build-bootstrap-tool    name="javac"/>
521    </target>
522
523    <target name="build-classes-javac" depends="build-bootstrap-javac,-create-import-jdk-stubs">
524        <build-classes includes="${javac.includes}"/>
525    </target>
526
527    <target name="build-javac" depends="build-classes-javac">
528        <build-jar  name="javac" includes="${javac.includes}"/>
529        <build-tool name="javac"/>
530    </target>
531
532    <target name="javadoc-javac" depends="build-javac,-def-javadoc-tool">
533        <javadoc-tool name="javac" includes="${javac.includes}" options="${javadoc.jls.option}"/>
534    </target>
535
536    <target name="jtreg-javac" depends="build-javac,build-javap,-def-jtreg">
537        <jtreg-tool name="javac" tests="${javac.tests}"/>
538    </target>
539
540    <target name="findbugs-javac" depends="build-javac,-def-findbugs">
541        <findbugs-tool name="javac"/>
542    </target>
543
544    <target name="javac" depends="build-javac,jtreg-javac,findbugs-javac"/>
545
546
547    <!--
548    **** javadoc targets.
549    -->
550
551    <target name="build-bootstrap-javadoc" depends="build-bootstrap-javac">
552        <build-bootstrap-classes includes="${javadoc.includes}"/>
553        <build-bootstrap-jar     name="javadoc" includes="${javadoc.includes}"
554                                 jarclasspath="javac.jar doclets.jar"/>
555        <build-bootstrap-tool    name="javadoc"/>
556    </target>
557
558    <target name="build-classes-javadoc" depends="build-classes-javac">
559        <build-classes includes="${javadoc.includes}"/>
560    </target>
561
562    <target name="build-javadoc" depends="build-javac,build-classes-javadoc">
563        <build-jar  name="javadoc" includes="${javadoc.includes}"
564                    jarclasspath="javac.jar doclets.jar"/>
565        <build-tool name="javadoc"/>
566    </target>
567
568    <target name="javadoc-javadoc" depends="build-javadoc,-def-javadoc-tool">
569        <javadoc-tool name="javadoc" includes="${javadoc.includes}"/>
570    </target>
571
572    <target name="jtreg-javadoc" depends="build-javadoc,-def-jtreg">
573        <jtreg-tool name="javadoc" tests="${javadoc.tests}"/>
574    </target>
575
576    <target name="findbugs-javadoc" depends="build-javadoc,-def-findbugs">
577        <findbugs-tool name="javadoc"/>
578    </target>
579
580    <target name="javadoc" depends="build-javadoc,jtreg-javadoc,findbugs-javadoc"/>
581
582
583    <!--
584    **** doclets targets.
585    -->
586
587    <target name="build-bootstrap-doclets" depends="build-bootstrap-javadoc,-def-build-bootstrap-jar">
588        <build-bootstrap-classes includes="${doclets.includes}"/>
589        <build-bootstrap-jar     name="doclets" includes="${doclets.includes}"
590                                 jarmainclass="com.sun.tools.javadoc.Main"
591                                 jarclasspath="javadoc.jar"/>
592    </target>
593
594    <target name="build-classes-doclets" depends="build-classes-javadoc">
595        <build-classes includes="${doclets.includes}"/>
596    </target>
597
598    <target name="build-doclets" depends="build-javadoc,build-classes-doclets">
599        <!-- just jar, no bin for doclets -->
600        <build-jar name="doclets" includes="${doclets.includes}" jarclasspath="javadoc.jar"/>
601    </target>
602
603    <!-- (no javadoc for doclets) -->
604
605    <target name="jtreg-doclets" depends="build-doclets,-def-jtreg">
606        <jtreg-tool name="doclets" tests="${doclets.tests}"/>
607    </target>
608
609    <target name="findbugs-doclets" depends="build-doclets,-def-findbugs">
610        <findbugs-tool name="doclets"/>
611    </target>
612
613    <target name="doclets" depends="build-doclets,jtreg-doclets,findbugs-doclets"/>
614
615
616    <!--
617    **** javah targets.
618    -->
619
620    <target name="build-bootstrap-javah" depends="build-bootstrap-javadoc">
621        <build-bootstrap-classes includes="${javah.includes}"/>
622        <build-bootstrap-jar     name="javah" includes="${javah.includes}"
623                                 jarclasspath="javadoc.jar doclets.jar javac.jar"/>
624        <build-bootstrap-tool    name="javah"/>
625    </target>
626
627    <target name="build-javah" depends="build-javac,build-classes-javah">
628        <build-jar  name="javah" includes="${javah.includes}" jarclasspath="javac.jar"/>
629        <build-tool name="javah"/>
630    </target>
631
632    <target name="build-classes-javah" depends="build-classes-javadoc">
633        <build-classes includes="${javah.includes}"/>
634    </target>
635
636    <!-- (no javadoc for javah) -->
637
638    <target name="jtreg-javah" depends="build-javah,-def-jtreg">
639        <jtreg-tool name="javah" tests="${javah.tests}"/>
640    </target>
641
642    <target name="findbugs-javah" depends="build-javah,-def-findbugs">
643        <findbugs-tool name="javah"/>
644    </target>
645
646    <target name="javah" depends="build-javah,jtreg-javah,findbugs-javah"/>
647
648
649    <!--
650    **** javap targets.
651    -->
652
653    <target name="build-bootstrap-javap"
654            depends="-def-build-bootstrap-classes,-def-build-bootstrap-jar,-def-build-bootstrap-tool">
655        <build-bootstrap-classes includes="${javap.includes}"/>
656        <build-bootstrap-jar     name="javap" includes="${javap.includes}"
657                                 jarmainclass="sun.tools.javap.Main"/>
658        <build-bootstrap-tool    name="javap"/>
659    </target>
660
661    <target name="build-classes-javap" depends="build-classes-javac">
662        <build-classes includes="${javap.includes}"/>
663    </target>
664
665    <target name="build-javap" depends="build-javac,build-classes-javap">
666        <build-jar  name="javap" includes="${javap.includes}"
667                    jarmainclass="com.sun.tools.javap.Main"
668                    jarclasspath="javac.jar"/>
669        <build-tool name="javap"/>
670    </target>
671
672    <!-- (no javadoc for javap) -->
673
674    <target name="jtreg-javap" depends="build-javap,-def-jtreg">
675        <jtreg-tool name="javap" tests="${javap.tests}"/>
676    </target>
677
678    <target name="findbugs-javap" depends="build-javap,-def-findbugs">
679        <findbugs-tool name="javap"/>
680    </target>
681
682    <target name="javap" depends="build-javap,jtreg-javap,findbugs-javap"/>
683
684    <!--
685    **** sjavac targets.
686    -->
687
688    <target name="build-bootstrap-sjavac"
689            depends="-def-build-bootstrap-classes,-def-build-bootstrap-jar,-def-build-bootstrap-tool">
690        <build-bootstrap-classes includes="${sjavac.includes}"/>
691        <build-bootstrap-jar     name="sjavac" includes="${sjavac.includes}"
692                                 jarmainclass="com.sun.tools.sjavac.Main"/>
693        <build-bootstrap-tool    name="sjavac"/>
694    </target>
695
696    <target name="build-classes-sjavac" depends="build-classes-javac">
697        <build-classes includes="${sjavac.includes}"/>
698    </target>
699
700    <target name="build-sjavac" depends="build-classes-sjavac">
701        <build-jar  name="sjavac" includes="${sjavac.includes}"
702                    jarmainclass="com.sun.tools.sjavac.Main"
703                    jarclasspath="sjavac.jar"/>
704        <build-tool name="sjavac"/>
705    </target>
706
707    <!-- (no javadoc for javap) -->
708
709    <target name="jtreg-sjavac" depends="build-sjavac,-def-jtreg">
710        <jtreg-tool name="sjavac" tests="${sjavac.tests}"/>
711    </target>
712
713    <target name="findbugs-sjavac" depends="build-sjavac,-def-findbugs">
714        <findbugs-tool name="sjavac"/>
715    </target>
716
717    <target name="sjavac" depends="build-sjavac,jtreg-sjavac,findbugs-sjavac"/>
718
719    <!--
720    **** crules targets.
721    -->
722
723    <target name="build-crules" depends="-def-compilecrules,-def-build-jar-with-services">
724        <compilecrules/>
725        <build-jar-with-services
726                    name="crules"
727                    includes="crules/* crules/resources/*"
728                    classes.dir="${build.toolclasses.dir}"
729                    lib.dir="${build.toolclasses.dir}"
730                    jarmainclass=""
731                    jarclasspath="crules.jar"
732                    service.type="com.sun.source.util.Plugin"
733                    service.provider="crules.MutableFieldsAnalyzer"/>
734        <build-tool name="crules"/>
735    </target>
736
737    <target name="check-coding-rules" depends="build-bootstrap-javac,-create-import-jdk-stubs,build-crules">
738        <build-classes includes="${javac.includes}"
739            plugin.options="-J-Xbootclasspath/a:${build.toolclasses.dir}/crules.jar -Xplugin:mutable_fields_analyzer" />
740    </target>
741
742    <!--
743    **** Create import JDK stubs.
744    -->
745
746    <target name="-create-import-jdk-stubs" depends="-def-genstubs" if="require.import.jdk.stubs">
747        <mkdir dir="${build.genstubs.dir}"/>
748        <genstubs
749            srcdir="${import.jdk.src.dir}" destdir="${build.genstubs.dir}"
750            includes="${import.jdk.stub.files}"
751            fork="true" classpath="${build.toolclasses.dir}:${build.bootstrap.dir}/classes:${ant.core.lib}"
752        />
753    </target>
754
755    <!--
756    **** IDE support
757    -->
758
759    <target name="idea">
760        <mkdir dir=".idea"/>
761        <copy todir=".idea" >
762            <fileset dir="make/intellij" includes="**"/>
763        </copy>
764    </target>
765
766    <!--
767    **** Check targets.
768    **** "-check-*" targets check that a required property is set, and set to a reasonable value.
769    **** A user friendly message is generated if not, and the build exits.
770    -->
771
772    <target name="-check-boot.java.home" depends="-def-check">
773        <check name="bootstrap java" property="boot.java.home" marker="${java.marker}"/>
774    </target>
775
776    <target name="-check-target.java.home" depends="-def-check">
777        <check name="target java" property="target.java.home" marker="${java.marker}"/>
778    </target>
779
780    <target name="-check-cobertura.home" depends="-def-check">
781        <check name="cobertura" property="cobertura.home" marker="cobertura.jar"/>
782    </target>
783
784    <target name="-check-findbugs.home" depends="-def-check">
785        <check name="findbugs" property="findbugs.home" marker="lib/findbugs.jar"/>
786    </target>
787
788    <target name="-check-checkstyle.home" depends="-def-check">
789        <check name="checkstyle" property="checkstyle.home" marker="${checkstyle.name.version}.jar"/>
790    </target>
791
792    <target name="-check-jtreg.home" depends="-def-check">
793        <check name="jtreg" property="jtreg.home" marker="lib/jtreg.jar"/>
794    </target>
795
796    <target name="-check-vizant" depends="-def-check">
797        <check name="vizant" property="vizant.jar"/>
798        <check name="dot" property="dot"/>
799    </target>
800
801
802    <!--
803    **** Targets for Ant macro and task definitions.
804    -->
805
806    <target name="-def-build-tool">
807        <macrodef name="build-tool">
808            <attribute name="name"/>
809            <attribute name="bin.dir" default="${dist.bin.dir}"/>
810            <attribute name="java" default="${launcher.java}"/>
811            <sequential>
812                <mkdir dir="@{bin.dir}"/>
813                <copy file="${src.bin.dir}/launcher.sh-template" tofile="@{bin.dir}/@{name}">
814                    <filterset begintoken="#" endtoken="#">
815                        <filter token="PROGRAM" value="@{name}"/>
816                        <filter token="TARGET_JAVA" value="@{java}"/>
817                        <filter token="PS" value="${path.separator}"/>
818                    </filterset>
819                </copy>
820                <chmod file="@{bin.dir}/@{name}" perm="ugo+rx"/>
821            </sequential>
822        </macrodef>
823    </target>
824
825    <target name="-def-build-jar">
826        <macrodef name="build-jar">
827            <attribute name="name"/>
828            <attribute name="includes"/>
829            <attribute name="classes.dir" default="${build.classes.dir}"/>
830            <attribute name="lib.dir" default="${dist.lib.dir}"/>
831            <attribute name="jarmainclass" default="com.sun.tools.@{name}.Main"/>
832            <attribute name="jarclasspath" default=""/>
833            <sequential>
834                <mkdir dir="@{lib.dir}"/>
835                <jar destfile="@{lib.dir}/@{name}.jar"
836                     basedir="@{classes.dir}"
837                     includes="@{includes}">
838                    <manifest>
839                        <attribute name="Main-Class" value="@{jarmainclass}"/>
840                        <attribute name="Class-Path" value="@{jarclasspath}"/>
841                    </manifest>
842                </jar>
843            </sequential>
844        </macrodef>
845    </target>
846
847    <target name="-def-build-jar-with-services">
848        <macrodef name="build-jar-with-services">
849            <attribute name="name"/>
850            <attribute name="includes"/>
851            <attribute name="classes.dir" default="${build.classes.dir}"/>
852            <attribute name="lib.dir" default="${dist.lib.dir}"/>
853            <attribute name="jarmainclass" default="com.sun.tools.@{name}.Main"/>
854            <attribute name="jarclasspath" default=""/>
855            <attribute name="service.type" default=""/>
856            <attribute name="service.provider" default=""/>
857            <sequential>
858                <mkdir dir="${build.toolclasses.dir}"/>
859                <jar destfile="@{lib.dir}/@{name}.jar"
860                     basedir="@{classes.dir}"
861                     includes="@{includes}">
862                    <service type="@{service.type}" provider="@{service.provider}"/>
863                    <manifest>
864                        <attribute name="Main-Class" value="@{jarmainclass}"/>
865                        <attribute name="Class-Path" value="@{jarclasspath}"/>
866                    </manifest>
867                </jar>
868            </sequential>
869        </macrodef>
870    </target>
871
872    <target name="-def-build-classes" depends="-def-pcompile">
873        <macrodef name="build-classes">
874            <attribute name="includes"/>
875            <attribute name="excludes" default="${exclude.files} **/package-info.java"/>
876            <attribute name="classes.dir" default="${build.classes.dir}"/>
877            <attribute name="gensrc.dir" default="${build.gensrc.dir}"/>
878            <attribute name="javac.bootclasspath" default="${build.bootstrap.dir}/classes"/>
879            <attribute name="bootclasspath.opt" default="${javac.bootclasspath.opt}"/>
880            <attribute name="classpath" default="${javac.classpath}"/>
881            <attribute name="sourcepath" default="${javac.sourcepath}"/>
882            <attribute name="java.home" default="${boot.java.home}"/>
883            <attribute name="source" default="${javac.source}"/>
884            <attribute name="target" default="${javac.target}"/>
885            <attribute name="release" default="${release}"/>
886            <attribute name="full.version" default="${full.version}"/>
887            <attribute name="plugin.options" default=""/>
888            <sequential>
889                <echo level="verbose" message="build-classes: excludes=@{excludes}"/>
890                <echo level="verbose" message="build-classes: bootclasspath.opt=@{bootclasspath.opt}"/>
891                <echo level="verbose" message="build-classes: classpath=@{classpath}"/>
892                <echo level="verbose" message="build-classes: sourcepath=@{sourcepath}"/>
893                <mkdir dir="@{gensrc.dir}"/>
894                <mkdir dir="@{classes.dir}"/>
895                <pcompile srcdir="${src.classes.dir}"
896                          destdir="@{gensrc.dir}"
897                          includes="@{includes}"/>
898                <copy todir="@{gensrc.dir}">
899                    <fileset dir="${src.classes.dir}" includes="@{includes}"/>
900                    <globmapper from="*.properties-template" to="*.properties"/>
901                    <filterset begintoken="$(" endtoken=")">
902                        <filter token="JDK_VERSION" value="${jdk.version}"/>
903                        <filter token="RELEASE" value="@{release}"/>
904                        <filter token="FULL_VERSION" value="@{full.version}"/>
905                    </filterset>
906                </copy>
907                <pcompile srcdir="@{gensrc.dir}"
908                          destdir="@{gensrc.dir}"
909                          includes="**/*.properties"/>
910                <javac fork="true"
911                       executable="@{java.home}/bin/javac"
912                       srcdir="${src.classes.dir}:@{gensrc.dir}"
913                       destdir="@{classes.dir}"
914                       includes="@{includes}"
915                       excludes="@{excludes}"
916                       sourcepath="@{sourcepath}"
917                       classpath="@{classpath}"
918                       includeAntRuntime="no"
919                       source="@{source}"
920                       target="@{target}"
921                       debug="${javac.debug}"
922                       debuglevel="${javac.debuglevel}">
923                    <compilerarg value="-implicit:none"/>
924                    <compilerarg value="-Xprefer:source"/>
925                    <compilerarg value="-J-Xbootclasspath/p:@{javac.bootclasspath}"/>
926                    <compilerarg line="@{bootclasspath.opt}"/>
927                    <compilerarg line="${javac.no.jdk.warnings}"/>
928                    <compilerarg line="${javac.version.opt}"/>
929                    <compilerarg line="${javac.lint.opts}"/>
930                    <compilerarg line="@{plugin.options}"/>
931                </javac>
932                <copy todir="@{classes.dir}" includeemptydirs="false">
933                    <fileset dir="${src.classes.dir}" includes="@{includes}" excludes="@{excludes}">
934                        <exclude name="**/*.java"/>
935                        <exclude name="**/*.properties"/>
936                        <exclude name="**/*-template"/>
937                        <exclude name="**/*.rej"/>
938                        <exclude name="**/*.orig"/>
939                        <exclude name="**/overview.html"/>
940                        <exclude name="**/package.html"/>
941                    </fileset>
942                </copy>
943            </sequential>
944        </macrodef>
945    </target>
946
947    <target name="-def-build-bootstrap-tool" depends="-check-boot.java.home,-def-build-tool">
948        <presetdef name="build-bootstrap-tool">
949            <build-tool
950                bin.dir="${build.bootstrap.dir}/bin"
951                java="${boot.java}"/>
952        </presetdef>
953    </target>
954
955    <target name="-def-build-bootstrap-jar" depends="-def-build-jar">
956        <presetdef name="build-bootstrap-jar">
957            <build-jar
958                classes.dir="${build.bootstrap.dir}/classes"
959                lib.dir="${build.bootstrap.dir}/lib"/>
960        </presetdef>
961    </target>
962
963    <target name="-def-build-bootstrap-classes" depends="-def-build-classes">
964        <presetdef name="build-bootstrap-classes">
965            <build-classes
966                source="${boot.javac.source}"
967                target="${boot.javac.target}"
968                gensrc.dir="${build.bootstrap.dir}/gensrc"
969                classes.dir="${build.bootstrap.dir}/classes"
970                javac.bootclasspath=""
971                bootclasspath.opt="-Xbootclasspath/p:${build.bootstrap.dir}/classes"
972                sourcepath=""
973                release="${bootstrap.release}"
974                full.version="${bootstrap.full.version}"
975                excludes="${bootstrap.exclude.files} **/package-info.java"/>
976        </presetdef>
977    </target>
978
979    <target name="-def-pcompile">
980        <mkdir dir="${build.toolclasses.dir}"/>
981        <javac fork="true"
982               source="${boot.javac.source}"
983               target="${boot.javac.target}"
984               executable="${boot.java.home}/bin/javac"
985               srcdir="${make.tools.dir}"
986               includes="compileproperties/* anttasks/CompileProperties*"
987               destdir="${build.toolclasses.dir}/"
988               classpath="${ant.core.lib}"
989               bootclasspath="${boot.java.home}/jre/lib/rt.jar"
990               includeantruntime="false">
991            <compilerarg line="${javac.lint.opts}"/>
992        </javac>
993        <taskdef name="pcompile"
994                 classname="anttasks.CompilePropertiesTask"
995                 classpath="${build.toolclasses.dir}/"/>
996    </target>
997
998    <target name="-def-compilecrules">
999        <macrodef name="compilecrules">
1000            <sequential>
1001                <mkdir dir="${build.toolclasses.dir}"/>
1002                <javac fork="true"
1003                       source="${boot.javac.source}"
1004                       target="${boot.javac.target}"
1005                       executable="${boot.java.home}/bin/javac"
1006                       srcdir="${make.tools.dir}"
1007                       includes="crules/*"
1008                       destdir="${build.toolclasses.dir}/"
1009                       classpath="${ant.core.lib}"
1010                       bootclasspath="${boot.java.home}/jre/lib/rt.jar"
1011                       includeantruntime="false">
1012                    <compilerarg value="-Xbootclasspath/p:${build.bootstrap.dir}/classes"/>
1013                    <compilerarg line="${javac.lint.opts}"/>
1014                </javac>
1015                <copy todir="${build.toolclasses.dir}/" includeemptydirs="false">
1016                    <fileset dir="${make.tools.dir}">
1017                        <include name="**/*.properties"/>
1018                    </fileset>
1019                </copy>
1020            </sequential>
1021        </macrodef>
1022    </target>
1023
1024    <target name="-def-genstubs" depends="build-bootstrap-javac" if="require.import.jdk.stubs">
1025        <mkdir dir="${build.toolclasses.dir}"/>
1026        <javac fork="true"
1027               source="${boot.javac.source}"
1028               target="${boot.javac.target}"
1029               executable="${boot.java.home}/bin/javac"
1030               srcdir="${make.tools.dir}"
1031               includes="genstubs/* anttasks/GenStubs*"
1032               destdir="${build.toolclasses.dir}/"
1033               classpath="${ant.core.lib}"
1034               includeantruntime="false">
1035            <compilerarg value="-Xbootclasspath/p:${build.bootstrap.dir}/classes"/>
1036            <compilerarg line="${javac.lint.opts}"/>
1037        </javac>
1038        <taskdef name="genstubs"
1039                 classname="anttasks.GenStubsTask"
1040                 classpath="${build.toolclasses.dir}/"/>
1041    </target>
1042
1043    <target name="-def-javadoc-tool" depends="-check-target.java.home">
1044        <macrodef name="javadoc-tool">
1045            <attribute name="name"/>
1046            <attribute name="includes"/>
1047            <attribute name="options" default=""/>
1048            <attribute name="source" default="1.5"/> <!-- FIXME -->
1049            <sequential>
1050                <property name="javadoc.options" value=""/> <!-- default, can be overridden per user or per project -->
1051                <!-- Note: even with this default value, includes
1052                from src.classes.dir get javadoc'd; see packageset below -->
1053                <property name="javadoc.packagenames" value="none"/> <!-- default, can be overridden per user or per project -->
1054                <javadoc
1055                    executable="${target.java.home}/bin/javadoc"
1056                    destdir="${build.javadoc.dir}/@{name}"
1057                    source="@{source}"
1058                    windowtitle="UNOFFICIAL"
1059                    failonerror="true"
1060                    use="true"
1061                    author="false"
1062                    version="false"
1063                    packagenames="${javadoc.packagenames}" >
1064                    <header><![CDATA[<strong>Unofficial Javadoc</strong> generated from developer sources for preview purposes only]]></header>
1065                    <arg line="@{options}"/>
1066                    <bootclasspath>
1067                        <path location="${build.classes.dir}"/>
1068                        <path location="${target.java.home}/jre/lib/rt.jar"/>
1069                    </bootclasspath>
1070                    <sourcepath>
1071                        <pathelement location="${src.classes.dir}"/>
1072                    </sourcepath>
1073                    <!-- XXX just <fileset> (restricted further to **/*.java) and no <packageset> -->
1074                    <!-- means that {@link some.package} will not work, which is no good. -->
1075                    <!-- (It correctly skips excluded single classes, but not if packageset is also included, -->
1076                    <!-- which also causes duplicates in the class index for included files.) -->
1077                    <packageset dir="${src.classes.dir}" includes="@{includes}">
1078                        <or>
1079                            <filename name="java/"/>
1080                            <filename name="javax/"/>
1081                            <filename name="com/sun/javadoc/"/>
1082                            <filename name="com/sun/source/"/>
1083                        </or>
1084                    </packageset>
1085                </javadoc>
1086            </sequential>
1087        </macrodef>
1088    </target>
1089
1090    <target name="-def-jtreg" unless="jtreg.defined" depends="-check-jtreg.home,-check-target.java.home">
1091        <taskdef name="jtreg" classname="com.sun.javatest.regtest.Main$$Ant">
1092            <classpath>
1093                <pathelement location="${jtreg.home}/lib/jtreg.jar"/>
1094                <pathelement location="${jtreg.home}/lib/javatest.jar"/>
1095            </classpath>
1096        </taskdef>
1097        <macrodef name="jtreg-tool">
1098            <attribute name="name"/>
1099            <attribute name="tests"/>
1100            <attribute name="jdk" default="${target.java.home}"/>
1101            <attribute name="samevm" default="true"/>
1102            <attribute name="verbose" default="${default.jtreg.verbose}"/>
1103            <attribute name="options" default="${other.jtreg.options}"/>
1104            <attribute name="keywords" default="-keywords:!ignore"/>
1105            <attribute name="jpda.jvmargs" default=""/>
1106            <sequential>
1107                <property name="coverage.options" value=""/>              <!-- default -->
1108                <property name="coverage.classpath" value=""/>            <!-- default -->
1109                <property name="default.jtreg.verbose" value="summary"/>  <!-- default -->
1110                <property name="other.jtreg.options" value=""/>           <!-- default -->
1111                <jtreg
1112                    dir="${test.dir}"
1113                    workDir="${build.jtreg.dir}/@{name}/work"
1114                    reportDir="${build.jtreg.dir}/@{name}/report"
1115                    jdk="@{jdk}"
1116                    samevm="@{samevm}" verbose="@{verbose}"
1117                    failonerror="false" resultproperty="jtreg.@{name}.result"
1118                    javacoptions="-g"
1119                    vmoptions="${coverage.options} -Xbootclasspath/p:${coverage.classpath}${path.separator}${build.classes.dir} @{jpda.jvmargs}">
1120                    <arg line="@{keywords}"/>
1121                    <arg line="@{options}"/>
1122                    <arg line="@{tests}"/>
1123                </jtreg>
1124                <!-- the next two properties are for convenience, when only
1125                     a single instance of jtreg will be invoked. -->
1126                <condition property="jtreg.passed">
1127                    <equals arg1="${jtreg.@{name}.result}" arg2="0"/>
1128                </condition>
1129                <property name="jtreg.report" value="${build.jtreg.dir}/@{name}/report"/>
1130            </sequential>
1131        </macrodef>
1132        <property name="jtreg.defined" value="true"/>
1133    </target>
1134
1135    <target name="-def-cobertura" depends="-check-cobertura.home">
1136        <path id="cobertura.classpath">
1137            <fileset dir="${cobertura.home}">
1138                <include name="cobertura.jar"/>
1139                <include name="lib/**/*.jar"/>
1140            </fileset>
1141        </path>
1142        <taskdef classpathref="cobertura.classpath" resource="tasks.properties"/>
1143    </target>
1144
1145    <target name="-def-checkstyle" unless="checkstyle.defined"
1146        depends="-check-checkstyle.home">
1147        <taskdef resource="checkstyletask.properties">
1148            <classpath>
1149                <pathelement location="${checkstyle.home}/${checkstyle.name.version}-all.jar"/>
1150            </classpath>
1151        </taskdef>
1152        <property name="checkstyle.defined" value="true"/>
1153    </target>
1154
1155    <target name="-def-findbugs" unless="findbugs.defined"
1156        depends="-check-findbugs.home,-check-target.java.home">
1157        <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask">
1158            <classpath>
1159                <pathelement location="${findbugs.home}/lib/findbugs.jar"/>
1160            </classpath>
1161        </taskdef>
1162        <macrodef name="findbugs-tool">
1163            <attribute name="name"/>
1164            <attribute name="output" default="emacs"/>
1165            <attribute name="outputFile" default=""/>
1166            <attribute name="reportLevel" default="high"/>
1167            <sequential>
1168                <findbugs
1169                    home="${findbugs.home}"
1170                    output="@{output}"
1171                    outputFile="@{outputFile}"
1172                    reportLevel="@{reportLevel}"
1173                    failOnError="false"
1174                    errorProperty="findbugs.@{name}.errors"
1175                    warningsProperty="findbugs.@{name}.warnings"
1176                    jvm="${target.java.home}/bin/java"
1177                    jvmargs="-Xmx512M" >
1178                    <class location="${dist.dir}/lib/@{name}.jar"/>
1179                    <auxClasspath>
1180                        <pathelement location="${build.classes.dir}"/>
1181                    </auxClasspath>
1182                    <sourcePath>
1183                        <pathelement location="${src.classes.dir}"/>
1184                    </sourcePath>
1185                </findbugs>
1186            </sequential>
1187        </macrodef>
1188        <property name="findbugs.defined" value="true"/>
1189    </target>
1190
1191    <target name="-def-vizant" unless="vizant.defined" depends="-check-vizant">
1192        <taskdef name="vizant" classname="net.sourceforge.vizant.Vizant" classpath="${vizant.jar}"/>
1193        <property name="vizant.defined" value="true"/>
1194    </target>
1195
1196    <target name="-def-check">
1197        <macrodef name="check">
1198            <attribute name="name"/>
1199            <attribute name="property"/>
1200            <attribute name="marker" default=""/>
1201            <sequential>
1202                <fail message="Cannot locate @{name}: please set @{property} to its location">
1203                    <condition>
1204                        <not>
1205                            <isset property="@{property}"/>
1206                        </not>
1207                    </condition>
1208                </fail>
1209                <fail message="@{name} is not installed in ${@{property}}">
1210                    <condition>
1211                        <and>
1212                            <not>
1213                                <equals arg1="@{marker}" arg2=""/>
1214                            </not>
1215                            <not>
1216                                <available file="${@{property}}/@{marker}"/>
1217                            </not>
1218                        </and>
1219                    </condition>
1220                </fail>
1221            </sequential>
1222        </macrodef>
1223    </target>
1224
1225</project>
1226
1227