build.xml revision 2873:57b69e17048f
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 a convenience build file supporting development in the langtools
29 repository. It can be run either standalone, or from IDEs. This build script
30 is for a developer use only, it is not used to build the production version
31 of javac or other langtools tools.
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 The main build happens in two phases:
43 - First, javac is built using ${boot.java.home}. (This implies a constraint
44   on the source code that they can be compiled with the previous version of JDK.
45 - Second, all required classes are compiled with the latest javac, created
46   in the previous step.
47 The build generally builds one module at time.
48
49 For more details on the stub generator, see
50    http://blogs.sun.com/jjg/entry/building_javac_for_jdk7
51
52 Internal details ...
53
54 Bootstrap classes are built into the build/bootstrap/<module-name>/classes directory.
55 Final classes are built into the build/<module-name>/classes directory.
56 Final runnable javac is in dist/bin and dist/lib. Bootstrap javac (if requested by
57 using the build-bootstrap-javac target) is built into dist/bootstrap.
58
59 This file is organized into sections as follows:
60 - global property definitions
61 - primary top level targets (cleaning, building, testing, producing javac)
62 - secondary top level targets (code analysis, diagnostics, extra documentation, etc.)
63 - utility definitions
64 -->
65
66<project name="langtools" default="build" basedir="..">
67    <!--
68    **** Global property definitions.
69    -->
70
71    <!-- The following locations can be used to override default property values. -->
72
73    <!-- Use this location for customizations specific to this instance of this workspace -->
74    <property file="build.properties"/>
75
76    <!-- Use this location for customizations common to all OpenJDK langtools workspaces -->
77    <property file="${user.home}/.openjdk/${ant.project.name}-build.properties"/>
78
79    <!-- Use this location for customizations common to all OpenJDK workspaces -->
80    <property file="${user.home}/.openjdk/build.properties"/>
81
82    <!-- Convenient shorthands for standard locations within the workspace. -->
83    <property name="build.dir" location="build"/>
84    <property name="build.crules.dir" location="${build.dir}/crules"/>
85    <property name="build.jtreg.dir" location="${build.dir}/jtreg"/>
86    <property name="build.toolclasses.dir" location="${build.dir}/toolclasses"/>
87    <property name="build.javadoc.dir" location="${build.dir}/javadoc"/>
88    <property name="dist.dir" location="dist"/>
89    <property name="dist.bin.dir" location="${dist.dir}/bin"/>
90    <property name="dist.lib.dir" location="${dist.dir}/lib"/>
91    <property name="dist.findbugs.dir" location="${dist.dir}/findbugs"/>
92    <property name="dist.checkstyle.dir" location="${dist.dir}/checkstyle"/>
93    <property name="make.dir" location="make"/>
94    <property name="make.conf.dir" location="${make.dir}/conf"/>
95    <property name="make.tools.dir" location="${make.dir}/tools"/>
96    <property name="test.dir" location="test"/>
97
98    <property name="boot.build.dir" location="${build.dir}/bootstrap"/>
99    <property name="boot.dist.dir" location="${dist.dir}/bootstrap"/>
100    <property name="boot.dist.bin.dir" location="${boot.dist.dir}/bin"/>
101    <property name="boot.dist.lib.dir" location="${boot.dist.dir}/lib"/>
102
103    <!-- java.marker is set to a marker file to check for within a Java install dir.
104         The best file to check for across Solaris/Linux/Windows/MacOS is one of the
105         executables; regrettably, that is OS-specific. -->
106    <condition property="java.marker" value="bin/java">
107        <os family="unix"/>
108    </condition>
109    <condition property="java.marker" value="bin/java.exe">
110        <os family="windows"/>
111    </condition>
112
113    <!-- Standard property values, if not overriden by earlier settings. -->
114    <property file="${make.dir}/build.properties"/>
115
116    <!-- launcher.java is used in the launcher scripts provided to run
117        the tools' jar files.  If it has not already been set, then
118        default it to use ${target.java.home}, if available, otherwise
119        quietly default to simply use "java". -->
120    <condition property="launcher.java"
121        value="${target.java.home}/bin/java" else="java">
122        <isset property="target.java.home"/>
123    </condition>
124
125    <!-- setup basic properties holding paths to all sources, generated source and class directories
126         (both boot and non-boot) -->
127    <pathconvert property="langtools.sources">
128        <path>
129            <pathelement path="${langtools.modules}" />
130        </path>
131        <map from="${basedir}/" to="${basedir}/src/" />
132        <mapper type="glob" from="*" to="*/share/classes"/>
133    </pathconvert>
134    <pathconvert property="langtools.gensrc">
135        <path>
136            <pathelement path="${langtools.modules}" />
137        </path>
138        <map from="${basedir}/" to="${build.dir}/" />
139        <mapper type="glob" from="*" to="*/gensrc"/>
140    </pathconvert>
141    <pathconvert property="langtools.boot.classes">
142        <path>
143            <pathelement path="${langtools.modules}" />
144        </path>
145        <map from="${basedir}/" to="${boot.build.dir}/" />
146        <mapper type="glob" from="*" to="*/classes"/>
147    </pathconvert>
148    <pathconvert property="langtools.classes">
149        <path>
150            <pathelement path="${langtools.modules}" />
151        </path>
152        <map from="${basedir}/" to="${build.dir}/" />
153        <mapper type="glob" from="*" to="*/classes"/>
154    </pathconvert>
155
156    <!--
157        **** Primary targets
158    -->
159
160    <target name="clean" description="Delete all generated files">
161        <delete dir="${build.dir}"/>
162        <delete dir="${dist.dir}"/>
163    </target>
164
165    <target name="build" depends="build-all-tools">
166    </target>
167
168    <target name="build-all-tools" depends="build-all-classes,-def-build-all-module-jars,-def-build-tool">
169        <build-all-module-jars />
170        <build-tool name="javac"/>
171        <build-tool name="javadoc"/>
172        <build-tool name="javap"/>
173        <build-tool name="javah"/>
174        <build-tool name="sjavac"/>
175    </target>
176
177    <target name="build-all-classes" depends="-def-build-all-module-classes,build-bootstrap-javac-classes">
178        <build-all-module-classes />
179    </target>
180
181    <target name="jtreg" depends="build-all-tools,-def-jtreg">
182        <jtreg-tool name="all" tests="${jtreg.tests}"/>
183    </target>
184
185    <target name="javadoc" depends="build-all-classes,-def-javadoc-tool">
186        <javadoc-tool options="${javadoc.jls.option}"/>
187    </target>
188
189    <target name="build-bootstrap-javac-classes" depends="-check-boot.java.home,-def-build-all-module-classes">
190        <build-all-module-classes compilation.kind="boot." />
191    </target>
192
193    <!--
194        **** Extra targets
195    -->
196
197    <target name="build-bootstrap-javac" depends="build-bootstrap-javac-classes,-def-build-all-module-jars,-def-build-tool">
198        <build-all-module-jars compilation.kind="boot." />
199        <build-tool name="javac" compilation.kind="boot." />
200    </target>
201
202    <target name="jtreg-bootstrap-javac" depends="build-bootstrap-javac,-def-jtreg">
203        <jtreg-tool name="bootstrap-javac"
204                    tests="${boot.javac.tests}"
205                    langtools.classes="${langtools.boot.classes}"/>
206    </target>
207
208    <target name="checkstyle" depends="-def-checkstyle"
209        description="Generates reports for code convention violations.">
210        <mkdir dir="${dist.checkstyle.dir}"/>
211        <checkstyle config="${make.conf.dir}/checkstyle-langtools.xml"
212              failureProperty="checkstyle.failure"
213              failOnViolation="false">
214            <formatter type="xml" tofile="${dist.checkstyle.dir}/checkstyle_report.xml"/>
215            <fileset dir="src" includes="**/*.java, **/*.properties"/>
216        </checkstyle>
217        <!-- transform the output to a simple html -->
218        <xslt  in="${dist.checkstyle.dir}/checkstyle_report.xml"
219               out="${dist.checkstyle.dir}/checkstyle_report.html"
220               style="${checkstyle.home}/contrib/checkstyle-simple.xsl"/>
221        <!-- transform the output to a very simple emacs friendly text file -->
222        <xslt  in="${dist.checkstyle.dir}/checkstyle_report.xml"
223               out="${dist.checkstyle.dir}/checkstyle_report.tmp"
224               style="${make.conf.dir}/checkstyle-emacs.xsl"/>
225        <!-- beautify remove extra lines -->
226        <move file="${dist.checkstyle.dir}/checkstyle_report.tmp"
227             toFile="${dist.checkstyle.dir}/checkstyle_report.emacs.txt">
228            <filterchain>
229                <ignoreblank/>
230                <replaceregex byline="true" pattern="^File:" replace="${line.separator}File:"/>
231            </filterchain>
232        </move>
233    </target>
234    <!-- target can be invoked from an ide, the output of which can be used
235         to access and fix the errors directly.
236     -->
237    <target name="checkstyle-ide" depends="checkstyle">
238        <concat>
239            <fileset file="${dist.checkstyle.dir}/checkstyle_report.emacs.txt"/>
240        </concat>
241    </target>
242
243    <target name="findbugs" depends="-def-findbugs,build-all-tools">
244        <property name="findbugs.reportLevel" value="medium"/>
245        <mkdir dir="${dist.findbugs.dir}"/>
246        <findbugs
247            home="${findbugs.home}"
248            projectName="JDK langtools ${full.version}"
249            output="xml"
250            outputFile="${dist.findbugs.dir}/findbugs.xml"
251            reportLevel="${findbugs.reportLevel}"
252            failOnError="false"
253            errorProperty="findbugs.all.errors"
254            warningsProperty="findbugs.all.warnings"
255            jvm="${target.java.home}/bin/java"
256            jvmargs="-Xmx512M">
257            <class location="${build.dir}/java.compiler/classes"/>
258            <class location="${build.dir}/jdk.compiler/classes"/>
259            <class location="${build.dir}/jdk.javadoc/classes"/>
260            <class location="${build.dir}/jdk.dev/classes"/>
261            <sourcePath>
262                <pathelement path="${langtools.sources}"/>
263            </sourcePath>
264        </findbugs>
265        <exec executable="sh">
266            <arg value="${findbugs.home}/bin/convertXmlToText"/>
267            <arg value="-longBugCodes"/>
268            <arg value="-html:${findbugs.home}/src/xsl/fancy.xsl"/>
269            <arg value="${dist.findbugs.dir}/findbugs.xml"/>
270            <redirector output="${dist.findbugs.dir}/findbugs.html"/>
271        </exec>
272    </target>
273
274    <target name="diags-examples" depends="build-all-tools">
275        <!-- can override the following on the command line if desired. -->
276        <property name="diags.examples.out" location="${build.dir}/diag-examples/diags-examples.html"/>
277        <mkdir dir="${build.dir}/diag-examples/classes"/>
278        <javac fork="true"
279            executable="${dist.bin.dir}/javac"
280            srcdir="test/tools/javac/diags"
281            destdir="${build.dir}/diag-examples/classes"
282            includes="ArgTypeCompilerFactory.java,Example.java,FileManager.java,HTMLWriter.java,RunExamples.java,DocCommentProcessor.java"
283            sourcepath=""
284            classpath="${langtools.classes}"
285            includeAntRuntime="no"
286            debug="${javac.debug}"
287            debuglevel="${javac.debuglevel}">
288            <compilerarg line="${javac.lint.opts}"/>
289        </javac>
290        <java fork="true"
291            jvm="${target.java.home}/bin/java"
292            dir="test/tools/javac/diags"
293            classpath="${build.dir}/diag-examples/classes;${langtools.classes}"
294            classname="RunExamples">
295            <jvmarg value="-Dtest.classes=${build.dir}/diag-examples/classes"/>
296            <arg value="-examples"/>
297            <arg value="examples"/>
298            <arg value="-o"/>
299            <arg file="${diags.examples.out}"/>
300            <arg value="-showFiles"/>
301            <arg value="-title"/>
302            <arg value="Examples of javac diagnostics"/>
303        </java>
304    </target>
305
306    <target name="doclint-api" depends="build-all-classes">
307        <delete dir="${build.dir}/doclint/classes"/>
308        <mkdir dir="${build.dir}/doclint/classes"/>
309        <javac fork="true"
310               executable="${boot.java.home}/bin/javac"
311               destdir="${build.dir}/doclint/classes"
312               includes="javax/lang/model/** com/sun/javadoc/** com/sun/source/**"
313               excludes=""
314               sourcepath=""
315               classpath="${langtools.classes}"
316               includeAntRuntime="no"
317               source="${javac.source}"
318               target="${javac.target}"
319               debug="${javac.debug}"
320               debuglevel="${javac.debuglevel}">
321            <compilerarg value="-implicit:none"/>
322            <compilerarg value="-Xprefer:source"/>
323            <compilerarg value="-J-Xbootclasspath/p:${build.bootstrap.dir}/classes"/>
324            <compilerarg line="${javac.extra.opts}"/>
325            <compilerarg line="-Xdoclint:all/protected,-missing"/>
326            <src>
327                <pathelement path="${langtools.sources}"/>
328                <pathelement path="${langtools.gensrc}"/>
329            </src>
330        </javac>
331    </target>
332
333    <!-- Generate API docs for "important" test classes that are used by
334         multiple tests.
335    -->
336    <target name="test-framework-docs" depends="build-all-classes">
337        <javadoc executable="${target.java.home}/bin/javadoc"
338                destdir="${build.dir}/testframeworkdocs">
339            <!-- disable doclint for now; it might be good to enable -Xdoclint:missing -->
340            <arg value="-Xdoclint:none"/>
341            <!-- source files to be documented -->
342            <sourcefiles>
343                <fileset dir="${test.dir}">
344                    <include name="**/ToolBox.java"/>
345                    <include name="**/*Tester.java"/>
346                    <include name="**/*TestBase.java"/>
347                    <include name="**/*Testing*.java"/>
348                </fileset>
349            </sourcefiles>
350            <!-- source path used for documentation -->
351            <sourcepath>
352                <pathelement path="${test.dir}/lib"/>
353                <pathelement path="${test.dir}/lib/combo"/>
354                <pathelement path="${test.dir}/tools/javac/lib"/>
355                <pathelement path="${test.dir}/tools/javac/classfiles/attributes/LocalVariableTable"/>
356            </sourcepath>
357            <!-- exclude the following "packages" found by <javadoc>
358                on the sourcepath -->
359            <excludepackage name="combo.tools.javac.combo"/>
360            <excludepackage name="tools.javac.combo"/>
361            <!-- library classes used for documentation -->
362            <classpath>
363                <pathelement path="${jtreg.home}/lib/testng.jar"/>
364            </classpath>
365            <!-- platform classes used for documentation -->
366            <bootclasspath>
367                <pathelement path="${langtools.classes}"/>
368                <pathelement path="${target.java.home}/jre/lib/rt.jar"/>
369            </bootclasspath>
370        </javadoc>
371    </target>
372
373    <target name="sanity"
374        description="display settings of configuration values">
375        <echo level="info">ant.home = ${ant.home}</echo>
376        <echo level="info">boot.java.home = ${boot.java.home}</echo>
377        <echo level="info">target.java.home = ${target.java.home}</echo>
378        <echo level="info">jtreg.home = ${jtreg.home}</echo>
379        <echo level="info">findbugs.home = ${findbugs.home}</echo>
380        <echo level="info">checkstyle.home = ${checkstyle.home}</echo>
381    </target>
382
383    <target name="diagnostics">
384        <diagnostics/>
385    </target>
386
387    <target name="jtreg-crules" depends="build-all-classes,-def-jtreg">
388        <mkdir dir="${build.crules.dir}/classes"/>
389        <javac fork="true"
390               source="${boot.javac.source}"
391               target="${boot.javac.target}"
392               executable="${boot.java.home}/bin/javac"
393               srcdir="${make.tools.dir}"
394               includes="crules/*"
395               destdir="${build.crules.dir}/classes"
396               includeantruntime="false">
397            <compilerarg value="-Xbootclasspath/p:${langtools.classes}"/>
398            <compilerarg line="${javac.lint.opts}"/>
399        </javac>
400        <copy todir="${build.crules.dir}/classes" includeemptydirs="false">
401            <fileset dir="${make.tools.dir}">
402                <include name="**/*.properties"/>
403            </fileset>
404        </copy>
405        <echo file="${build.crules.dir}/classes/META-INF/services/com.sun.source.util.Plugin">crules.CodingRulesAnalyzerPlugin</echo>
406        <jtreg-tool name="crules"
407                    tests="${crules.tests}"
408                    extra.jvmargs="-Xbootclasspath/a:${build.crules.dir}/classes" />
409    </target>
410
411    <!--
412    **** IDE support
413    -->
414
415    <target name="idea">
416        <mkdir dir=".idea"/>
417        <copy todir=".idea" >
418            <fileset dir="make/intellij" excludes="**/src/**"/>
419        </copy>
420        <condition property="jtreg.idea.home" value="${jtreg.home}" else = "[jtreg.home]">
421            <isset property="jtreg.home"/>
422        </condition>
423        <replace file=".idea/ant.xml" token="@@@" value="${jtreg.idea.home}"/>
424        <replace file=".idea/workspace.xml" token="@FILE_SEP@" value="${file.separator}"/>
425        <replace file=".idea/workspace.xml" token="@PATH_SEP@" value="${path.separator}"/>
426        <mkdir dir=".idea/classes"/>
427        <javac srcdir="make/intellij/src"
428               destdir=".idea/classes"/>
429    </target>
430
431    <!--
432    **** Check targets.
433    **** "-check-*" targets check that a required property is set, and set to a reasonable value.
434    **** A user friendly message is generated if not, and the build exits.
435    -->
436
437    <target name="-check-boot.java.home" depends="-def-check">
438        <check name="bootstrap java" property="boot.java.home" marker="${java.marker}"/>
439    </target>
440
441    <target name="-check-target.java.home" depends="-def-check">
442        <check name="target java" property="target.java.home" marker="${java.marker}"/>
443    </target>
444
445    <target name="-check-jtreg.home" depends="-def-check">
446        <check name="jtreg" property="jtreg.home" marker="lib/jtreg.jar"/>
447    </target>
448
449    <target name="-check-findbugs.home" depends="-def-check">
450        <check name="findbugs" property="findbugs.home" marker="lib/findbugs.jar"/>
451    </target>
452
453    <target name="-check-checkstyle.home" depends="-def-check">
454        <check name="checkstyle" property="checkstyle.home" marker=""/> <!--TODO: better checkstyle verification-->
455    </target>
456
457    <!-- Definitions -->
458
459    <target name="-def-build-all-module-jars" depends="-def-build-module-jar">
460        <macrodef name="build-all-module-jars">
461            <attribute name="compilation.kind" default=""/>
462            <sequential>
463                <build-module-jar module.name="java.compiler" compilation.kind="@{compilation.kind}" />
464                <build-module-jar module.name="jdk.compiler" compilation.kind="@{compilation.kind}" />
465                <build-module-jar module.name="jdk.javadoc" compilation.kind="@{compilation.kind}" />
466                <build-module-jar module.name="jdk.dev" compilation.kind="@{compilation.kind}" />
467            </sequential>
468        </macrodef>
469    </target>
470
471    <target name="-def-build-module-jar">
472        <macrodef name="build-module-jar">
473            <attribute name="module.name"/>
474            <attribute name="compilation.kind"/>
475            <attribute name="dependencies" default="${@{compilation.kind}@{module.name}.dependencies}"/>
476            <attribute name="build.dir" default="${@{compilation.kind}build.dir}"/>
477            <attribute name="lib.dir" default="${@{compilation.kind}dist.lib.dir}"/>
478            <attribute name="classes.dir" default="@{build.dir}/@{module.name}/classes"/>
479            <sequential>
480                <mkdir dir="@{lib.dir}"/>
481                <local name="jarclasspath" />
482                <pathconvert property="jarclasspath">
483                    <path>
484                        <pathelement path="@{dependencies}" />
485                    </path>
486                    <map from="${basedir}/" to="" />
487                    <mapper type="glob" from="*" to="*.jar"/>
488                </pathconvert>
489                <jar destfile="@{lib.dir}/@{module.name}.jar"
490                     basedir="@{classes.dir}">
491                    <manifest>
492                        <attribute name="Class-Path" value="@{jarclasspath}"/>
493                    </manifest>
494                </jar>
495            </sequential>
496        </macrodef>
497    </target>
498
499    <target name="-def-build-tool">
500        <macrodef name="build-tool">
501            <attribute name="name"/>
502            <attribute name="compilation.kind" default=""/>
503            <attribute name="bin.dir" default="${@{compilation.kind}dist.bin.dir}"/>
504            <attribute name="java" default="${launcher.java}"/>
505            <sequential>
506                <mkdir dir="@{bin.dir}"/>
507                <copy file="${make.dir}/launcher.sh-template" tofile="@{bin.dir}/@{name}">
508                    <filterset begintoken="#" endtoken="#">
509                        <filter token="PROGRAM" value="@{name}"/>
510                        <filter token="TARGET_JAVA" value="@{java}"/>
511                        <filter token="PS" value="${path.separator}"/>
512                    </filterset>
513                </copy>
514                <chmod file="@{bin.dir}/@{name}" perm="ugo+rx"/>
515            </sequential>
516        </macrodef>
517    </target>
518
519    <target name="-def-build-all-module-classes" depends="-def-build-module-classes">
520        <macrodef name="build-all-module-classes">
521            <attribute name="compilation.kind" default=""/>
522            <sequential>
523                <build-module-classes module.name="java.compiler"
524                                      compilation.kind="@{compilation.kind}" />
525                <build-module-classes module.name="jdk.compiler"
526                                      compilation.kind="@{compilation.kind}"
527                                      resource.includes="${javac.resource.includes}" />
528                <build-module-classes module.name="jdk.javadoc"
529                                      compilation.kind="@{compilation.kind}" />
530                <build-module-classes module.name="jdk.dev"
531                                      compilation.kind="@{compilation.kind}" />
532            </sequential>
533        </macrodef>
534    </target>
535
536    <target name="-def-build-module-classes" depends="-def-pcompile,-def-pparse">
537        <macrodef name="build-module-classes">
538            <attribute name="module.name"/>
539            <attribute name="compilation.kind" default=""/>
540            <attribute name="resource.includes" default="nonExistent" />
541            <attribute name="dependencies" default="${@{module.name}.dependencies}"/>
542            <attribute name="includes" default="${@{compilation.kind}javac.includes}"/>
543            <attribute name="javac.lint.opts" default="${@{compilation.kind}javac.lint.opts}"/>
544            <attribute name="javac.extra.opts" default="${@{compilation.kind}javac.extra.opts}"/>
545            <attribute name="build.dir" default="${@{compilation.kind}build.dir}"/>
546            <attribute name="excludes" default="${exclude.files} **/package-info.java"/>
547            <attribute name="classes.dir" default="@{build.dir}/@{module.name}/classes"/>
548            <attribute name="gensrc.dir" default="@{build.dir}/@{module.name}/gensrc"/>
549            <attribute name="depcache.dir" default="@{build.dir}/@{module.name}/depcache"/>
550            <attribute name="java.home" default="${boot.java.home}"/>
551            <attribute name="source" default="${@{compilation.kind}javac.source}"/>
552            <attribute name="target" default="${@{compilation.kind}javac.target}"/>
553            <attribute name="release" default="${release}"/>
554            <attribute name="full.version" default="${full.version}"/>
555            <attribute name="plugin.options" default=""/>
556            <sequential>
557                <echo level="verbose" message="build-classes: excludes=@{excludes}"/>
558                <echo level="verbose" message="build-classes: classpath=@{classpath}"/>
559                <echo level="verbose" message="build-classes: sourcepath=@{sourcepath}"/>
560                <echo level="verbose" message="build-classes: dependencies=@{dependencies}"/>
561                <local name="src.dir" />
562                <property name="src.dir" location="${basedir}/src/@{module.name}/share/classes"/>
563                <local name="classpath" />
564                <pathconvert property="classpath">
565                    <path>
566                        <pathelement path="@{dependencies}" />
567                    </path>
568                    <map from="${basedir}/" to="@{build.dir}/" />
569                    <mapper type="glob" from="*" to="*/classes"/>
570                </pathconvert>
571                <local name="bootclasspath.prepend"/>
572                <condition property="bootclasspath.prepend" value="" else="${langtools.boot.classes}">
573                    <equals arg1="@{compilation.kind}" arg2="boot."/>
574                </condition>
575                <mkdir dir="@{classes.dir}"/>
576                <mkdir dir="@{gensrc.dir}"/>
577                <mkdir dir="@{depcache.dir}"/>
578                <pcompile destdir="@{gensrc.dir}"
579                          includes="@{includes}">
580                    <src>
581                        <path location="${src.dir}"/>
582                    </src>
583                </pcompile>
584                <pparse destdir="@{gensrc.dir}"
585                        includes="@{resource.includes}">
586                    <src>
587                        <path location="${src.dir}"/>
588                    </src>
589                </pparse>
590                <copy todir="@{gensrc.dir}">
591                    <fileset dir="${src.dir}" includes="@{includes}" />
592                    <globmapper from="*.properties-template" to="*.properties"/>
593                    <filterset begintoken="$(" endtoken=")">
594                        <filter token="JDK_VERSION" value="${jdk.version}"/>
595                        <filter token="RELEASE" value="@{release}"/>
596                        <filter token="FULL_VERSION" value="@{full.version}"/>
597                    </filterset>
598                </copy>
599                <pcompile destdir="@{gensrc.dir}"
600                          includes="**/*.properties">
601                    <src>
602                        <pathelement location="@{gensrc.dir}"/>
603                    </src>
604                </pcompile>
605                <antcall target="-do-depend">
606                    <param name="src.dir" value="${src.dir}" />
607                    <param name="classes.dir" value="@{classes.dir}" />
608                    <param name="gensrc.dir" value="@{gensrc.dir}" />
609                    <param name="depcache.dir" value="@{depcache.dir}" />
610                    <param name="classpath" value="${classpath}" />
611                </antcall>
612                <javac fork="true"
613                       executable="@{java.home}/bin/javac"
614                       destdir="@{classes.dir}"
615                       includes="@{includes}"
616                       excludes="@{excludes}"
617                       sourcepath="${src.dir}:@{gensrc.dir}"
618                       classpath="${classpath}"
619                       includeAntRuntime="no"
620                       source="@{source}"
621                       target="@{target}"
622                       debug="${javac.debug}"
623                       debuglevel="${javac.debuglevel}">
624                    <compilerarg value="-implicit:none"/>
625                    <compilerarg value="-Xprefer:source"/>
626                    <compilerarg value="-J-Xbootclasspath/p:${bootclasspath.prepend}"/>
627                    <compilerarg value="-Xbootclasspath/p:${classpath}"/>
628                    <compilerarg line="@{javac.extra.opts}"/>
629                    <compilerarg line="@{javac.lint.opts}"/>
630                    <compilerarg line="@{plugin.options}"/>
631                    <src>
632                        <path location="${src.dir}"/>
633                        <path location="@{gensrc.dir}"/>
634                    </src>
635                </javac>
636                <copy todir="@{classes.dir}" includeemptydirs="false">
637                    <fileset dir="${src.dir}" includes="@{includes}" excludes="@{excludes}">
638                        <exclude name="**/*.java"/>
639                        <exclude name="**/*.properties"/>
640                        <exclude name="**/*-template"/>
641                        <exclude name="**/*.rej"/>
642                        <exclude name="**/*.orig"/>
643                        <exclude name="**/overview.html"/>
644                        <exclude name="**/package.html"/>
645                    </fileset>
646                </copy>
647            </sequential>
648        </macrodef>
649    </target>
650
651    <target name="-def-pparse">
652        <mkdir dir="${build.toolclasses.dir}"/>
653        <copy todir="${build.toolclasses.dir}/propertiesparser" >
654            <fileset dir="make/tools/propertiesparser" includes="**/resources/**"/>
655        </copy>
656        <javac fork="true"
657               source="${boot.javac.source}"
658               target="${boot.javac.target}"
659               executable="${boot.java.home}/bin/javac"
660               srcdir="${make.tools.dir}"
661               includes="propertiesparser/* anttasks/PropertiesParser* anttasks/PathFileSet*"
662               destdir="${build.toolclasses.dir}/"
663               classpath="${ant.core.lib}"
664               bootclasspath="${boot.java.home}/jre/lib/rt.jar"
665               includeantruntime="false">
666            <compilerarg line="${javac.lint.opts}"/>
667        </javac>
668        <taskdef name="pparse"
669                 classname="anttasks.PropertiesParserTask"
670                 classpath="${build.toolclasses.dir}/"/>
671    </target>
672
673    <target name="-do-depend" if="do.depend">
674        <depend srcdir="${src.dir}:${gensrc.dir}" destdir="${classes.dir}" classpath="${classpath}"
675                cache="${depcache.dir}"/>
676    </target>
677
678    <target name="-def-pcompile">
679        <mkdir dir="${build.toolclasses.dir}"/>
680        <javac fork="true"
681               source="${boot.javac.source}"
682               target="${boot.javac.target}"
683               executable="${boot.java.home}/bin/javac"
684               srcdir="${make.tools.dir}"
685               includes="compileproperties/* anttasks/CompileProperties* anttasks/PathFileSet*"
686               destdir="${build.toolclasses.dir}/"
687               classpath="${ant.core.lib}"
688               bootclasspath="${boot.java.home}/jre/lib/rt.jar"
689               includeantruntime="false">
690            <compilerarg line="${javac.lint.opts}"/>
691        </javac>
692        <taskdef name="pcompile"
693                 classname="anttasks.CompilePropertiesTask"
694                 classpath="${build.toolclasses.dir}/"/>
695    </target>
696
697    <target name="-def-javadoc-tool" depends="-check-target.java.home">
698        <macrodef name="javadoc-tool">
699            <attribute name="includes" default="${javac.includes}"/>
700            <attribute name="options" default=""/>
701            <attribute name="source" default="${javac.source}"/>
702            <sequential>
703                <property name="javadoc.options" value=""/> <!-- default, can be overridden per user or per project -->
704                <!-- Note: even with this default value, includes
705                from source directories get javadoc'd; see packageset below -->
706                <property name="javadoc.packagenames" value="none"/> <!-- default, can be overridden per user or per project -->
707                <javadoc
708                    executable="${target.java.home}/bin/javadoc"
709                    destdir="${build.javadoc.dir}"
710                    source="@{source}"
711                    windowtitle="UNOFFICIAL"
712                    failonerror="true"
713                    use="true"
714                    author="false"
715                    version="false"
716                    packagenames="${javadoc.packagenames}" >
717                    <header><![CDATA[<strong>Unofficial Javadoc</strong> generated from developer sources for preview purposes only]]></header>
718                    <arg line="@{options}"/>
719                    <bootclasspath>
720                        <pathelement path="${langtools.classes}"/>
721                        <path location="${target.java.home}/jre/lib/rt.jar"/>
722                    </bootclasspath>
723                    <sourcepath>
724                        <pathelement path="${langtools.sources}"/>
725                    </sourcepath>
726                    <!-- XXX just <fileset> (restricted further to **/*.java) and no <packageset> -->
727                    <!-- means that {@link some.package} will not work, which is no good. -->
728                    <!-- (It correctly skips excluded single classes, but not if packageset is also included, -->
729                    <!-- which also causes duplicates in the class index for included files.) -->
730                    <packageset dir="${basedir}/src/java.compiler/share/classes" includes="@{includes}">
731                        <or>
732                            <filename name="javax/"/>
733                        </or>
734                    </packageset>
735                    <packageset dir="${basedir}/src/jdk.compiler/share/classes" includes="@{includes}">
736                        <or>
737                            <filename name="com/sun/source/"/>
738                        </or>
739                    </packageset>
740                    <packageset dir="${basedir}/src/jdk.javadoc/share/classes" includes="@{includes}">
741                        <or>
742                            <filename name="com/sun/javadoc/"/>
743                        </or>
744                    </packageset>
745                </javadoc>
746            </sequential>
747        </macrodef>
748    </target>
749
750    <target name="-def-jtreg" unless="jtreg.defined" depends="-check-jtreg.home,-check-target.java.home">
751        <taskdef name="jtreg" classname="com.sun.javatest.regtest.Main$$Ant">
752            <classpath>
753                <pathelement location="${jtreg.home}/lib/jtreg.jar"/>
754                <pathelement location="${jtreg.home}/lib/javatest.jar"/>
755            </classpath>
756        </taskdef>
757        <macrodef name="jtreg-tool">
758            <attribute name="name"/>
759            <attribute name="tests"/>
760            <attribute name="langtools.classes" default="${langtools.classes}"/>
761            <attribute name="jdk" default="${target.java.home}"/>
762            <attribute name="samevm" default="true"/>
763            <attribute name="verbose" default="${default.jtreg.verbose}"/>
764            <attribute name="options" default="${other.jtreg.options}"/>
765            <attribute name="keywords" default="-keywords:!ignore"/>
766            <attribute name="jpda.jvmargs" default=""/>
767            <attribute name="extra.jvmargs" default=""/>
768            <attribute name="build.dir" default="${build.dir}"/>
769            <sequential>
770                <property name="coverage.options" value=""/>              <!-- default -->
771                <property name="coverage.classpath" value=""/>            <!-- default -->
772                <property name="default.jtreg.verbose" value="summary"/>  <!-- default -->
773                <property name="other.jtreg.options" value=""/>           <!-- default -->
774                <jtreg
775                    dir="${test.dir}"
776                    workDir="${build.jtreg.dir}/@{name}/work"
777                    reportDir="${build.jtreg.dir}/@{name}/report"
778                    jdk="@{jdk}"
779                    samevm="@{samevm}" verbose="@{verbose}"
780                    failonerror="false" resultproperty="jtreg.@{name}.result"
781                    javacoptions="-g"
782                    vmoptions="${coverage.options} -Xbootclasspath/p:${coverage.classpath}${path.separator}@{langtools.classes} @{jpda.jvmargs} @{extra.jvmargs}">
783                    <arg line="@{keywords}"/>
784                    <arg line="@{options}"/>
785                    <arg line="@{tests}"/>
786                </jtreg>
787                <!-- the next two properties are for convenience, when only
788                     a single instance of jtreg will be invoked. -->
789                <condition property="jtreg.passed">
790                    <equals arg1="${jtreg.@{name}.result}" arg2="0"/>
791                </condition>
792                <property name="jtreg.report" value="${build.jtreg.dir}/@{name}/report"/>
793            </sequential>
794        </macrodef>
795        <property name="jtreg.defined" value="true"/>
796    </target>
797
798    <target name="-def-checkstyle" unless="checkstyle.defined" depends="-check-checkstyle.home">
799        <taskdef resource="checkstyletask.properties">
800            <classpath>
801              <fileset dir="${checkstyle.home}">
802                <include name="checkstyle-*-all.jar"/>
803              </fileset>
804            </classpath>
805        </taskdef>
806        <property name="checkstyle.defined" value="true"/>
807    </target>
808
809    <target name="-def-findbugs" unless="findbugs.defined"
810        depends="-check-findbugs.home,-check-target.java.home">
811        <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask">
812            <classpath>
813                <pathelement location="${findbugs.home}/lib/findbugs.jar"/>
814            </classpath>
815        </taskdef>
816        <macrodef name="findbugs-tool">
817            <attribute name="name"/>
818            <attribute name="output" default="emacs"/>
819            <attribute name="outputFile" default=""/>
820            <attribute name="reportLevel" default="high"/>
821            <sequential>
822                <findbugs
823                    home="${findbugs.home}"
824                    output="@{output}"
825                    outputFile="@{outputFile}"
826                    reportLevel="@{reportLevel}"
827                    failOnError="false"
828                    errorProperty="findbugs.@{name}.errors"
829                    warningsProperty="findbugs.@{name}.warnings"
830                    jvm="${target.java.home}/bin/java"
831                    jvmargs="-Xmx512M" >
832                    <class location="${dist.dir}/lib/@{name}.jar"/>
833                    <auxClasspath>
834                        <pathelement location="${langtools.classes}"/>
835                    </auxClasspath>
836                    <sourcePath>
837                        <path refid="src.dirs"/>
838                    </sourcePath>
839                </findbugs>
840            </sequential>
841        </macrodef>
842        <property name="findbugs.defined" value="true"/>
843    </target>
844
845    <target name="-def-check">
846        <macrodef name="check">
847            <attribute name="name"/>
848            <attribute name="property"/>
849            <attribute name="marker" default=""/>
850            <sequential>
851                <fail message="Cannot locate @{name}: please set @{property} to its location">
852                    <condition>
853                        <not>
854                            <isset property="@{property}"/>
855                        </not>
856                    </condition>
857                </fail>
858                <fail message="@{name} is not installed in ${@{property}}">
859                    <condition>
860                        <and>
861                            <not>
862                                <equals arg1="@{marker}" arg2=""/>
863                            </not>
864                            <not>
865                                <available file="${@{property}}/@{marker}"/>
866                            </not>
867                        </and>
868                    </condition>
869                </fail>
870            </sequential>
871        </macrodef>
872    </target>
873
874</project>
875
876