build.xml 34.3 KB
Newer Older
D
duke 已提交
1 2
<?xml version="1.0" encoding="UTF-8"?>
<!--
X
xdono 已提交
3
 Copyright 2007-2009 Sun Microsystems, Inc.  All Rights Reserved.
D
duke 已提交
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.

 This code is free software; you can redistribute it and/or modify it
 under the terms of the GNU General Public License version 2 only, as
 published by the Free Software Foundation.  Sun designates this
 particular file as subject to the "Classpath" exception as provided
 by Sun in the LICENSE file that accompanied this code.

 This code is distributed in the hope that it will be useful, but WITHOUT
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 version 2 for more details (a copy is included in the LICENSE file that
 accompanied this code).

 You should have received a copy of the GNU General Public License version
 2 along with this work; if not, write to the Free Software Foundation,
 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.

 Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
 CA 95054 USA or visit www.sun.com if you need additional information or
 have any questions.
-->

<!--
 This is the main build file for the complete langtools workspace.
 It is used both when working on the tools in NetBeans, and when building
 JDK itself, in which case it is invoked from the wrapper Makefile.
 -->

<project name="langtools" default="build" basedir="..">
34

35 36 37 38 39 40 41
    <!-- Force full debuginfo for javac if the debug.classfiles
    property is set.  This must be BEFORE the include of
    build.properties because it sets javac.debuglevel.  -->
    <condition property="javac.debuglevel" value="source,lines,vars">
        <equals arg1="${debug.classfiles}" arg2="true"/>
    </condition>

D
duke 已提交
42 43 44 45 46 47 48 49 50 51
    <!-- The following locations can be used to override default property values. -->

    <!-- Use this location for customizations specific to this instance of this workspace -->
    <property file="build.properties"/>

    <!-- Use this location for customizations common to all OpenJDK langtools workspaces -->
    <property file="${user.home}/.openjdk/${ant.project.name}-build.properties"/>

    <!-- Use this location for customizations common to all OpenJDK workspaces -->
    <property file="${user.home}/.openjdk/build.properties"/>
52 53

    <!-- Convenient shorthands for standard locations within the workspace. -->
D
duke 已提交
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
    <property name="build.dir" location="build"/>
    <property name="build.bootstrap.dir" location="${build.dir}/bootstrap"/>
    <property name="build.coverage.dir" location="${build.dir}/coverage"/>
    <property name="build.classes.dir" location="${build.dir}/classes"/>
    <property name="build.gensrc.dir" location="${build.dir}/gensrc"/>
    <property name="build.javadoc.dir" location="${build.dir}/javadoc"/>
    <property name="build.jtreg.dir" location="${build.dir}/jtreg"/>
    <property name="build.toolclasses.dir" location="${build.dir}/toolclasses"/>
    <property name="dist.dir" location="dist"/>
    <property name="dist.bin.dir" location="${dist.dir}/bin"/>
    <property name="dist.coverage.dir" location="${dist.dir}/coverage"/>
    <property name="dist.findbugs.dir" location="${dist.dir}/findbugs"/>
    <property name="dist.lib.dir" location="${dist.dir}/lib"/>
    <property name="make.dir" location="make"/>
    <property name="make.tools.dir" location="${make.dir}/tools"/>
    <property name="src.dir" location="src"/>
    <property name="src.bin.dir" location="${src.dir}/share/bin"/>
    <property name="src.classes.dir" location="${src.dir}/share/classes"/>
    <property name="test.dir" location="test"/>

    <!-- java.marker is set to a marker file to check for within a Java install dir.
         The best file to check for across Solaris/Linux/Windows/MacOS is one of the
         executables; regrettably, that is OS-specific. -->
    <condition property="java.marker" value="bin/java">
78
        <os family="unix"/>
D
duke 已提交
79 80
    </condition>
    <condition property="java.marker" value="bin/java.exe">
81
        <os family="windows"/>
D
duke 已提交
82
    </condition>
83

D
duke 已提交
84
    <!-- Standard property values, if not overriden by earlier settings. -->
85
    <property file="${make.dir}/build.properties"/>
J
jjg 已提交
86 87

    <!-- launcher.java is used in the launcher scripts provided to run
88 89 90 91 92 93
        the tools' jar files.  If it has not already been set, then
        default it to use ${target.java.home}, if available, otherwise
        quietly default to simply use "java". -->
    <condition property="launcher.java"
        value="${target.java.home}/bin/java" else="java">
        <isset property="target.java.home"/>
J
jjg 已提交
94 95
    </condition>

96

D
duke 已提交
97 98 99 100 101 102 103 104 105 106 107 108 109
    <!-- Standard target to build deliverables for JDK build. -->

    <target name="build" depends="build-bootstrap-tools,build-all-classes">
        <copy todir="${dist.dir}/bootstrap">
            <fileset dir="${build.bootstrap.dir}" includes="bin/,lib/"/>
        </copy>
        <chmod dir="${dist.dir}/bootstrap/bin" perm="ugo+rx">
            <include name="*"/>
        </chmod>
        <mkdir dir="${dist.lib.dir}"/>
        <jar file="${dist.lib.dir}/classes.jar" basedir="${build.classes.dir}"/>
        <zip file="${dist.lib.dir}/src.zip" basedir="${src.classes.dir}"/>
    </target>
110

D
duke 已提交
111
    <target name="build-bootstrap-tools" depends="build-bootstrap-javac,build-bootstrap-javadoc,build-bootstrap-doclets,build-bootstrap-javah"/>
112

D
duke 已提交
113
    <target name="build-all-tools" depends="build-javac,build-javadoc,build-doclets,build-javah,build-javap,build-apt"/>
114

D
duke 已提交
115
    <target name="build-all-classes" depends="build-classes-javac,build-classes-javadoc,build-classes-doclets,build-classes-javah,build-classes-javap,build-classes-apt"/>
116

D
duke 已提交
117 118 119 120 121 122 123 124 125
    <!-- clean -->

    <target name="clean" description="Delete all generated files">
        <delete dir="${build.dir}"/>
        <delete dir="${dist.dir}"/>
    </target>

    <!-- Additional targets for running tools on the build -->

126 127 128 129
    <target name="jtreg" depends="build-all-tools,-def-jtreg">
        <jtreg-tool name="all" tests="${jtreg.tests}"/>
    </target>

D
duke 已提交
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
    <target name="findbugs" depends="-def-findbugs,build-all-tools">
        <property name="findbugs.reportLevel" value="medium"/>
        <mkdir dir="${dist.findbugs.dir}"/>
        <findbugs
            home="${findbugs.home}"
            projectName="JDK langtools ${full.version}"
            output="xml"
            outputFile="${dist.findbugs.dir}/findbugs.xml"
            reportLevel="${findbugs.reportLevel}"
            failOnError="false"
            errorProperty="findbugs.all.errors"
            warningsProperty="findbugs.all.warnings"
            jvmargs="-Xmx512M">
            <class location="${build.classes.dir}"/>
            <sourcePath>
                <pathelement location="${src.classes.dir}"/>
            </sourcePath>
        </findbugs>
        <exec executable="sh">
            <arg value="${findbugs.home}/bin/convertXmlToText"/>
            <arg value="-longBugCodes"/>
            <arg value="-html:${findbugs.home}/src/xsl/fancy.xsl"/>
            <arg value="${dist.findbugs.dir}/findbugs.xml"/>
            <redirector output="${dist.findbugs.dir}/findbugs.html"/>
154
        </exec>
D
duke 已提交
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
    </target>

    <target name="coverage" depends="-def-cobertura,build-all-classes,instrument-classes,jtreg,coverage-report"/>

    <target name="instrument-classes" depends="-def-cobertura">
        <!-- only define the following property when we want coverage info -->
        <path id="coverage.classpath">
            <pathelement location="${build.coverage.dir}/classes"/>
            <path refid="cobertura.classpath"/>
        </path>
        <property name="coverage.options" value="-Dnet.sourceforge.cobertura.datafile=${build.coverage.dir}/cobertura.ser"/>
        <property name="coverage.classpath" refid="coverage.classpath"/>
        <mkdir dir="${build.coverage.dir}/classes"/>
        <delete file="${build.coverage.dir}/cobertura.ser"/>
        <cobertura-instrument todir="${build.coverage.dir}/classes"
            datafile="${build.coverage.dir}/cobertura.ser">
171
            <fileset dir="${build.classes.dir}"
D
duke 已提交
172 173
               includes="**/*.class" excludes="**/resources/*.class"/>
        </cobertura-instrument>
174
    </target>
D
duke 已提交
175 176 177

    <target name="coverage-report" depends="-def-cobertura">
        <mkdir dir="${dist.coverage.dir}"/>
178
        <cobertura-report
D
duke 已提交
179 180 181
            srcdir="${src.classes.dir}"
            destdir="${dist.coverage.dir}"
            datafile="${build.coverage.dir}/cobertura.ser"/>
182 183 184
        <cobertura-report
            format="xml"
            srcdir="${src.classes.dir}"
D
duke 已提交
185 186 187
            destdir="${dist.coverage.dir}"
            datafile="${build.coverage.dir}/cobertura.ser"/>
    </target>
188

D
duke 已提交
189 190 191 192 193
    <!-- javac targets -->

    <target name="build-bootstrap-javac" depends="-def-build-bootstrap-tool">
        <build-bootstrap-tool name="javac" includes="${javac.includes}"/>
    </target>
194

D
duke 已提交
195 196 197
    <target name="build-classes-javac" depends="build-bootstrap-javac">
        <build-classes name="javac" includes="${javac.includes}"/>
    </target>
198

D
duke 已提交
199 200 201
    <target name="build-javac" depends="build-bootstrap-javac">
        <build-tool name="javac" includes="${javac.includes}"/>
    </target>
202

D
duke 已提交
203 204 205
    <target name="javadoc-javac" depends="build-javac,-def-javadoc-tool">
        <javadoc-tool name="javac" includes="${javac.includes}" options="${javadoc.jls3.option}"/>
    </target>
206

D
duke 已提交
207
    <target name="jtreg-javac" depends="build-javac,-def-jtreg">
208
        <jtreg-tool name="javac" tests="${javac.tests}"/>
D
duke 已提交
209
    </target>
210

D
duke 已提交
211 212 213
    <target name="findbugs-javac" depends="build-javac,-def-findbugs">
        <findbugs-tool name="javac"/>
    </target>
214

D
duke 已提交
215
    <target name="javac" depends="build-javac,jtreg-javac,findbugs-javac"/>
216

D
duke 已提交
217 218 219 220 221 222 223
    <!-- javadoc targets -->

    <target name="build-bootstrap-javadoc" depends="build-bootstrap-javac">
        <build-bootstrap-tool name="javadoc"
                              includes="${javadoc.includes}"
                              jarclasspath="javac.jar doclets.jar"/>
    </target>
224

D
duke 已提交
225 226 227
    <target name="build-classes-javadoc" depends="build-classes-javac">
        <build-classes name="javadoc" includes="${javadoc.includes}"/>
    </target>
228

D
duke 已提交
229 230 231 232 233
    <target name="build-javadoc" depends="build-javac">
        <build-tool name="javadoc"
                    includes="${javadoc.includes}"
                    jarclasspath="javac.jar doclets.jar"/>
    </target>
234

D
duke 已提交
235 236 237
    <target name="javadoc-javadoc" depends="build-javadoc,-def-javadoc-tool">
        <javadoc-tool name="javadoc" includes="${javadoc.includes}"/>
    </target>
238

D
duke 已提交
239
    <target name="jtreg-javadoc" depends="build-javadoc,-def-jtreg">
240
        <jtreg-tool name="javadoc" tests="${javadoc.tests}"/>
D
duke 已提交
241
    </target>
242

D
duke 已提交
243 244 245
    <target name="findbugs-javadoc" depends="build-javadoc,-def-findbugs">
        <findbugs-tool name="javadoc"/>
    </target>
246

D
duke 已提交
247
    <target name="javadoc" depends="build-javadoc,jtreg-javadoc,findbugs-javadoc"/>
248

D
duke 已提交
249 250 251 252 253 254 255 256
    <!-- doclets targets -->

    <target name="build-bootstrap-doclets" depends="build-bootstrap-javadoc,-def-build-bootstrap-jar">
        <build-bootstrap-jar name="doclets"
                              includes="${doclets.includes}"
                              jarmainclass="com.sun.tools.javadoc.Main"
                              jarclasspath="javadoc.jar"/>
    </target>
257

D
duke 已提交
258 259 260
    <target name="build-classes-doclets" depends="build-classes-javadoc">
        <build-classes name="doclets" includes="${doclets.includes}"/>
    </target>
261

D
duke 已提交
262 263 264 265 266 267 268 269
    <target name="build-doclets" depends="build-javadoc">
        <!-- just jar, no bin for doclets -->
        <build-jar name="doclets"
                    includes="${doclets.includes}"
                    jarclasspath="javadoc.jar"/>
    </target>

    <!-- (no javadoc for doclets) -->
270

D
duke 已提交
271
    <target name="jtreg-doclets" depends="build-doclets,-def-jtreg">
272
        <jtreg-tool name="doclets" tests="${doclets.tests}"/>
D
duke 已提交
273
    </target>
274

D
duke 已提交
275 276 277
    <target name="findbugs-doclets" depends="build-doclets,-def-findbugs">
        <findbugs-tool name="doclets"/>
    </target>
278

D
duke 已提交
279
    <target name="doclets" depends="build-doclets,jtreg-doclets,findbugs-doclets"/>
280

D
duke 已提交
281 282 283 284 285 286 287
    <!-- javah targets -->

    <target name="build-bootstrap-javah" depends="build-bootstrap-javadoc">
        <build-bootstrap-tool name="javah"
                              includes="${javah.includes}"
                              jarclasspath="javadoc.jar doclets.jar javac.jar"/>
    </target>
288

289
    <target name="build-javah" depends="build-javac">
D
duke 已提交
290 291
        <build-tool name="javah"
                    includes="${javah.includes}"
292
                    jarclasspath="javac.jar"/>
D
duke 已提交
293
    </target>
294

D
duke 已提交
295 296 297
    <target name="build-classes-javah" depends="build-classes-javadoc">
        <build-classes name="javah" includes="${javah.includes}"/>
    </target>
298

D
duke 已提交
299 300 301
    <!-- (no javadoc for javah) -->

    <target name="jtreg-javah" depends="build-javah,-def-jtreg">
302
        <jtreg-tool name="javah" tests="${javah.tests}"/>
D
duke 已提交
303
    </target>
304

D
duke 已提交
305 306 307
    <target name="findbugs-javah" depends="build-javah,-def-findbugs">
        <findbugs-tool name="javah"/>
    </target>
308

D
duke 已提交
309
    <target name="javah" depends="build-javah,jtreg-javah,findbugs-javah"/>
310

D
duke 已提交
311 312 313 314 315 316 317
    <!-- javap targets -->

    <target name="build-bootstrap-javap" depends="-def-build-bootstrap-tool">
        <build-bootstrap-tool name="javap"
                              includes="${javap.includes}"
                              jarmainclass="sun.tools.javap.Main"/>
    </target>
318

319
    <target name="build-classes-javap" depends="build-classes-javac">
D
duke 已提交
320 321
        <build-classes name="javap" includes="${javap.includes}"/>
    </target>
322

323
    <target name="build-javap" depends="build-javac">
D
duke 已提交
324 325
        <build-tool name="javap"
                    includes="${javap.includes}"
J
jjg 已提交
326
                    jarmainclass="com.sun.tools.javap.Main"
327
                    jarclasspath="javac.jar"/>
D
duke 已提交
328
    </target>
329

D
duke 已提交
330 331 332
    <!-- (no javadoc for javap) -->

    <target name="jtreg-javap" depends="build-javap,-def-jtreg">
333
        <jtreg-tool name="javap" tests="${javap.tests}"/>
D
duke 已提交
334
    </target>
335

D
duke 已提交
336 337 338
    <target name="findbugs-javap" depends="build-javap,-def-findbugs">
        <findbugs-tool name="javap"/>
    </target>
339

D
duke 已提交
340
    <target name="javap" depends="build-javap,jtreg-javap,findbugs-javap"/>
341

D
duke 已提交
342
    <!-- apt targets -->
343

D
duke 已提交
344 345 346 347 348
    <target name="build-bootstrap-apt" depends="build-bootstrap-javac">
        <build-bootstrap-tool name="apt"
                              includes="${apt.includes}"
                              jarclasspath="javac.jar"/>
    </target>
349

D
duke 已提交
350 351 352 353 354
    <target name="build-apt" depends="build-javac">
        <build-tool name="apt"
                    includes="${apt.includes}"
                    jarclasspath="javac.jar"/>
    </target>
355

D
duke 已提交
356 357 358
    <target name="build-classes-apt" depends="build-classes-javac">
        <build-classes name="apt" includes="${apt.includes}"/>
    </target>
359

D
duke 已提交
360 361 362
    <target name="javadoc-apt" depends="build-apt,-def-javadoc-tool">
        <javadoc-tool name="apt" includes="${apt.includes}"/>
    </target>
363 364


D
duke 已提交
365
    <target name="jtreg-apt" depends="build-apt,-def-jtreg">
366
        <jtreg-tool name="apt" tests="${apt.tests}"/>
D
duke 已提交
367
    </target>
368

D
duke 已提交
369 370 371
    <target name="findbugs-apt" depends="build-apt,-def-findbugs">
        <findbugs-tool name="apt"/>
    </target>
372

D
duke 已提交
373 374 375
    <target name="apt" depends="build-apt,jtreg-apt,findbugs-apt"/>

    <!-- Check targets -->
376

D
duke 已提交
377 378 379
    <target name="-check-boot.java.home" depends="-def-check">
        <check name="bootstrap java" property="boot.java.home" marker="${java.marker}"/>
    </target>
380

D
duke 已提交
381 382 383
    <target name="-check-target.java.home" depends="-def-check">
        <check name="target java" property="target.java.home" marker="${java.marker}"/>
    </target>
384

D
duke 已提交
385 386 387
    <target name="-check-cobertura.home" depends="-def-check">
        <check name="cobertura" property="cobertura.home" marker="cobertura.jar"/>
    </target>
388

D
duke 已提交
389 390 391
    <target name="-check-findbugs.home" depends="-def-check">
        <check name="findbugs" property="findbugs.home" marker="lib/findbugs.jar"/>
    </target>
392

D
duke 已提交
393 394 395
    <target name="-check-jtreg.home" depends="-def-check">
        <check name="jtreg" property="jtreg.home" marker="lib/jtreg.jar"/>
    </target>
396

D
duke 已提交
397 398 399 400 401 402 403 404 405 406 407
    <!-- Ant macro and preset defs -->

    <target name="-def-build-tool" depends="-def-build-jar">
        <macrodef name="build-tool">
            <attribute name="name"/>
            <attribute name="includes"/>
            <attribute name="excludes" default="**/package-info.java"/>
            <attribute name="bin.dir" default="${dist.bin.dir}"/>
            <attribute name="classes.dir" default="${build.classes.dir}"/>
            <attribute name="gensrc.dir" default="${build.gensrc.dir}"/>
            <attribute name="lib.dir" default="${dist.lib.dir}"/>
J
jjg 已提交
408
            <attribute name="java" default="${launcher.java}"/>
409
            <attribute name="javac.bootclasspath" default="${build.bootstrap.dir}/classes"/>
410
            <attribute name="javac.java.home" default="${boot.java.home}"/>
411
            <attribute name="javac.source" default="${javac.source}"/>
D
duke 已提交
412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429
            <attribute name="javac.target" default="${javac.target}"/>
            <attribute name="jarmainclass" default="com.sun.tools.@{name}.Main"/>
            <attribute name="jarclasspath" default=""/>
            <attribute name="release" default="${release}"/>
            <attribute name="full.version" default="${full.version}"/>
            <sequential>
                <build-jar
                    name="@{name}"
                    gensrc.dir="@{gensrc.dir}"
                    classes.dir="@{classes.dir}"
                    lib.dir="@{lib.dir}"
                    includes="@{includes}"
                    excludes="@{excludes}"
                    jarmainclass="@{jarmainclass}"
                    jarclasspath="@{jarclasspath}"
                    release="@{release}"
                    full.version="@{full.version}"
                    javac.bootclasspath="@{javac.bootclasspath}"
430
                    javac.source="@{javac.source}"
D
duke 已提交
431 432 433 434 435
                    javac.target="@{javac.target}"
                />
                <mkdir dir="@{bin.dir}"/>
                <copy file="${src.bin.dir}/launcher.sh-template" tofile="@{bin.dir}/@{name}">
                    <filterset begintoken="#" endtoken="#">
436 437
                        <filter token="PROGRAM" value="@{name}"/>
                        <filter token="TARGET_JAVA" value="@{java}"/>
D
duke 已提交
438 439 440 441 442 443 444 445 446 447 448 449 450 451 452
                    </filterset>
                </copy>
                <chmod file="@{bin.dir}/@{name}" perm="ugo+rx"/>
            </sequential>
        </macrodef>
    </target>

    <target name="-def-build-jar" depends="-def-build-classes">
        <macrodef name="build-jar">
            <attribute name="name"/>
            <attribute name="includes"/>
            <attribute name="excludes" default="**/package-info.java"/>
            <attribute name="classes.dir" default="${build.classes.dir}"/>
            <attribute name="gensrc.dir" default="${build.gensrc.dir}"/>
            <attribute name="lib.dir" default="${dist.lib.dir}"/>
453
            <attribute name="javac.bootclasspath" default="${build.bootstrap.dir}/classes"/>
454
            <attribute name="javac.java.home" default="${boot.java.home}"/>
455
            <attribute name="javac.source" default="${javac.source}"/>
D
duke 已提交
456 457 458 459 460 461 462 463 464 465 466 467 468 469 470
            <attribute name="javac.target" default="${javac.target}"/>
            <attribute name="jarmainclass" default="com.sun.tools.@{name}.Main"/>
            <attribute name="jarclasspath" default=""/>
            <attribute name="release" default="${release}"/>
            <attribute name="full.version" default="${full.version}"/>
            <sequential>
                <build-classes
                    name="@{name}"
                    gensrc.dir="@{gensrc.dir}"
                    classes.dir="@{classes.dir}"
                    includes="@{includes}"
                    excludes="@{excludes}"
                    release="@{release}"
                    full.version="@{full.version}"
                    javac.bootclasspath="@{javac.bootclasspath}"
471
                    javac.source="@{javac.source}"
D
duke 已提交
472 473 474 475 476 477
                    javac.target="@{javac.target}"
                />
                <mkdir dir="@{lib.dir}"/>
                <jar destfile="@{lib.dir}/@{name}.jar"
                     basedir="@{classes.dir}"
                     includes="@{includes}">
478
                    <manifest>
D
duke 已提交
479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494
                        <attribute name="Main-Class" value="@{jarmainclass}"/>
                        <attribute name="Class-Path" value="@{jarclasspath}"/>
                    </manifest>
                </jar>
            </sequential>
        </macrodef>
    </target>

    <target name="-def-build-classes" depends="-def-pcompile">
        <macrodef name="build-classes">
            <attribute name="name"/>
            <attribute name="includes"/>
            <attribute name="excludes" default="**/package-info.java"/>
            <attribute name="classes.dir" default="${build.classes.dir}"/>
            <attribute name="gensrc.dir" default="${build.gensrc.dir}"/>
            <attribute name="javac.bootclasspath" default="${build.bootstrap.dir}/classes"/>
495
            <attribute name="javac.java.home" default="${boot.java.home}"/>
496
            <attribute name="javac.source" default="${javac.source}"/>
D
duke 已提交
497 498 499 500 501 502 503 504 505 506
            <attribute name="javac.target" default="${javac.target}"/>
            <attribute name="release" default="${release}"/>
            <attribute name="full.version" default="${full.version}"/>
            <sequential>
                <mkdir dir="@{gensrc.dir}"/>
                <mkdir dir="@{classes.dir}"/>
                <pcompile srcdir="${src.classes.dir}"
                          destdir="@{gensrc.dir}"
                          includes="@{includes}"/>
                <copy todir="@{gensrc.dir}">
507
                    <fileset dir="${src.classes.dir}" includes="@{includes}"/>
D
duke 已提交
508 509 510 511 512 513 514 515 516 517 518
                    <globmapper from="*.properties-template" to="*.properties"/>
                    <filterset begintoken="$(" endtoken=")">
                        <filter token="JDK_VERSION" value="${jdk.version}"/>
                        <filter token="RELEASE" value="@{release}"/>
                        <filter token="FULL_VERSION" value="@{full.version}"/>
                    </filterset>
                </copy>
                <pcompile srcdir="@{gensrc.dir}"
                          destdir="@{gensrc.dir}"
                          includes="**/*.properties"/>
                <javac fork="true"
519
                       executable="@{javac.java.home}/bin/javac"
D
duke 已提交
520 521 522 523 524
                       srcdir="@{gensrc.dir}"
                       destdir="@{classes.dir}"
                       includes="@{includes}"
                       sourcepath=""
                       includeAntRuntime="no"
525
                       source="@{javac.source}"
D
duke 已提交
526 527 528 529 530 531
                       target="@{javac.target}">
                    <compilerarg value="-J-Xbootclasspath/p:@{javac.bootclasspath}"/>
                    <compilerarg line="${javac.version.opt}"/>
                    <compilerarg line="-Xlint"/>
                </javac>
                <javac fork="true"
532
                       executable="@{javac.java.home}/bin/javac"
D
duke 已提交
533 534 535 536 537 538
                       srcdir="${src.classes.dir}"
                       destdir="@{classes.dir}"
                       includes="@{includes}"
                       excludes="@{excludes}"
                       sourcepath=""
                       includeAntRuntime="no"
539
                       source="@{javac.source}"
D
duke 已提交
540
                       target="@{javac.target}"
541
                       debug="${javac.debug}"
D
duke 已提交
542 543 544 545 546 547 548 549
                       debuglevel="${javac.debuglevel}">
                    <compilerarg value="-J-Xbootclasspath/p:@{javac.bootclasspath}"/>
                    <compilerarg value="-Xbootclasspath/p:@{classes.dir}"/>
                    <compilerarg line="${javac.no.jdk.warnings}"/>
                    <compilerarg line="${javac.version.opt}"/>
                    <compilerarg line="${javac.lint.opts}"/>
                </javac>
                <copy todir="@{classes.dir}">
550
                    <fileset dir="${src.classes.dir}">
D
duke 已提交
551 552 553 554 555 556 557 558 559 560
                        <include name="@{includes}"/>
                        <exclude name="**/*.java"/>
                        <exclude name="**/*.properties"/>
                        <exclude name="**/*-template"/>
                        <exclude name="**/package.html"/>
                    </fileset>
                </copy>
            </sequential>
        </macrodef>
    </target>
561

D
duke 已提交
562 563 564
    <target name="-def-build-bootstrap-tool" depends="-check-boot.java.home,-def-build-tool">
        <presetdef name="build-bootstrap-tool">
            <build-tool
565
                javac.source="${boot.javac.source}"
D
duke 已提交
566 567 568 569 570
                javac.target="${boot.javac.target}"
                gensrc.dir="${build.bootstrap.dir}/gensrc"
                classes.dir="${build.bootstrap.dir}/classes"
                bin.dir="${build.bootstrap.dir}/bin"
                lib.dir="${build.bootstrap.dir}/lib"
571
                java="${boot.java}"
D
duke 已提交
572 573 574 575 576
                javac.bootclasspath=""
                release="${bootstrap.release}"
                full.version="${bootstrap.full.version}"/>
        </presetdef>
    </target>
577

D
duke 已提交
578 579 580
    <target name="-def-build-bootstrap-jar" depends="-def-build-jar">
        <presetdef name="build-bootstrap-jar">
            <build-jar
581
                javac.source="${boot.javac.source}"
D
duke 已提交
582 583 584 585 586 587 588 589 590
                javac.target="${boot.javac.target}"
                gensrc.dir="${build.bootstrap.dir}/gensrc"
                classes.dir="${build.bootstrap.dir}/classes"
                lib.dir="${build.bootstrap.dir}/lib"
                javac.bootclasspath=""
                release="${bootstrap.release}"
                full.version="${bootstrap.full.version}"/>
        </presetdef>
    </target>
591

D
duke 已提交
592 593
    <target name="-def-pcompile">
        <mkdir dir="${build.toolclasses.dir}"/>
594
        <javac fork="true"
595 596
               source="${boot.javac.source}"
               target="${boot.javac.target}"
597 598
               executable="${boot.java.home}/bin/javac"
               srcdir="${make.tools.dir}/CompileProperties"
D
duke 已提交
599 600 601
               destdir="${build.toolclasses.dir}/"
               classpath="${ant.home}/lib/ant.jar"/>
        <taskdef name="pcompile"
602
                 classname="CompilePropertiesTask"
D
duke 已提交
603 604
                 classpath="${build.toolclasses.dir}/"/>
    </target>
605

D
duke 已提交
606 607 608 609 610 611 612 613 614 615 616
    <target name="-def-javadoc-tool" depends="-check-target.java.home">
        <macrodef name="javadoc-tool">
            <attribute name="name"/>
            <attribute name="includes"/>
            <attribute name="options" default=""/>
            <attribute name="source" default="1.5"/> <!-- FIXME -->
            <sequential>
                <property name="javadoc.options" value=""/> <!-- default, can be overridden per user or per project -->
                <!-- Note: even with this default value, includes
         from src.classes.dir get javadoc'd; see packageset below -->
                <property name="javadoc.packagenames" value="none"/> <!-- default, can be overridden per user or per project -->
617
                <javadoc
D
duke 已提交
618
                    executable="${target.java.home}/bin/javadoc"
619
                    destdir="${build.javadoc.dir}/@{name}"
D
duke 已提交
620
                    source="@{source}"
621 622
                    windowtitle="UNOFFICIAL"
                    failonerror="true"
D
duke 已提交
623
                    use="true"
624
                    author="false"
D
duke 已提交
625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652
                    version="false"
                    packagenames="${javadoc.packagenames}" >
                    <header><![CDATA[<strong>Unofficial Javadoc</strong> generated from developer sources for preview purposes only]]></header>
                    <arg line="@{options}"/>
                    <bootclasspath>
                        <path location="${build.classes.dir}"/>
                        <path location="${target.java.home}/jre/lib/rt.jar"/>
                    </bootclasspath>
                    <sourcepath>
                        <pathelement location="${src.classes.dir}"/>
                    </sourcepath>
                    <!-- XXX just <fileset> (restricted further to **/*.java) and no <packageset> -->
                    <!-- means that {@link some.package} will not work, which is no good. -->
                    <!-- (It correctly skips excluded single classes, but not if packageset is also included, -->
                    <!-- which also causes duplicates in the class index for included files.) -->
                    <packageset dir="${src.classes.dir}" includes="@{includes}">
                        <or>
                            <filename name="java/"/>
                            <filename name="javax/"/>
                            <filename name="com/sun/javadoc/"/>
                            <filename name="com/sun/mirror/"/>
                            <filename name="com/sun/source/"/>
                        </or>
                    </packageset>
                </javadoc>
            </sequential>
        </macrodef>
    </target>
653 654

    <target name="-def-jtreg" unless="jtreg.defined" depends="-check-jtreg.home,-check-target.java.home">
D
duke 已提交
655 656 657 658 659 660 661 662 663 664
        <taskdef name="jtreg" classname="com.sun.javatest.regtest.Main$$Ant">
            <classpath>
                <pathelement location="${jtreg.home}/lib/jtreg.jar"/>
                <pathelement location="${jtreg.home}/lib/javatest.jar"/>
            </classpath>
        </taskdef>
        <macrodef name="jtreg-tool">
            <attribute name="name"/>
            <attribute name="tests"/>
            <attribute name="jdk" default="${target.java.home}"/>
665
            <attribute name="samevm" default="true"/>
D
duke 已提交
666 667 668 669 670 671 672
            <attribute name="verbose" default="summary"/>
            <attribute name="options" default=""/>
            <attribute name="keywords" default="-keywords:!ignore"/>
            <attribute name="jpda.jvmargs" default=""/>
            <sequential>
                <property name="coverage.options" value=""/>    <!-- default -->
                <property name="coverage.classpath" value=""/>    <!-- default -->
673
                <jtreg
D
duke 已提交
674
                    dir="${test.dir}"
675
                    workDir="${build.jtreg.dir}/@{name}/work"
D
duke 已提交
676 677 678 679 680 681 682 683 684 685
                    reportDir="${build.jtreg.dir}/@{name}/report"
                    jdk="@{jdk}"
                    samevm="@{samevm}" verbose="@{verbose}"
                    failonerror="false" resultproperty="jtreg.@{name}.result"
                    javacoptions="-g"
                    vmoptions="${coverage.options} -Xbootclasspath/p:${coverage.classpath}:${build.classes.dir} @{jpda.jvmargs}">
                    <arg line="@{keywords}"/>
                    <arg line="@{options}"/>
                    <arg line="@{tests}"/>
                </jtreg>
686
                <!-- the next two properties are for convenience, when only
D
duke 已提交
687 688
                     a single instance of jtreg will be invoked. -->
                <condition property="jtreg.passed">
689
                    <equals arg1="${jtreg.@{name}.result}" arg2="0"/>
D
duke 已提交
690 691 692 693 694 695 696 697 698 699 700 701 702 703
                </condition>
                <property name="jtreg.report" value="${build.jtreg.dir}/@{name}/report"/>
            </sequential>
        </macrodef>
        <property name="jtreg.defined" value="true"/>
    </target>

    <target name="-def-cobertura" depends="-check-cobertura.home">
        <path id="cobertura.classpath">
            <fileset dir="${cobertura.home}">
                <include name="cobertura.jar"/>
                <include name="lib/**/*.jar"/>
            </fileset>
        </path>
704
        <taskdef classpathref="cobertura.classpath" resource="tasks.properties"/>
D
duke 已提交
705
    </target>
706

D
duke 已提交
707 708 709 710 711 712 713 714 715 716 717 718
    <target name="-def-findbugs" unless="findbugs.defined" depends="-check-findbugs.home">
        <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask">
            <classpath>
                <pathelement location="${findbugs.home}/lib/findbugs.jar"/>
            </classpath>
        </taskdef>
        <macrodef name="findbugs-tool">
            <attribute name="name"/>
            <attribute name="output" default="emacs"/>
            <attribute name="outputFile" default=""/>
            <attribute name="reportLevel" default="high"/>
            <sequential>
719
                <findbugs
D
duke 已提交
720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739
                    home="${findbugs.home}"
                    output="@{output}"
                    outputFile="@{outputFile}"
                    reportLevel="@{reportLevel}"
                    failOnError="false"
                    errorProperty="findbugs.@{name}.errors"
                    warningsProperty="findbugs.@{name}.warnings"
                    jvmargs="-Xmx512M" >
                    <class location="${dist.dir}/lib/@{name}.jar"/>
                    <auxClasspath>
                        <pathelement location="${build.classes.dir}"/>
                    </auxClasspath>
                    <sourcePath>
                        <pathelement location="${src.classes.dir}"/>
                    </sourcePath>
                </findbugs>
            </sequential>
        </macrodef>
        <property name="findbugs.defined" value="true"/>
    </target>
740

D
duke 已提交
741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765
    <target name="-def-check">
        <macrodef name="check">
            <attribute name="name"/>
            <attribute name="property"/>
            <attribute name="marker"/>
            <sequential>
                <fail message="Cannot locate @{name}: please set @{property} to its location">
                    <condition>
                        <not>
                            <isset property="@{property}"/>
                        </not>
                    </condition>
                </fail>
                <fail message="@{name} is not installed in ${@{property}}">
                    <condition>
                        <not>
                            <available file="${@{property}}/@{marker}"/>
                        </not>
                    </condition>
                </fail>
            </sequential>
        </macrodef>
    </target>

    <!-- standard JDK target -->
766
    <target name="sanity"
D
duke 已提交
767 768 769 770 771 772 773 774 775 776 777 778 779 780 781
        description="display settings of congiguration values">
        <echo level="info">ant.home = ${ant.home}</echo>
        <echo level="info">boot.java.home = ${boot.java.home}</echo>
        <echo level="info">target.java.home = ${target.java.home}</echo>
        <echo level="info">jtreg.home = ${jtreg.home}</echo>
        <echo level="info">findbugs.home = ${findbugs.home}</echo>
    </target>

    <!-- useful debugging targets -->
    <target name="diagnostics">
        <diagnostics/>
    </target>

    <target name="post-sanity" depends="-def-jtreg,sanity,build"
        description="perform basic validation after a standard build">
782
        <jtreg
D
duke 已提交
783
            dir="make/test"
784
            workDir="${build.jtreg.dir}/post-sanity/work"
D
duke 已提交
785 786 787 788 789
            reportDir="${build.jtreg.dir}/post-sanity/report"
            jdk="${target.java.home}"
            verbose="summary"
            failonerror="false" resultproperty="jtreg.post-sanity.result">
        </jtreg>
790

D
duke 已提交
791 792 793
    </target>
</project>