build.xml revision 578:d33b91f360fc
1<?xml version="1.0" encoding="UTF-8"?> 2<!-- 3 Copyright (c) 2007, 2009, 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 jvmargs="-Xmx512M"> 279 <class location="${build.classes.dir}"/> 280 <sourcePath> 281 <pathelement location="${src.classes.dir}"/> 282 </sourcePath> 283 </findbugs> 284 <exec executable="sh"> 285 <arg value="${findbugs.home}/bin/convertXmlToText"/> 286 <arg value="-longBugCodes"/> 287 <arg value="-html:${findbugs.home}/src/xsl/fancy.xsl"/> 288 <arg value="${dist.findbugs.dir}/findbugs.xml"/> 289 <redirector output="${dist.findbugs.dir}/findbugs.html"/> 290 </exec> 291 </target> 292 293 <target name="coverage" depends="-def-cobertura,build-all-classes,instrument-classes,jtreg,coverage-report"/> 294 295 <target name="instrument-classes" depends="-def-cobertura"> 296 <!-- only define the following property when we want coverage info --> 297 <path id="coverage.classpath"> 298 <pathelement location="${build.coverage.dir}/classes"/> 299 <path refid="cobertura.classpath"/> 300 </path> 301 <property name="coverage.options" value="-Dnet.sourceforge.cobertura.datafile=${build.coverage.dir}/cobertura.ser"/> 302 <property name="coverage.classpath" refid="coverage.classpath"/> 303 <mkdir dir="${build.coverage.dir}/classes"/> 304 <delete file="${build.coverage.dir}/cobertura.ser"/> 305 <cobertura-instrument todir="${build.coverage.dir}/classes" 306 datafile="${build.coverage.dir}/cobertura.ser"> 307 <fileset dir="${build.classes.dir}" 308 includes="**/*.class" excludes="**/resources/*.class"/> 309 </cobertura-instrument> 310 </target> 311 312 <target name="coverage-report" depends="-def-cobertura"> 313 <mkdir dir="${dist.coverage.dir}"/> 314 <cobertura-report 315 srcdir="${src.classes.dir}" 316 destdir="${dist.coverage.dir}" 317 datafile="${build.coverage.dir}/cobertura.ser"/> 318 <cobertura-report 319 format="xml" 320 srcdir="${src.classes.dir}" 321 destdir="${dist.coverage.dir}" 322 datafile="${build.coverage.dir}/cobertura.ser"/> 323 </target> 324 325 326 <!-- 327 **** Debugging/diagnostic targets. 328 --> 329 330 <!-- standard JDK target --> 331 <target name="sanity" 332 description="display settings of configuration values"> 333 <echo level="info">ant.home = ${ant.home}</echo> 334 <echo level="info">boot.java.home = ${boot.java.home}</echo> 335 <echo level="info">target.java.home = ${target.java.home}</echo> 336 <echo level="info">jtreg.home = ${jtreg.home}</echo> 337 <echo level="info">findbugs.home = ${findbugs.home}</echo> 338 </target> 339 340 <target name="post-sanity" depends="-def-jtreg,sanity,build" 341 description="perform basic validation after a standard build"> 342 <jtreg 343 dir="make/test" 344 workDir="${build.jtreg.dir}/post-sanity/work" 345 reportDir="${build.jtreg.dir}/post-sanity/report" 346 jdk="${target.java.home}" 347 verbose="summary" 348 failonerror="false" resultproperty="jtreg.post-sanity.result"> 349 </jtreg> 350 </target> 351 352 <!-- use vizant tool to generate graphical image of this Ant file.--> 353 <target name="vizant" depends="-def-vizant"> 354 <mkdir dir="${build.dir}"/> 355 <echo message="Generating ${build.dir}/build.dot"/> 356 <vizant antfile="${make.dir}/build.xml" outfile="${build.dir}/build.dot"/> 357 <echo message="Generating ${build.dir}/build.png"/> 358 <exec executable="${dot}" > 359 <arg value="-Tpng"/> 360 <arg value="-o"/> 361 <arg file="${build.dir}/build.png"/> 362 <arg file="${build.dir}/build.dot"/> 363 </exec> 364 </target> 365 366 <target name="check-import.jdk"> 367 <echo message="import.jdk: ${import.jdk}"/> 368 <echo message="import.jdk.jar: ${import.jdk.jar}"/> 369 <echo message="import.jdk.src.dir: ${import.jdk.src.dir}"/> 370 </target> 371 372 <target name="diagnostics"> 373 <diagnostics/> 374 </target> 375 376 377 <!-- 378 **** javac targets. 379 --> 380 381 <target name="build-bootstrap-javac" 382 depends="-def-build-bootstrap-classes,-def-build-bootstrap-jar,-def-build-bootstrap-tool"> 383 <build-bootstrap-classes includes="${javac.includes}"/> 384 <build-bootstrap-jar name="javac" includes="${javac.includes}"/> 385 <build-bootstrap-tool name="javac"/> 386 </target> 387 388 <target name="build-classes-javac" depends="build-bootstrap-javac,-create-import-jdk-stubs"> 389 <build-classes includes="${javac.includes}"/> 390 </target> 391 392 <target name="build-javac" depends="build-classes-javac"> 393 <build-jar name="javac" includes="${javac.includes}"/> 394 <build-tool name="javac"/> 395 </target> 396 397 <target name="javadoc-javac" depends="build-javac,-def-javadoc-tool"> 398 <javadoc-tool name="javac" includes="${javac.includes}" options="${javadoc.jls3.option}"/> 399 </target> 400 401 <target name="jtreg-javac" depends="build-javac,build-javap,-def-jtreg"> 402 <jtreg-tool name="javac" tests="${javac.tests}"/> 403 </target> 404 405 <target name="findbugs-javac" depends="build-javac,-def-findbugs"> 406 <findbugs-tool name="javac"/> 407 </target> 408 409 <target name="javac" depends="build-javac,jtreg-javac,findbugs-javac"/> 410 411 412 <!-- 413 **** javadoc targets. 414 --> 415 416 <target name="build-bootstrap-javadoc" depends="build-bootstrap-javac"> 417 <build-bootstrap-classes includes="${javadoc.includes}"/> 418 <build-bootstrap-jar name="javadoc" includes="${javadoc.includes}" 419 jarclasspath="javac.jar doclets.jar"/> 420 <build-bootstrap-tool name="javadoc"/> 421 </target> 422 423 <target name="build-classes-javadoc" depends="build-classes-javac"> 424 <build-classes includes="${javadoc.includes}"/> 425 </target> 426 427 <target name="build-javadoc" depends="build-javac,build-classes-javadoc"> 428 <build-jar name="javadoc" includes="${javadoc.includes}" 429 jarclasspath="javac.jar doclets.jar"/> 430 <build-tool name="javadoc"/> 431 </target> 432 433 <target name="javadoc-javadoc" depends="build-javadoc,-def-javadoc-tool"> 434 <javadoc-tool name="javadoc" includes="${javadoc.includes}"/> 435 </target> 436 437 <target name="jtreg-javadoc" depends="build-javadoc,-def-jtreg"> 438 <jtreg-tool name="javadoc" tests="${javadoc.tests}"/> 439 </target> 440 441 <target name="findbugs-javadoc" depends="build-javadoc,-def-findbugs"> 442 <findbugs-tool name="javadoc"/> 443 </target> 444 445 <target name="javadoc" depends="build-javadoc,jtreg-javadoc,findbugs-javadoc"/> 446 447 448 <!-- 449 **** doclets targets. 450 --> 451 452 <target name="build-bootstrap-doclets" depends="build-bootstrap-javadoc,-def-build-bootstrap-jar"> 453 <build-bootstrap-classes includes="${doclets.includes}"/> 454 <build-bootstrap-jar name="doclets" includes="${doclets.includes}" 455 jarmainclass="com.sun.tools.javadoc.Main" 456 jarclasspath="javadoc.jar"/> 457 </target> 458 459 <target name="build-classes-doclets" depends="build-classes-javadoc"> 460 <build-classes includes="${doclets.includes}"/> 461 </target> 462 463 <target name="build-doclets" depends="build-javadoc,build-classes-doclets"> 464 <!-- just jar, no bin for doclets --> 465 <build-jar name="doclets" includes="${doclets.includes}" jarclasspath="javadoc.jar"/> 466 </target> 467 468 <!-- (no javadoc for doclets) --> 469 470 <target name="jtreg-doclets" depends="build-doclets,-def-jtreg"> 471 <jtreg-tool name="doclets" tests="${doclets.tests}"/> 472 </target> 473 474 <target name="findbugs-doclets" depends="build-doclets,-def-findbugs"> 475 <findbugs-tool name="doclets"/> 476 </target> 477 478 <target name="doclets" depends="build-doclets,jtreg-doclets,findbugs-doclets"/> 479 480 481 <!-- 482 **** javah targets. 483 --> 484 485 <target name="build-bootstrap-javah" depends="build-bootstrap-javadoc"> 486 <build-bootstrap-classes includes="${javah.includes}"/> 487 <build-bootstrap-jar name="javah" includes="${javah.includes}" 488 jarclasspath="javadoc.jar doclets.jar javac.jar"/> 489 <build-bootstrap-tool name="javah"/> 490 </target> 491 492 <target name="build-javah" depends="build-javac,build-classes-javah"> 493 <build-jar name="javah" includes="${javah.includes}" jarclasspath="javac.jar"/> 494 <build-tool name="javah"/> 495 </target> 496 497 <target name="build-classes-javah" depends="build-classes-javadoc"> 498 <build-classes includes="${javah.includes}"/> 499 </target> 500 501 <!-- (no javadoc for javah) --> 502 503 <target name="jtreg-javah" depends="build-javah,-def-jtreg"> 504 <jtreg-tool name="javah" tests="${javah.tests}"/> 505 </target> 506 507 <target name="findbugs-javah" depends="build-javah,-def-findbugs"> 508 <findbugs-tool name="javah"/> 509 </target> 510 511 <target name="javah" depends="build-javah,jtreg-javah,findbugs-javah"/> 512 513 514 <!-- 515 **** javap targets. 516 --> 517 518 <target name="build-bootstrap-javap" 519 depends="-def-build-bootstrap-classes,-def-build-bootstrap-jar,-def-build-bootstrap-tool"> 520 <build-bootstrap-classes includes="${javap.includes}"/> 521 <build-bootstrap-jar name="javap" includes="${javap.includes}" 522 jarmainclass="sun.tools.javap.Main"/> 523 <build-bootstrap-tool name="javap"/> 524 </target> 525 526 <target name="build-classes-javap" depends="build-classes-javac"> 527 <build-classes includes="${javap.includes}"/> 528 </target> 529 530 <target name="build-javap" depends="build-javac,build-classes-javap"> 531 <build-jar name="javap" includes="${javap.includes}" 532 jarmainclass="com.sun.tools.javap.Main" 533 jarclasspath="javac.jar"/> 534 <build-tool name="javap"/> 535 </target> 536 537 <!-- (no javadoc for javap) --> 538 539 <target name="jtreg-javap" depends="build-javap,-def-jtreg"> 540 <jtreg-tool name="javap" tests="${javap.tests}"/> 541 </target> 542 543 <target name="findbugs-javap" depends="build-javap,-def-findbugs"> 544 <findbugs-tool name="javap"/> 545 </target> 546 547 <target name="javap" depends="build-javap,jtreg-javap,findbugs-javap"/> 548 549 550 <!-- 551 **** apt targets. 552 --> 553 554 <target name="build-bootstrap-apt" depends="build-bootstrap-javac"> 555 <build-bootstrap-classes includes="${apt.includes}"/> 556 <build-bootstrap-jar name="apt" includes="${apt.includes}" 557 jarclasspath="javac.jar"/> 558 <build-bootstrap-tool name="apt"/> 559 </target> 560 561 <target name="build-apt" depends="build-javac,build-classes-apt"> 562 <build-jar name="apt" includes="${apt.includes}" jarclasspath="javac.jar"/> 563 <build-tool name="apt"/> 564 </target> 565 566 <target name="build-classes-apt" depends="build-classes-javac"> 567 <build-classes includes="${apt.includes}"/> 568 </target> 569 570 <target name="javadoc-apt" depends="build-apt,-def-javadoc-tool"> 571 <javadoc-tool name="apt" includes="${apt.includes}"/> 572 </target> 573 574 575 <target name="jtreg-apt" depends="build-apt,-def-jtreg"> 576 <jtreg-tool name="apt" tests="${apt.tests}"/> 577 </target> 578 579 <target name="findbugs-apt" depends="build-apt,-def-findbugs"> 580 <findbugs-tool name="apt"/> 581 </target> 582 583 <target name="apt" depends="build-apt,jtreg-apt,findbugs-apt"/> 584 585 586 <!-- 587 **** Create import JDK stubs. 588 --> 589 590 <target name="-create-import-jdk-stubs" depends="-def-genstubs" if="require.import.jdk.stubs"> 591 <mkdir dir="${build.genstubs.dir}"/> 592 <genstubs 593 srcdir="${import.jdk.src.dir}" destdir="${build.genstubs.dir}" 594 includes="${import.jdk.stub.files}" 595 fork="true" classpath="${build.toolclasses.dir}:${build.bootstrap.dir}/classes:${ant.home}/lib/ant.jar" 596 /> 597 </target> 598 599 600 <!-- 601 **** Check targets. 602 **** "-check-*" targets check that a required property is set, and set to a reasonable value. 603 **** A user friendly message is generated if not, and the build exits. 604 --> 605 606 <target name="-check-boot.java.home" depends="-def-check"> 607 <check name="bootstrap java" property="boot.java.home" marker="${java.marker}"/> 608 </target> 609 610 <target name="-check-target.java.home" depends="-def-check"> 611 <check name="target java" property="target.java.home" marker="${java.marker}"/> 612 </target> 613 614 <target name="-check-cobertura.home" depends="-def-check"> 615 <check name="cobertura" property="cobertura.home" marker="cobertura.jar"/> 616 </target> 617 618 <target name="-check-findbugs.home" depends="-def-check"> 619 <check name="findbugs" property="findbugs.home" marker="lib/findbugs.jar"/> 620 </target> 621 622 <target name="-check-jtreg.home" depends="-def-check"> 623 <check name="jtreg" property="jtreg.home" marker="lib/jtreg.jar"/> 624 </target> 625 626 <target name="-check-vizant" depends="-def-check"> 627 <check name="vizant" property="vizant.jar"/> 628 <check name="dot" property="dot"/> 629 </target> 630 631 632 <!-- 633 **** Targets for Ant macro and task definitions. 634 --> 635 636 <target name="-def-build-tool"> 637 <macrodef name="build-tool"> 638 <attribute name="name"/> 639 <attribute name="bin.dir" default="${dist.bin.dir}"/> 640 <attribute name="java" default="${launcher.java}"/> 641 <sequential> 642 <mkdir dir="@{bin.dir}"/> 643 <copy file="${src.bin.dir}/launcher.sh-template" tofile="@{bin.dir}/@{name}"> 644 <filterset begintoken="#" endtoken="#"> 645 <filter token="PROGRAM" value="@{name}"/> 646 <filter token="TARGET_JAVA" value="@{java}"/> 647 </filterset> 648 </copy> 649 <chmod file="@{bin.dir}/@{name}" perm="ugo+rx"/> 650 </sequential> 651 </macrodef> 652 </target> 653 654 <target name="-def-build-jar"> 655 <macrodef name="build-jar"> 656 <attribute name="name"/> 657 <attribute name="includes"/> 658 <attribute name="classes.dir" default="${build.classes.dir}"/> 659 <attribute name="lib.dir" default="${dist.lib.dir}"/> 660 <attribute name="jarmainclass" default="com.sun.tools.@{name}.Main"/> 661 <attribute name="jarclasspath" default=""/> 662 <sequential> 663 <mkdir dir="@{lib.dir}"/> 664 <jar destfile="@{lib.dir}/@{name}.jar" 665 basedir="@{classes.dir}" 666 includes="@{includes}"> 667 <manifest> 668 <attribute name="Main-Class" value="@{jarmainclass}"/> 669 <attribute name="Class-Path" value="@{jarclasspath}"/> 670 </manifest> 671 </jar> 672 </sequential> 673 </macrodef> 674 </target> 675 676 <target name="-def-build-classes" depends="-def-pcompile"> 677 <macrodef name="build-classes"> 678 <attribute name="includes"/> 679 <attribute name="excludes" default="${exclude.files} **/package-info.java"/> 680 <attribute name="classes.dir" default="${build.classes.dir}"/> 681 <attribute name="gensrc.dir" default="${build.gensrc.dir}"/> 682 <attribute name="javac.bootclasspath" default="${build.bootstrap.dir}/classes"/> 683 <attribute name="bootclasspath.opt" default="${javac.bootclasspath.opt}"/> 684 <attribute name="classpath" default="${javac.classpath}"/> 685 <attribute name="sourcepath" default="${javac.sourcepath}"/> 686 <attribute name="java.home" default="${boot.java.home}"/> 687 <attribute name="source" default="${javac.source}"/> 688 <attribute name="target" default="${javac.target}"/> 689 <attribute name="release" default="${release}"/> 690 <attribute name="full.version" default="${full.version}"/> 691 <sequential> 692 <echo level="verbose" message="build-classes: excludes=@{excludes}"/> 693 <echo level="verbose" message="build-classes: bootclasspath.opt=@{bootclasspath.opt}"/> 694 <echo level="verbose" message="build-classes: classpath=@{classpath}"/> 695 <echo level="verbose" message="build-classes: sourcepath=@{sourcepath}"/> 696 <mkdir dir="@{gensrc.dir}"/> 697 <mkdir dir="@{classes.dir}"/> 698 <pcompile srcdir="${src.classes.dir}" 699 destdir="@{gensrc.dir}" 700 includes="@{includes}"/> 701 <copy todir="@{gensrc.dir}"> 702 <fileset dir="${src.classes.dir}" includes="@{includes}"/> 703 <globmapper from="*.properties-template" to="*.properties"/> 704 <filterset begintoken="$(" endtoken=")"> 705 <filter token="JDK_VERSION" value="${jdk.version}"/> 706 <filter token="RELEASE" value="@{release}"/> 707 <filter token="FULL_VERSION" value="@{full.version}"/> 708 </filterset> 709 </copy> 710 <pcompile srcdir="@{gensrc.dir}" 711 destdir="@{gensrc.dir}" 712 includes="**/*.properties"/> 713 <javac fork="true" 714 executable="@{java.home}/bin/javac" 715 srcdir="${src.classes.dir}:@{gensrc.dir}" 716 destdir="@{classes.dir}" 717 includes="@{includes}" 718 excludes="@{excludes}" 719 sourcepath="@{sourcepath}" 720 classpath="@{classpath}" 721 includeAntRuntime="no" 722 source="@{source}" 723 target="@{target}" 724 debug="${javac.debug}" 725 debuglevel="${javac.debuglevel}"> 726 <compilerarg value="-implicit:none"/> 727 <compilerarg value="-Xprefer:source"/> 728 <compilerarg value="-J-Xbootclasspath/p:@{javac.bootclasspath}"/> 729 <compilerarg line="@{bootclasspath.opt}"/> 730 <compilerarg line="${javac.no.jdk.warnings}"/> 731 <compilerarg line="${javac.version.opt}"/> 732 <compilerarg line="${javac.lint.opts}"/> 733 </javac> 734 <copy todir="@{classes.dir}" includeemptydirs="false"> 735 <fileset dir="${src.classes.dir}" includes="@{includes}" excludes="@{excludes}"> 736 <exclude name="**/*.java"/> 737 <exclude name="**/*.properties"/> 738 <exclude name="**/*-template"/> 739 <exclude name="**/package.html"/> 740 </fileset> 741 </copy> 742 </sequential> 743 </macrodef> 744 </target> 745 746 <target name="-def-build-bootstrap-tool" depends="-check-boot.java.home,-def-build-tool"> 747 <presetdef name="build-bootstrap-tool"> 748 <build-tool 749 bin.dir="${build.bootstrap.dir}/bin" 750 java="${boot.java}"/> 751 </presetdef> 752 </target> 753 754 <target name="-def-build-bootstrap-jar" depends="-def-build-jar"> 755 <presetdef name="build-bootstrap-jar"> 756 <build-jar 757 classes.dir="${build.bootstrap.dir}/classes" 758 lib.dir="${build.bootstrap.dir}/lib"/> 759 </presetdef> 760 </target> 761 762 <target name="-def-build-bootstrap-classes" depends="-def-build-classes"> 763 <presetdef name="build-bootstrap-classes"> 764 <build-classes 765 source="${boot.javac.source}" 766 target="${boot.javac.target}" 767 gensrc.dir="${build.bootstrap.dir}/gensrc" 768 classes.dir="${build.bootstrap.dir}/classes" 769 javac.bootclasspath="" 770 bootclasspath.opt="-Xbootclasspath/p:${build.bootstrap.dir}/classes" 771 sourcepath="" 772 release="${bootstrap.release}" 773 full.version="${bootstrap.full.version}" 774 excludes="${bootstrap.exclude.files} **/package-info.java"/> 775 </presetdef> 776 </target> 777 778 <target name="-def-pcompile"> 779 <mkdir dir="${build.toolclasses.dir}"/> 780 <javac fork="true" 781 source="${boot.javac.source}" 782 target="${boot.javac.target}" 783 executable="${boot.java.home}/bin/javac" 784 srcdir="${make.tools.dir}/CompileProperties" 785 destdir="${build.toolclasses.dir}/" 786 classpath="${ant.home}/lib/ant.jar"/> 787 <taskdef name="pcompile" 788 classname="CompilePropertiesTask" 789 classpath="${build.toolclasses.dir}/"/> 790 </target> 791 792 <target name="-def-genstubs" depends="build-bootstrap-javac" if="require.import.jdk.stubs"> 793 <mkdir dir="${build.toolclasses.dir}"/> 794 <javac fork="true" 795 source="${boot.javac.source}" 796 target="${boot.javac.target}" 797 executable="${boot.java.home}/bin/javac" 798 srcdir="${make.tools.dir}/GenStubs" 799 destdir="${build.toolclasses.dir}/" 800 classpath="${build.bootstrap.dir}/classes:${ant.home}/lib/ant.jar"/> 801 <taskdef name="genstubs" 802 classname="GenStubs$$Ant" 803 classpath="${build.toolclasses.dir}/"/> 804 </target> 805 806 <target name="-def-javadoc-tool" depends="-check-target.java.home"> 807 <macrodef name="javadoc-tool"> 808 <attribute name="name"/> 809 <attribute name="includes"/> 810 <attribute name="options" default=""/> 811 <attribute name="source" default="1.5"/> <!-- FIXME --> 812 <sequential> 813 <property name="javadoc.options" value=""/> <!-- default, can be overridden per user or per project --> 814 <!-- Note: even with this default value, includes 815 from src.classes.dir get javadoc'd; see packageset below --> 816 <property name="javadoc.packagenames" value="none"/> <!-- default, can be overridden per user or per project --> 817 <javadoc 818 executable="${target.java.home}/bin/javadoc" 819 destdir="${build.javadoc.dir}/@{name}" 820 source="@{source}" 821 windowtitle="UNOFFICIAL" 822 failonerror="true" 823 use="true" 824 author="false" 825 version="false" 826 packagenames="${javadoc.packagenames}" > 827 <header><![CDATA[<strong>Unofficial Javadoc</strong> generated from developer sources for preview purposes only]]></header> 828 <arg line="@{options}"/> 829 <bootclasspath> 830 <path location="${build.classes.dir}"/> 831 <path location="${target.java.home}/jre/lib/rt.jar"/> 832 </bootclasspath> 833 <sourcepath> 834 <pathelement location="${src.classes.dir}"/> 835 </sourcepath> 836 <!-- XXX just <fileset> (restricted further to **/*.java) and no <packageset> --> 837 <!-- means that {@link some.package} will not work, which is no good. --> 838 <!-- (It correctly skips excluded single classes, but not if packageset is also included, --> 839 <!-- which also causes duplicates in the class index for included files.) --> 840 <packageset dir="${src.classes.dir}" includes="@{includes}"> 841 <or> 842 <filename name="java/"/> 843 <filename name="javax/"/> 844 <filename name="com/sun/javadoc/"/> 845 <filename name="com/sun/mirror/"/> 846 <filename name="com/sun/source/"/> 847 </or> 848 </packageset> 849 </javadoc> 850 </sequential> 851 </macrodef> 852 </target> 853 854 <target name="-def-jtreg" unless="jtreg.defined" depends="-check-jtreg.home,-check-target.java.home"> 855 <taskdef name="jtreg" classname="com.sun.javatest.regtest.Main$$Ant"> 856 <classpath> 857 <pathelement location="${jtreg.home}/lib/jtreg.jar"/> 858 <pathelement location="${jtreg.home}/lib/javatest.jar"/> 859 </classpath> 860 </taskdef> 861 <macrodef name="jtreg-tool"> 862 <attribute name="name"/> 863 <attribute name="tests"/> 864 <attribute name="jdk" default="${target.java.home}"/> 865 <attribute name="samevm" default="true"/> 866 <attribute name="verbose" default="summary"/> 867 <attribute name="options" default=""/> 868 <attribute name="keywords" default="-keywords:!ignore"/> 869 <attribute name="jpda.jvmargs" default=""/> 870 <sequential> 871 <property name="coverage.options" value=""/> <!-- default --> 872 <property name="coverage.classpath" value=""/> <!-- default --> 873 <jtreg 874 dir="${test.dir}" 875 workDir="${build.jtreg.dir}/@{name}/work" 876 reportDir="${build.jtreg.dir}/@{name}/report" 877 jdk="@{jdk}" 878 samevm="@{samevm}" verbose="@{verbose}" 879 failonerror="false" resultproperty="jtreg.@{name}.result" 880 javacoptions="-g" 881 vmoptions="${coverage.options} -Xbootclasspath/p:${coverage.classpath}:${build.classes.dir} @{jpda.jvmargs}"> 882 <arg line="@{keywords}"/> 883 <arg line="@{options}"/> 884 <arg line="@{tests}"/> 885 </jtreg> 886 <!-- the next two properties are for convenience, when only 887 a single instance of jtreg will be invoked. --> 888 <condition property="jtreg.passed"> 889 <equals arg1="${jtreg.@{name}.result}" arg2="0"/> 890 </condition> 891 <property name="jtreg.report" value="${build.jtreg.dir}/@{name}/report"/> 892 </sequential> 893 </macrodef> 894 <property name="jtreg.defined" value="true"/> 895 </target> 896 897 <target name="-def-cobertura" depends="-check-cobertura.home"> 898 <path id="cobertura.classpath"> 899 <fileset dir="${cobertura.home}"> 900 <include name="cobertura.jar"/> 901 <include name="lib/**/*.jar"/> 902 </fileset> 903 </path> 904 <taskdef classpathref="cobertura.classpath" resource="tasks.properties"/> 905 </target> 906 907 <target name="-def-findbugs" unless="findbugs.defined" depends="-check-findbugs.home"> 908 <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask"> 909 <classpath> 910 <pathelement location="${findbugs.home}/lib/findbugs.jar"/> 911 </classpath> 912 </taskdef> 913 <macrodef name="findbugs-tool"> 914 <attribute name="name"/> 915 <attribute name="output" default="emacs"/> 916 <attribute name="outputFile" default=""/> 917 <attribute name="reportLevel" default="high"/> 918 <sequential> 919 <findbugs 920 home="${findbugs.home}" 921 output="@{output}" 922 outputFile="@{outputFile}" 923 reportLevel="@{reportLevel}" 924 failOnError="false" 925 errorProperty="findbugs.@{name}.errors" 926 warningsProperty="findbugs.@{name}.warnings" 927 jvmargs="-Xmx512M" > 928 <class location="${dist.dir}/lib/@{name}.jar"/> 929 <auxClasspath> 930 <pathelement location="${build.classes.dir}"/> 931 </auxClasspath> 932 <sourcePath> 933 <pathelement location="${src.classes.dir}"/> 934 </sourcePath> 935 </findbugs> 936 </sequential> 937 </macrodef> 938 <property name="findbugs.defined" value="true"/> 939 </target> 940 941 <target name="-def-vizant" unless="vizant.defined" depends="-check-vizant"> 942 <taskdef name="vizant" classname="net.sourceforge.vizant.Vizant" classpath="${vizant.jar}"/> 943 <property name="vizant.defined" value="true"/> 944 </target> 945 946 <target name="-def-check"> 947 <macrodef name="check"> 948 <attribute name="name"/> 949 <attribute name="property"/> 950 <attribute name="marker" default=""/> 951 <sequential> 952 <fail message="Cannot locate @{name}: please set @{property} to its location"> 953 <condition> 954 <not> 955 <isset property="@{property}"/> 956 </not> 957 </condition> 958 </fail> 959 <fail message="@{name} is not installed in ${@{property}}"> 960 <condition> 961 <and> 962 <not> 963 <equals arg1="@{marker}" arg2=""/> 964 </not> 965 <not> 966 <available file="${@{property}}/@{marker}"/> 967 </not> 968 </and> 969 </condition> 970 </fail> 971 </sequential> 972 </macrodef> 973 </target> 974 975</project> 976 977