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