< prev index next >

./build.gradle

Print this page
rev 10114 : 8161704: Switch to Jigsaw-aware boot JDK for compiling FX 9
Reviewed-by:

   1 /*
   2  * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 /**
  27  * The main build script for JavaFX.
  28  *
  29  * MUST FIX tasks to complete:
  30  *  - build check -- making sure the final artifact has the right bits
  31  *      - some things worth automatically sanity checking:
  32  *          - are there images in the javadocs?
  33  *          - are all of the expected dylibs etc there?
  34  *          - is jfxrt.jar there?
  35  *          - does jfxrt.jar contain stuff it shouldn't (doc-files, iml, etc)
  36  *          - does jfxrt.jar contain stuff it should (bss files, etc)
  37  *  - Perform sanity checking to make sure a JDK exists with javac, javah, etc
  38  *  - Support building with no known JDK location, as long as javac, javah, etc are on the path
  39  *  - Check all of the native flags. We're adding weight to some libs that don't need it, and so forth.
  40  *
  41  * Additional projects to work on as we go:
  42  *  - Add "developer debug". This is where the natives do not have debug symbols, but the Java code does
  43  *  - The genVSproperties.bat doesn't find the directory where RC.exe lives. So it is hard coded. Might be a problem.
  44  *  - special tasks for common needs, such as:
  45  *      - updating copyright headers
  46  *      - stripping trailing whitespace (?)
  47  *  - checkstyle
  48  *  - findbugs
  49  *  - re needs?
  50  *  - sqe testing
  51  *  - API change check
  52  *  - Pushing results to a repo?
  53  *  - ServiceWithSecurityManagerTest fails to complete when run from gradle.
  54  *  - Integrate Parfait reports for C code
  55  *  - FXML Project tests are not running
  56  */


 241  *  All properties defined using ext. are immediately available throughout    *
 242  *  the script as variables that can be used. These variables are attached    *
 243  *  to the root project (whereas if they were defined as def variables then   *
 244  *  they would only be available within the root project scope).              *
 245  *                                                                            *
 246  *  All properties defined using the "defineProperty" method can be replaced  *
 247  *  on the command line by using the -P flag. For example, to override the    *
 248  *  location of the binary plug, you would specify -PBINARY_PLUG=some/where   *
 249  *                                                                            *
 250  *****************************************************************************/
 251 
 252 // If the ../rt-closed directory exists, then we are doing a closed build.
 253 // In this case, build and property files will be read from
 254 // ../rt-closed/closed-build.gradle and ../rt-closed/closed-properties.gradle
 255 // respectively
 256 
 257 def closedDir = file("../rt-closed")
 258 def buildClosed = closedDir.isDirectory()
 259 ext.BUILD_CLOSED = buildClosed
 260 









 261 // These variables indicate what platform is running the build. Is
 262 // this build running on a Mac, Windows, or Linux machine? 32 or 64 bit?
 263 ext.OS_NAME = System.getProperty("os.name").toLowerCase()
 264 ext.OS_ARCH = System.getProperty("os.arch")
 265 ext.IS_64 = OS_ARCH.toLowerCase().contains("64")
 266 ext.IS_MAC = OS_NAME.contains("mac") || OS_NAME.contains("darwin")
 267 ext.IS_WINDOWS = OS_NAME.contains("windows")
 268 ext.IS_LINUX = OS_NAME.contains("linux")
 269 
 270 // Verify that the architecture & OS are supported configurations. Note that
 271 // at present building on PI is not supported, but we would only need to make
 272 // some changes on assumptions on what should be built (like SWT / Swing) and
 273 // such and we could probably make it work.
 274 if (!IS_MAC && !IS_WINDOWS && !IS_LINUX) fail("Unsupported build OS ${OS_NAME}")
 275 if (IS_WINDOWS && OS_ARCH != "x86" && OS_ARCH != "amd64") {
 276     fail("Unknown and unsupported build architecture: $OS_ARCH")
 277 } else if (IS_MAC && OS_ARCH != "x86_64") {
 278     fail("Unknown and unsupported build architecture: $OS_ARCH")
 279 } else if (IS_LINUX && OS_ARCH != "i386" && OS_ARCH != "amd64") {
 280     fail("Unknown and unsupported build architecture: $OS_ARCH")
 281 }
 282 
 283 
 284 // Get the JDK_HOME automatically based on the version of Java used to execute gradle. Or, if specified,
 285 // use a user supplied JDK_HOME, STUB_RUNTIME, JAVAC, and/or JAVAH, all of which may be specified
 286 // independently (or we'll try to get the right one based on other supplied info). Sometimes the
 287 // JRE might be the thing that is being used instead of the JRE embedded in the JDK, such as:
 288 //    c:\Program Files (x86)\Java\jdk1.8.0\jre
 289 //    c:\Program Files (x86)\Java\jre8\
 290 // Because of this, you may sometimes get the jdk's JRE (in which case the logic we used to have here
 291 // was correct and consistent with all other platforms), or it might be the standalone JRE (for the love!).
 292 def envJavaHome = cygpath(System.getenv("JDK_HOME"))
 293 if (envJavaHome == null || envJavaHome.equals("")) envJavaHome = cygpath(System.getenv("JAVA_HOME"))
 294 def javaHome = envJavaHome == null || envJavaHome.equals("") ? System.getProperty("java.home") : envJavaHome
 295 def javaHomeFile = file(javaHome)
 296 defineProperty("JDK_HOME",
 297         javaHomeFile.name == "jre" ?
 298         javaHomeFile.getParent().toString() :
 299         javaHomeFile.name.startsWith("jre") ?
 300         new File(javaHomeFile.getParent(), "jdk1.${javaHomeFile.name.substring(3)}.0").toString() :
 301         javaHome) // we have to bail and set it to something and this is as good as any!
 302 ext.JAVA_HOME = JDK_HOME
 303 
 304 // Check whether JIGSAW_HOME is set. If it is, then it points to a JDK9
 305 // jigsaw build with modularization enabled and can be used for testing
 306 def envJigsawHome = cygpath(System.getenv("JIGSAW_HOME"))
 307 defineProperty("JIGSAW_HOME", envJigsawHome);
 308 
 309 if (JIGSAW_HOME == null || JIGSAW_HOME == "") {
 310     logger.warn("JIGSAW_HOME is not set");
 311     ext.USE_JIGSAW = false
 312 } else {
 313     ext.USE_JIGSAW = true
 314 }
 315 
 316 defineProperty("JAVA", cygpath("$JDK_HOME/bin/java${IS_WINDOWS ? '.exe' : ''}"))
 317 defineProperty("JIGSAW_JAVA", cygpath("$JIGSAW_HOME/bin/java${IS_WINDOWS ? '.exe' : ''}"))
 318 defineProperty("JAVAC", cygpath("$JDK_HOME/bin/javac${IS_WINDOWS ? '.exe' : ''}"))
 319 defineProperty("JIGSAW_JAVAC", cygpath("$JIGSAW_HOME/bin/javac${IS_WINDOWS ? '.exe' : ''}"))
 320 defineProperty("JAVAH", cygpath("$JDK_HOME/bin/javah${IS_WINDOWS ? '.exe' : ''}"))
 321 defineProperty("JAVADOC", cygpath("$JDK_HOME/bin/javadoc${IS_WINDOWS ? '.exe' : ''}"))
 322 defineProperty("JDK_DOCS", "https://docs.oracle.com/javase/8/docs/api/")
 323 defineProperty("JIGSAW_MODULES", cygpath(System.getenv("JIGSAW_MODULES")) ?: cygpath(System.getenv("JIGSAW_HOME") + "/jmods"))
 324 
 325 defineProperty("javaRuntimeVersion", System.getProperty("java.runtime.version"))
 326 def javaVersionInfo = parseJavaVersion(javaRuntimeVersion)
 327 defineProperty("javaVersion", javaVersionInfo[0])
 328 defineProperty("javaBuildNumber", javaVersionInfo[1])
 329 
 330 loadProperties("$projectDir/build.properties")
 331 
 332 // Look for stub runtime in either old (JDK 8u) or new (JDK 9) dir layout
 333 
 334 def cachesSdkRtDir = file("../caches/sdk/rt")
 335 def hasRtDir = cachesSdkRtDir.isDirectory()
 336 def String closedCacheStubRuntime = cygpath("$projectDir") + "/../caches/sdk" + (hasRtDir ? "/rt" : "")
 337 
 338 def jdkHomeJreDir = file("$JDK_HOME/jre")
 339 def hasJreDir = jdkHomeJreDir.isDirectory()
 340 def String jreStubRuntime = cygpath("$JDK_HOME") + (hasJreDir ? "/jre" : "")
 341 
 342 defineProperty("STUB_RUNTIME", BUILD_CLOSED ? closedCacheStubRuntime : jreStubRuntime)
 343 
 344 defineProperty("LIBRARY_STUB", IS_MAC ? "$STUB_RUNTIME/lib" :








 345                                IS_WINDOWS ? "$STUB_RUNTIME/bin" :
 346                                "$STUB_RUNTIME/lib/$OS_ARCH")
 347 defineProperty("UPDATE_STUB_CACHE", (STUB_RUNTIME.equals(closedCacheStubRuntime) ? 'true' : 'false'))





 348 
 349 def supplementalPreBuildFile = file("$closedDir/closed-pre-build.gradle");
 350 def supplementalBuildFile = file("$closedDir/closed-build.gradle");
 351 
 352 if (BUILD_CLOSED) {
 353     apply from: supplementalPreBuildFile
 354 }
 355 
 356 // GRADLE_VERSION_CHECK specifies whether to fail the build if the
 357 // gradle version check fails
 358 defineProperty("GRADLE_VERSION_CHECK", "true")
 359 ext.IS_GRADLE_VERSION_CHECK = Boolean.parseBoolean(GRADLE_VERSION_CHECK)
 360 
 361 // COMPILE_WEBKIT specifies whether to build all of webkit.
 362 defineProperty("COMPILE_WEBKIT", "false")
 363 ext.IS_COMPILE_WEBKIT = Boolean.parseBoolean(COMPILE_WEBKIT)
 364 
 365 // COMPILE_MEDIA specifies whether to build all of media.
 366 defineProperty("COMPILE_MEDIA", "false")
 367 ext.IS_COMPILE_MEDIA = Boolean.parseBoolean(COMPILE_MEDIA)
 368 
 369 // COMPILE_PANGO specifies whether to build javafx_font_pango.
 370 defineProperty("COMPILE_PANGO", "${IS_LINUX}")
 371 ext.IS_COMPILE_PANGO = Boolean.parseBoolean(COMPILE_PANGO)
 372 
 373 // COMPILE_HARFBUZZ specifies whether to use Harfbuzz.
 374 defineProperty("COMPILE_HARFBUZZ", "false")
 375 ext.IS_COMPILE_HARFBUZZ = Boolean.parseBoolean(COMPILE_HARFBUZZ)
 376 
 377 // COMPILE_PARFAIT specifies whether to build parfait
 378 defineProperty("COMPILE_PARFAIT", "false")
 379 ext.IS_COMPILE_PARFAIT = Boolean.parseBoolean(COMPILE_PARFAIT)
 380 
 381 // FIXME: update the default when using 9 (pre-jigsaw) as boot jdk
 382 // COMPILE_JFR specifies whether to build code that logs to JRockit Flight Recorder
 383 defineProperty("COMPILE_JFR", Boolean.toString(file("$JDK_HOME/jre/lib/jfr.jar").exists()))
 384 ext.IS_COMPILE_JFR = Boolean.parseBoolean(COMPILE_JFR)
 385 
 386 // BUILD_FXPACKAGER enables building the packager modules and native code
 387 defineProperty("BUILD_FXPACKAGER", "false")
 388 ext.IS_BUILD_FXPACKAGER = Boolean.parseBoolean(BUILD_FXPACKAGER)
 389 
 390 // RETAIN_PACKAGER_TESTS specifies whether the tests in fxpackager should
 391 // keep generated files instead of attempting to automatically delete them
 392 defineProperty("RETAIN_PACKAGER_TESTS", "false")
 393 ext.IS_RETAIN_PACKAGER_TESTS = Boolean.parseBoolean(RETAIN_PACKAGER_TESTS)
 394 
 395 // TEST_PACKAGER_DMG whether tests that create DMG files via hdiutil
 396 // should be run.  On OSX 10.7 this tends to hang automated builds
 397 defineProperty("TEST_PACKAGER_DMG", "false")
 398 ext.IS_TEST_PACKAGER_DMG = Boolean.parseBoolean(TEST_PACKAGER_DMG)
 399 
 400 // Define the SWT.jar that we are going to have to download during the build process based
 401 // on what platform we are compiling from (not based on our target).
 402 ext.SWT_FILE_NAME = IS_MAC ? "org.eclipse.swt.cocoa.macosx.x86_64_3.7.2.v3740f" :
 403     IS_WINDOWS && IS_64 ? "org.eclipse.swt.win32.win32.x86_64_3.7.2.v3740f" :
 404     IS_WINDOWS && !IS_64 ? "org.eclipse.swt.win32.win32.x86_3.7.2.v3740f" :
 405     IS_LINUX && IS_64 ? "org.eclipse.swt.gtk.linux.x86_64_3.7.2.v3740f" :
 406     IS_LINUX && !IS_64 ? "org.eclipse.swt.gtk.linux.x86_3.7.2.v3740f" : ""
 407 
 408 // Build javadocs only if BUILD_JAVADOC=true
 409 defineProperty("BUILD_JAVADOC", "false")
 410 ext.IS_BUILD_JAVADOC = Boolean.parseBoolean(BUILD_JAVADOC)
 411 
 412 // Specifies whether to build the javafx-src bundle
 413 defineProperty("BUILD_SRC_ZIP", "false")
 414 ext.IS_BUILD_SRC_ZIP = Boolean.parseBoolean(BUILD_SRC_ZIP)
 415 
 416 // Specifies whether to build the javafx-exports bundle
 417 defineProperty("BUILD_MODULE_ZIP", "true")
 418 ext.IS_BUILD_MODULE_ZIP = Boolean.parseBoolean(BUILD_MODULE_ZIP)
 419 
 420 // Specifies whether to run full tests (true) or smoke tests (false)
 421 defineProperty("FULL_TEST", "false")
 422 ext.IS_FULL_TEST = Boolean.parseBoolean(FULL_TEST);
 423 
 424 defineProperty("JIGSAW_TEST", "true")
 425 ext.IS_JIGSAW_TEST = Boolean.parseBoolean(JIGSAW_TEST) && USE_JIGSAW
 426 
 427 defineProperty("FORCE_TESTS", "false")
 428 ext.IS_FORCE_TESTS = Boolean.parseBoolean(FORCE_TESTS);
 429 
 430 // Specifies whether to run robot-based visual tests (only used when FULL_TEST is also enabled)
 431 defineProperty("USE_ROBOT", "false")
 432 ext.IS_USE_ROBOT = Boolean.parseBoolean(USE_ROBOT);
 433 
 434 // Specified whether to run tests in headless mode
 435 defineProperty("HEADLESS_TEST", "false")
 436 ext.IS_HEADLESS_TEST = Boolean.parseBoolean(HEADLESS_TEST);
 437 
 438 // Specifies whether to run system tests that depend on AWT (only used when FULL_TEST is also enabled)
 439 defineProperty("AWT_TEST", "true")
 440 ext.IS_AWT_TEST = Boolean.parseBoolean(AWT_TEST);
 441 
 442 // Specifies whether to run system tests that depend on SWT (only used when FULL_TEST is also enabled)
 443 defineProperty("SWT_TEST", "true")
 444 ext.IS_SWT_TEST = Boolean.parseBoolean(SWT_TEST);
 445 
 446 // Specifies whether to run unstable tests (true) - tests that don't run well with Hudson builds


 555 // Check whether the COMPILE_TARGETS property has been specified (if so, it was done by
 556 // the user and not by this script). If it has not been defined then default
 557 // to building the normal desktop build for this machine
 558 project.ext.set("defaultHostTarget", IS_MAC ? "mac" : IS_WINDOWS ? "win" : IS_LINUX ? "linux" : "");
 559 defineProperty("COMPILE_TARGETS", "$defaultHostTarget")
 560 
 561 // Flag indicating whether to import cross compile tools
 562 def importCrossTools = BUILD_CLOSED ? true : false;
 563 if (!importCrossTools && hasProperty("IMPORT_CROSS_TOOLS")) {
 564     importCrossTools = Boolean.parseBoolean(IMPORT_CROSS_TOOLS);
 565 }
 566 ext.IS_IMPORT_CROSS_TOOLS = importCrossTools
 567 
 568 // Location of the cross compile tools
 569 def crossToolsDir = "../crosslibs"
 570 if (hasProperty("CROSS_TOOLS_DIR")) {
 571     crossToolsDir = CROSS_TOOLS_DIR
 572 }
 573 ext.CROSS_TOOLS_DIR = file(crossToolsDir)
 574 
 575 // Specifies whether to run tests with the present jfxrt.jar instead of compiling the new one
 576 defineProperty("BUILD_SDK_FOR_TEST", "true")
 577 ext.DO_BUILD_SDK_FOR_TEST = Boolean.parseBoolean(BUILD_SDK_FOR_TEST)
 578 
 579 // Specifies the location to point at SDK build when DO_BUILD_SDK_FOR_TEST set to false
 580 // Used to get location of jfxrt.jar, ant-javafx.jar and javafx-mx.jar
 581 defineProperty("TEST_SDK", JDK_HOME)
 582 ext.TEST_SDK_DIR = file(TEST_SDK)
 583 
 584 def rtDir = TEST_SDK_DIR
 585 ext.jfxrtJarFromSdk = new File(rtDir, "lib/jfxrt.jar").absolutePath
 586 if (!DO_BUILD_SDK_FOR_TEST && !file(jfxrtJarFromSdk).exists()) {
 587     fail ("BUILD_SDK_FOR_TEST is set to false, but there\'s no jfxrt.jar at the expected paths in TEST_SDK($TEST_SDK_DIR)\n"
 588             + "TEST_SDK should point at either JavaFX SDK location or JDK location\n"
 589             + "Please, set the correct TEST_SDK")
 590 }
 591 
 592 // All "classes" and "jar" tasks and their dependencies would be disabled 
 593 // when running with DO_BUILD_SDK_FOR_TEST=false as they're unneeded for running tests
 594 if (!DO_BUILD_SDK_FOR_TEST) {
 595     gradle.taskGraph.useFilter({ task -> !task.name.equals("classes") && !task.name.equals("jar") })
 596 }
 597 
 598 /**
 599  * Fetch/Check that external tools are present for the build. This method
 600  * will conditionally download the packages from project defined ivy repositories
 601  * and unpack them into the specified destdir
 602  *
 603  * @param configName A unique name to distinguish the configuration (ie "ARMSFV6")
 604  * @param packages A list of required packages (with extensions .tgz, .zip)
 605  * @param destdir where the packages should be unpacked
 606  * @param doFetch if true, the named packages will be download
 607  */
 608 void fetchExternalTools(String configName, List packages, File destdir, boolean doFetch) {
 609     if (doFetch) {
 610         // create a unique configuration for this fetch
 611         def String fetchToolsConfig = "fetchTools$configName"


 687         }
 688     } else { // !doFetch - so just check they are present
 689         // check that all the dirs are really there
 690         def List<String> errors = []
 691         packages.each { pkgname->
 692             def String basename = pkgname.substring(0,pkgname.lastIndexOf("."))
 693             def File pkgdir = file("$destdir/$basename")
 694 
 695             if (!pkgdir.isDirectory()) {
 696                 errors.add(pkgname)
 697             }
 698         }
 699         if (errors.size > 0) {
 700             throw new GradleException("Error: missing tool packages: $errors")
 701         } else {
 702             logger.quiet "all tool packages are present $packages"
 703         }
 704     }
 705 }
 706 




















































































































































































































 707 // Now we need to define the native compilation tasks. The set of parameters to
 708 // native compilation depends on the target platform (and also to some extent what platform
 709 // you are compiling on). These settings are contained in various gradle files
 710 // such as mac.gradle and linux.gradle and armhf.gradle. Additionally, the developer
 711 // can specify COMPILE_FLAGS_FILE to be a URL or path to a different gradle file
 712 // that will contain the appropriate flags.
 713 defineProperty("COMPILE_FLAGS_FILES", COMPILE_TARGETS.split(",").collect {"buildSrc/${it.trim()}.gradle"}.join(","))
 714 if (COMPILE_TARGETS == "all") {
 715     def tmp = []
 716     File buildSrcDir = file("buildSrc")
 717     buildSrcDir.listFiles().each { File f ->
 718         if (f.isFile() && f.name.endsWith(".gradle") && !f.name.equals("build.gradle")) {
 719             def target = f.name.substring(0, f.name.lastIndexOf('.gradle')).toUpperCase(Locale.ROOT)
 720             apply from: f
 721             if (project.ext["${target}"].canBuild) {
 722                 tmp.add(target)
 723             }
 724         }
 725     }
 726     COMPILE_FLAGS_FILES = tmp.collect { "buildSrc/${it}.gradle"}.join(",")


 730         logger.info("Applying COMPILE_FLAGS_FILE '$it'")
 731         apply from: it
 732     }
 733 }
 734 
 735 if (COMPILE_TARGETS != "") {
 736     def tmp = []
 737     COMPILE_TARGETS.split(",").each {target ->
 738         if (project.ext["${target.toUpperCase(Locale.ROOT)}"].canBuild) {
 739             tmp.add(target)
 740         }
 741     }
 742     COMPILE_TARGETS = tmp.collect { "${it.toLowerCase()}"}.join(",")
 743 }
 744 
 745 // Sanity check the expected properties all exist
 746 compileTargets { t ->
 747     // Every platform must define these variables
 748     if (!project.hasProperty(t.upper)) throw new Exception("ERROR: Incorrectly configured compile flags file, missing ${t.name} property")
 749     def props = project.ext[t.upper];

 750     ["compileSwing", "compileSWT", "compileFXPackager", "libDest"].each { prop ->
 751         if (!props.containsKey(prop)) throw new Exception("ERROR: Incorrectly configured compile flags file, missing ${prop} property on ${t.name}")
 752     }
 753 }
 754 
 755 // Various build flags may be set by the different target files, such as
 756 // whether to build Swing, SWT, FXPackager, etc. We iterate over all
 757 // compile targets and look for these settings in our properties. Note that
 758 // these properties cannot be set from the command line, but are set by
 759 // the target build files such as armv6hf.gradle or mac.gradle.
 760 ext.COMPILE_SWING = false;
 761 ext.COMPILE_SWT = false;
 762 ext.COMPILE_FXPACKAGER = false;
 763 compileTargets { t ->
 764     def targetProperties = project.rootProject.ext[t.upper]
 765 
 766     if (targetProperties.compileSwing) COMPILE_SWING = true
 767     if (targetProperties.compileSWT) COMPILE_SWT = true
 768     if (IS_BUILD_FXPACKAGER && JIGSAW_HOME && targetProperties.compileFXPackager) COMPILE_FXPACKAGER = true
 769 
 770     if (!targetProperties.containsKey('compileWebnodeNative')) {
 771         // unless specified otherwise, we will compile native Webnode if IS_COMPILE_WEBKIT
 772         targetProperties.compileWebnodeNative = true
 773     }
 774 
 775     if (!targetProperties.containsKey('compileMediaNative')) {
 776         // unless specified otherwise, we will compile native Media if IS_COMPILE_MEDIA
 777         targetProperties.compileMediaNative = true
 778     }
 779 
 780     if (!targetProperties.containsKey('includeSWT')) targetProperties.includeSWT = true
 781     if (!targetProperties.containsKey('includeSwing')) targetProperties.includeSwing = true
 782     if (!targetProperties.containsKey('includeNull3d')) targetProperties.includeNull3d = true
 783     if (!targetProperties.containsKey('includeLens')) targetProperties.includeLens = false
 784     if (!targetProperties.containsKey('includeMonocle')) targetProperties.includeMonocle = false
 785     if (!targetProperties.containsKey('includeEGL')) targetProperties.includeEGL = false
 786 
 787     if (!targetProperties.containsKey('includeGTK')) targetProperties.includeGTK = IS_LINUX
 788 
 789     if (!targetProperties.containsKey('modLibDest')) targetProperties.modLibDest = targetProperties.libDest
 790 


 791     // This value is used as a prefix for various directories under ./build,
 792     // such as sdk, to allow for a common name for the hosted build
 793     // (for use when building apps) and a unique name for cross builds.
 794     if (rootProject.defaultHostTarget.equals(t.name)) {
 795         // use a simple common default for the "host" build
 796         targetProperties.platformPrefix=""

 797     } else {
 798         // and a more complex one for cross builds
 799         targetProperties.platformPrefix="${t.name}-"
 800     }
 801 }
 802 
 803 /******************************************************************************
 804  *                                                                            *
 805  *                         Build Setup Sanity Checks                          *
 806  *                                                                            *
 807  *  Here we do a variety of checks so that if the version of Java you are     *
 808  *  building with is misconfigured, or you are using the wrong version of     *
 809  *  gradle, etc you will get some kind of helpful error / warning message     *
 810  *                                                                            *
 811  *****************************************************************************/
 812 
 813 // Sanity check that we actually have a list of compile targets to execute
 814 if (COMPILE_TARGETS == null || COMPILE_TARGETS == "") {
 815     throw new Exception("Unable to determine compilation platform, must specify valid COMPILE_TARGETS!")
 816 }
 817 
 818 // Make sure JDK_HOME/bin/java exists
 819 if (!file(JAVA).exists()) throw new Exception("Missing or incorrect path to 'java': '$JAVA'. Perhaps bad JDK_HOME? $JDK_HOME")
 820 if (!file(JIGSAW_JAVA).exists()) logger.warn("Missing or incorrect path to JIGSAW 'java': '$JIGSAW_JAVA'. Perhaps bad JIGSAW_HOME? $JIGSAW_HOME")
 821 if (!file(JAVAC).exists()) throw new Exception("Missing or incorrect path to 'javac': '$JAVAC'. Perhaps bad JDK_HOME? $JDK_HOME")
 822 if (!file(JIGSAW_JAVAC).exists()) logger.warn("Missing or incorrect path to JIGSAW 'javac': '$JIGSAW_JAVAC'. Perhaps bad JIGSAW_HOME? $JIGSAW_HOME")
 823 if (!file(JAVAH).exists()) throw new Exception("Missing or incorrect path to 'javah': '$JAVAH'. Perhaps bad JDK_HOME? $JDK_HOME")
 824 if (!file(JAVADOC).exists()) throw new Exception("Missing or incorrect path to 'javadoc': '$JAVADOC'. Perhaps bad JDK_HOME? $JDK_HOME")
 825 
 826 // Determine the verion of Java in JDK_HOME. It looks like this:
 827 //
 828 // $ java -version
 829 // java version "1.7.0_45"
 830 // Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
 831 // Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)
 832 //
 833 // We need to parse the second line
 834 def inStream = new java.io.BufferedReader(new java.io.InputStreamReader(new java.lang.ProcessBuilder(JAVA, "-fullversion").start().getErrorStream()));
 835 try {
 836     String v = inStream.readLine().trim();
 837     if (v != null) {
 838         int ib = v.indexOf("full version \"");
 839         if (ib != -1) {
 840             String str = v.substring(ib);
 841             String ver = str.substring(str.indexOf("\"") + 1, str.size() - 1);
 842 


 848     }
 849 } finally {
 850     inStream.close();
 851 }
 852 if (!project.hasProperty("jdkRuntimeVersion")) throw new Exception("Unable to determine the version of Java in JDK_HOME at $JDK_HOME");
 853 
 854 
 855 
 856 // Verify that CONF is something useful
 857 if (CONF != "Release" && CONF != "Debug" && CONF != "DebugNative") {
 858     logger.warn("Unknown configuration CONF='$CONF'. Treating as 'Release'")
 859 }
 860 
 861 // If the number of compile threads is less than 1 then we have a problem!
 862 if (Integer.parseInt(NUM_COMPILE_THREADS.toString()) < 1) {
 863     logger.warn("NUM_COMPILE_THREADS was specified as '$NUM_COMPILE_THREADS' which is less than the minimum value of 1. " +
 864             "Building with a value of 1 instead.")
 865     NUM_COMPILE_THREADS = 1
 866 }
 867 
 868 // Check that Gradle 2.11 is in use, error if < 2.11.
 869 if (gradle.gradleVersion != "2.11") {
 870     def ver = gradle.gradleVersion.split("[\\.]");
 871     def gradleMajor = Integer.parseInt(ver[0]);
 872     def gradleMinor = Integer.parseInt(ver[1]);
 873     def err = "";
 874     if (gradleMajor == 1 || gradleMajor == 2 && gradleMinor < 11) {
 875         err = "Gradle version too old: ${gradle.gradleVersion}; must be at least 2.11"
 876     }
 877 
 878     if (IS_GRADLE_VERSION_CHECK && err != "") {
 879         fail(err);
 880     }
 881 
 882     logger.warn("*****************************************************************");
 883     logger.warn("Unsupported gradle version $gradle.gradleVersion in use.");
 884     logger.warn("Only version 2.11 is supported. Use this version at your own risk");
 885     if ( err != "") logger.warn(err);
 886     logger.warn("*****************************************************************");
 887 }
 888 
 889 /******************************************************************************
 890  *                                                                            *
 891  *                      Logging of Properties and Settings                    *
 892  *                                                                            *
 893  *  Log some of the settings we've determined. We could log more here, it     *
 894  *  doesn't really hurt.                                                      *
 895  *                                                                            *
 896  *****************************************************************************/
 897 
 898 logger.quiet("gradle.gradleVersion: $gradle.gradleVersion")
 899 logger.quiet("OS_NAME: $OS_NAME")
 900 logger.quiet("OS_ARCH: $OS_ARCH")
 901 logger.quiet("JAVA_HOME: $JAVA_HOME")
 902 logger.quiet("JDK_HOME: $JDK_HOME")
 903 logger.quiet("JIGSAW_HOME: $JIGSAW_HOME")
 904 logger.quiet("java.runtime.version: ${javaRuntimeVersion}")
 905 logger.quiet("java version: ${javaVersion}")
 906 logger.quiet("java build number: ${javaBuildNumber}")
 907 logger.quiet("jdk.runtime.version: ${jdkRuntimeVersion}")
 908 logger.quiet("jdk version: ${jdkVersion}")
 909 logger.quiet("jdk build number: ${jdkBuildNumber}")
 910 logger.quiet("minimum jdk version: ${jfxBuildJdkVersionMin}")
 911 logger.quiet("minimum jdk build number: ${jfxBuildJdkBuildnumMin}")
 912 logger.quiet("STUB_RUNTIME: $STUB_RUNTIME")
 913 logger.quiet("CONF: $CONF")
 914 logger.quiet("NUM_COMPILE_THREADS: $NUM_COMPILE_THREADS")
 915 logger.quiet("COMPILE_TARGETS: $COMPILE_TARGETS")
 916 logger.quiet("COMPILE_FLAGS_FILES: $COMPILE_FLAGS_FILES")
 917 logger.quiet("HUDSON_JOB_NAME: $HUDSON_JOB_NAME")
 918 logger.quiet("HUDSON_BUILD_NUMBER: $HUDSON_BUILD_NUMBER")
 919 logger.quiet("PROMOTED_BUILD_NUMBER: $PROMOTED_BUILD_NUMBER")
 920 logger.quiet("PRODUCT_NAME: $PRODUCT_NAME")
 921 logger.quiet("RELEASE_VERSION: $RELEASE_VERSION")
 922 logger.quiet("RELEASE_SUFFIX: $RELEASE_SUFFIX")
 923 logger.quiet("RELEASE_VERSION_SHORT: $RELEASE_VERSION_SHORT")


 957  * @param name The name of the project, such as "prism-common". This name is used
 958  *        in the name of the generated task, such as ccPrismCommon, and also
 959  *        in the name of the final library, such as libprism-common.dylib.
 960  */
 961 void addNative(Project project, String name) {
 962     // TODO if we want to handle 32/64 bit windows in the same build,
 963     // Then we will need to modify the win compile target to be win32 or win64
 964     def capitalName = name.split("-").collect{it.capitalize()}.join()
 965     def nativeTask = project.task("native$capitalName", group: "Build") {
 966         description = "Generates JNI headers, compiles, and builds native dynamic library for $name for all compile targets"
 967     }
 968     def cleanTask = project.task("cleanNative$capitalName", type: Delete, group: "Build") {
 969         description = "Clean native objects for $name"
 970     }
 971     if (project.hasProperty("nativeAllTask")) project.nativeAllTask.dependsOn nativeTask
 972     project.assemble.dependsOn(nativeTask)
 973     if (project.hasProperty("cleanNativeAllTask")) project.cleanNativeAllTask.dependsOn cleanTask
 974 
 975     // Each of the different compile targets will be placed in a sub directory
 976     // of these root dirs, with the name of the dir being the name of the target
 977     def headerRootDir = project.file("$project.buildDir/gensrc/headers/$name")
 978     def nativeRootDir = project.file("$project.buildDir/native/$name")
 979     def libRootDir = project.file("$project.buildDir/libs/$name")
 980     // For each compile target, create a javah / cc / link triplet
 981     compileTargets { t ->
 982         def targetProperties = project.rootProject.ext[t.upper]
 983         def library = targetProperties.library
 984         def properties = targetProperties.get(name)
 985         def nativeDir = file("$nativeRootDir/${t.name}")
 986         def headerDir = file("$headerRootDir/${t.name}")
 987 
 988         // If there is not a library clause in the properties, assume it is not wanted
 989         if (!targetProperties.containsKey(name)) {
 990             println("Ignoring native library ${name}. Not defined in ${t.name} project properties");
 991             return
 992         }
 993 
 994         // check for the property disable${name} = true
 995         def String disableKey = "disable${name}"
 996         def boolean disabled = targetProperties.containsKey(disableKey) ? targetProperties.get(disableKey) : false
 997         if (disabled) {
 998             println("Native library ${name} disabled in ${t.name} project properties");
 999             return
1000         }
1001 
1002         def javahTask = project.task("javah${t.capital}${capitalName}", type: JavaHeaderTask, dependsOn: project.classes, group: "Build") {
1003             description = "Generates JNI Headers for ${name} for ${t.name}"
1004             if (properties.javahSource == null) {
1005                 source(project.sourceSets.main.output.classesDir)
1006             } else {
1007                 source(properties.javahSource)
1008             }
1009             if (properties.javahClasspath == null) {
1010                 classpath = project.files(project.sourceSets.main.output.classesDir)
1011                 classpath += project.sourceSets.main.compileClasspath
1012             } else {
1013                 classpath = project.files(properties.javahClasspath)
1014             }
1015             output = headerDir
1016             include(properties.javahInclude)
1017             cleanTask.delete headerDir
1018         }
1019 
1020         def variants = properties.containsKey("variants") ? properties.variants : [""];
1021         variants.each { variant ->
1022             def variantProperties = variant == "" ? properties : properties.get(variant)
1023             def capitalVariant = variant.capitalize()
1024             def ccOutput = variant == "" ? nativeDir : file("$nativeDir/$variant")
1025             def ccTask = project.task("cc${t.capital}$capitalName$capitalVariant", type: CCTask, dependsOn: javahTask, group: "Build") {
1026                 description = "Compiles native sources for ${name} for ${t.name}${capitalVariant != '' ? ' for variant ' + capitalVariant : ''}"
1027                 matches = ".*\\.c|.*\\.cpp|.*\\.m|.*\\.cc"
1028                 headers = headerDir
1029                 output(ccOutput)
1030                 params.addAll(variantProperties.ccFlags)
1031                 compiler = variantProperties.compiler
1032                 source(variantProperties.nativeSource)
1033                 cleanTask.delete ccOutput
1034             }
1035             def linkTask = project.task("link${t.capital}$capitalName$capitalVariant", type: LinkTask, dependsOn: ccTask, group: "Build") {
1036                 description = "Creates native dynamic library for $name for ${t.name}${capitalVariant != '' ? ' for variant ' + capitalVariant : ''}"
1037                 objectDir = ccOutput
1038                 linkParams.addAll(variantProperties.linkFlags)
1039                 lib = file("$libRootDir/${t.name}/${variant == '' ? library(properties.lib) : library(variantProperties.lib)}")
1040                 linker = variantProperties.linker
1041                 cleanTask.delete "$libRootDir/${t.name}"
1042             }
1043             nativeTask.dependsOn(linkTask)
1044             if (IS_WINDOWS && t.name == "win") {
1045                 def rcTask = project.task("rc$capitalName$capitalVariant", type: CompileResourceTask, dependsOn: javahTask, group: "Build") {
1046                     description = "Compiles native sources for $name"
1047                     matches = ".*\\.rc"
1048                     compiler = variantProperties.rcCompiler
1049                     source(variantProperties.rcSource)
1050                     if (variantProperties.rcFlags) {
1051                         rcParams.addAll(variantProperties.rcFlags)
1052                     }
1053                     output(ccOutput)
1054                 }
1055                 linkTask.dependsOn rcTask;
1056             }
1057         }
1058 
1059         def useLipo = targetProperties.containsKey('useLipo') ? targetProperties.useLipo : false
1060         if (useLipo) {
1061             def lipoTask = project.task("lipo${t.capital}$capitalName", type: LipoTask, dependsOn: javahTask, group: "Build") {
1062                 description = "Creates native fat library for $name for ${t.name}"
1063                 libDir = file("$libRootDir/${t.name}")
1064                 lib = file("$libRootDir/${t.name}/${library(properties.lib)}")
1065             }
1066             nativeTask.dependsOn(lipoTask)
1067         }
1068     }
1069 }
1070 
1071 void addJSL(Project project, String name, String pkg, Closure compile) {
1072     def lowerName = name.toLowerCase()
1073 
1074     def compileCompilers = project.task("compile${name}Compilers", type: JavaCompile, dependsOn: project.compileJava) {


1075         description = "Compile the $name JSL Compilers"

1076         classpath = project.files(project.sourceSets.main.output.classesDir) +
1077                project.files(project.sourceSets.jslc.output.classesDir) +
1078                project.configurations.antlr
1079         source = [project.file("src/main/jsl-$lowerName")]
1080         destinationDir = project.file("$project.buildDir/classes/jsl-compilers/$lowerName")




1081     }
1082 
1083     def generateShaders = project.task("generate${name}Shaders", dependsOn: compileCompilers) {

1084         description = "Generate $name shaders from JSL"
1085         def sourceDir = project.file("src/main/jsl-$lowerName")
1086         def destinationDir = project.file("$project.buildDir/gensrc/jsl-$lowerName")
1087         inputs.dir sourceDir
1088         outputs.dir destinationDir
1089         doLast {
1090             compile(sourceDir, destinationDir)
1091         }
1092     }
1093 
1094     def compileHLSLShaders = project.task("compile${name}HLSLShaders", dependsOn: generateShaders, type: CompileHLSLTask) {


1095         enabled = IS_WINDOWS
1096         description = "Compile $name HLSL files into .obj files"
1097         matches = ".*\\.hlsl"
1098         output project.file("$project.buildDir/hlsl/$name/$pkg")
1099         source project.file("$project.buildDir/gensrc/jsl-$lowerName/$pkg")
1100     }
1101 
1102     def processShaders = project.task("process${name}Shaders", dependsOn: [generateShaders, compileHLSLShaders], type: Copy, description: "Copy hlsl / frag shaders to build/resources/jsl-$lowerName") {



1103         from("$project.buildDir/hlsl/$name") {
1104             include "**/*.obj"
1105         }
1106         from("$project.buildDir/gensrc/jsl-$lowerName") {
1107             include("**/*.frag")
1108         }
1109         into project.sourceSets.main.output.resourcesDir

1110     }
1111 
1112     project.processShaders.dependsOn(processShaders)
1113     project.sourceSets.shaders.output.dir("$project.buildDir/gensrc/jsl-$lowerName", builtBy: processShaders )
1114 
1115 }
1116 
1117 /**
1118  * Parses a JDK version string. The string must be in one of the following
1119  * two formats:
1120  *
1121  *     major.minor.subminor
1122  * or
1123  *     major.minor.subminor_update
1124  *
1125  * In both cases a list of 4 integers is returned, with element 3 set to
1126  * 0 in the former case.
1127  */
1128 List parseJdkVersion(String version) {
1129     def arr = version.split("[_\\.]");


1147     }
1148     return 0;
1149 }
1150 
1151 // Task to verify the minimum level of Java needed to build JavaFX
1152 task verifyJava() {
1153     doLast {
1154         def status = compareJdkVersion(jdkVersion, jfxBuildJdkVersionMin);
1155         if (status < 0) {
1156             fail("java version mismatch: JDK version (${jdkVersion}) < minimum version (${jfxBuildJdkVersionMin})")
1157         } else if (status == 0) {
1158             def buildNum = Integer.parseInt(jdkBuildNumber)
1159             def minBuildNum = Integer.parseInt(jfxBuildJdkBuildnumMin)
1160             if (buildNum != 0 && buildNum < minBuildNum) {
1161                 fail("JDK build number ($buildNum) < minimum build number ($minBuildNum)")
1162             }
1163         }
1164     }
1165 }
1166 
1167 // Task to check whether jfxrt.jar is present in the JDK
1168 task checkJfxrtJar {
1169     doLast {
1170         // The following path is correct when using 8u as boot jdk
1171         def jfxrtFile = new File("$JDK_HOME/jre/lib/ext/jfxrt.jar");
1172         if (jfxrtFile.exists()) {
1173             fail("$jfxrtFile must be removed before building sdk")
1174         }
1175         // The following path is correct when using 9 (pre-jigsaw) as boot jdk
1176         jfxrtFile = new File("$JDK_HOME/lib/jfxrt.jar");
1177         if (jfxrtFile.exists()) {
1178             fail("$jfxrtFile must be removed before building sdk")
1179         }
1180     }
1181 }
1182 
1183 task updateCacheIfNeeded() {
1184     // an empty task we can add to as needed for UPDATE_STUB_CACHE
1185 }
1186 





1187 /*****************************************************************************
1188 *        Project definitions (dependencies, etc)                             *
1189 *****************************************************************************/
1190 
1191 void addJCov(p, test) {
1192     test.doFirst {
1193         def jcovJVMArgument =
1194                 "include=javafx," +
1195                 "include=com.sun.javafx," +
1196                 "include=com.sun.glass," +
1197                 "include=com.sun.openpisces," +
1198                 "include=com.sun.pisces," +
1199                 "include=com.sun.prism," +
1200                 "include=com.sun.scenario," +
1201                 "include=com.sun.webkit," +
1202                 "exclude=com," +
1203                 "exclude=java," +
1204                 "exclude=javax," +
1205                 "exclude=\"**.test\"," +
1206                 "exclude=\"**.*Test\"," +


1223                         "-output", ".",
1224                         "-source", p.sourceSets.main.java.srcDirs.collect{p.file(it)}.join(":"),
1225                         "report.xml"
1226                 ]
1227             }
1228         }
1229     }
1230 }
1231 
1232 allprojects {
1233     // We want to configure all projects as java projects and use the same compile settings
1234     // etc, except for the root project which we just want to ignore (and for now media)
1235     if (project == rootProject) {
1236        return
1237     }
1238     if (project.path.startsWith(":apps")) {
1239         // Lets handle the apps tree differently, as it is a collection of ant builds,
1240         // and the ant importer collides with the 'apply plugin:java'
1241         return
1242     }

1243     // All of our projects are java projects

1244     apply plugin: "java"
1245     sourceCompatibility = 1.8
1246 
1247     // Setup the repositories that we'll download libraries from. Maven Central is
1248     // just easy for most things. The custom "ivy" repo is for downloading SWT. The way it
1249     // works is to setup the download URL such that it will resolve to the actual jar file
1250     // to download. See SWT_FILE_NAME for the name of the jar that will be used as the
1251     // "artifact" in the pattern below. Note that the closed builds use different repositories
1252     // so if you are debugging a closed-build artifact related build issue, check out the
1253     // closed gradle file instead.
1254     if (!BUILD_CLOSED) {
1255         repositories {
1256             mavenCentral()
1257             ivy {
1258                 url "http://download.eclipse.org/eclipse/updates/3.7/R-3.7.2-201202080800/plugins/"
1259                 layout "pattern", {
1260                     artifact "[artifact].[ext]"
1261                 }
1262             }
1263         }
1264     }
1265 
1266     // By default all of our projects require junit for testing so we can just
1267     // setup this dependency here.
1268     dependencies {
1269         testCompile group: "junit", name: "junit", version: "4.8.2"
1270         if (BUILD_CLOSED && DO_JCOV)  {
1271             testCompile name: "jcov"
1272         }
1273     }
1274 
1275     compileJava.dependsOn verifyJava
1276     compileJava.dependsOn checkJfxrtJar
1277 
1278     // Compile and run tests against the jfxrt.jar in the built sdk of the host machine
1279     def sdkDir = "${rootProject.buildDir}/sdk"
1280     def jfxrtJar = "$sdkDir/lib/jfxrt.jar"
1281     def testJfxrtJar = DO_BUILD_SDK_FOR_TEST ? jfxrtJar : jfxrtJarFromSdk
1282 
1283     // At the moment the ASM library shipped with Gradle that is used to
1284     // discover the different test classes fails on Java 8, so in order
1285     // to have sourceCompatibility set to 1.8 I have to also turn scanForClasses off
1286     // and manually specify the includes / excludes. At the moment we use
1287     // Java 7 but when we switch to 8 this will be needed, and probably again when
1288     // we start building with Java 9.
1289     test {
1290         executable = JAVA;
1291         enableAssertions = true;
1292         testLogging.exceptionFormat = "full";
1293         scanForTestClasses = false;
1294         include("**/*Test.*");
1295         if (BUILD_CLOSED && DO_JCOV) {
1296             addJCov(project, test)
1297         }
1298         classpath = files(testJfxrtJar) + classpath
1299         if (IS_HEADLESS_TEST) {
1300             systemProperty 'glass.platform', 'Monocle'
1301             systemProperty 'monocle.platform', 'Headless'
1302             systemProperty 'prism.order', 'sw'
1303             systemProperty 'com.sun.javafx.gestures.zoom', 'true'
1304             systemProperty 'com.sun.javafx.gestures.rotate', 'true'
1305             systemProperty 'com.sun.javafx.gestures.scroll', 'true'
1306         }
1307 
1308         systemProperty 'unstable.test', IS_UNSTABLE_TEST
1309 
1310         if (project.hasProperty("EXTRA_TEST_ARGS")) {
1311             jvmArgs EXTRA_TEST_ARGS.split(' ')
1312         }
1313     }
1314 
1315     compileTestJava {
1316         classpath = files(testJfxrtJar) + classpath
1317     }
1318 
1319     // Exclude any non-public-API classes from having javadoc generated. This block is used
1320     // when generating JavaDocs for a specific project. When generating the JavaDocs for the
1321     // entire SDK, a different javadoc command is used (see the javadoc task on the top level)
1322     javadoc {
1323         enabled = IS_BUILD_JAVADOC
1324         exclude("com/**/*", "Compile*", "javafx/builder/**/*", "javafx/scene/accessibility/**/*");
1325         executable = JAVADOC;
1326         options.windowTitle("JavaFX Project ${project.name} ${RELEASE_VERSION}")
1327         if (BUILD_CLOSED) {
1328             options.linksOffline(JDK_DOCS, JDK_DOCS_CLOSED);
1329         } else {
1330             options.links(JDK_DOCS);
1331         }
1332         options.addBooleanOption("XDignore.symbol.file").setValue(true);
1333         options.addBooleanOption("Xdoclint:none").setValue(!IS_DOC_LINT);
1334         options.addBooleanOption("javafx").setValue(true);
1335         options.addBooleanOption("use").setValue(true);
1336         // All doc-files are located in src/main/docs because Gradle's javadoc doesn't copy
1337         // over the doc-files if they are embedded with the sources. I find this arrangement
1338         // somewhat cleaner anyway (never was a fan of mixing javadoc files with the sources)
1339         doLast {
1340             copy {
1341                 from "src/main/docs"
1342                 into "$buildDir/docs/javadoc"
1343             }
1344         }
1345     }
1346 }
1347 
























1348 // The "base" project is our first module and the most basic one required for
1349 // all other modules. It is useful even for non-GUI applications.
1350 project(":base") {
1351     project.ext.buildModule = true
1352     project.ext.moduleRuntime = true
1353     project.ext.moduleName = "javafx.base"
1354 
1355     Set<String> testInclude = [ "test/**" ]
1356     configureJigsawTests(project, null,
1357         null, testInclude,
1358         project.projectDir.path + "/src/test/addExports"
1359         )
1360 
1361     dependencies {

1362     }
1363 





1364     // We need to take the VersionInfo.java file and replace the various
1365     // properties within it
1366     def replacements = [
1367         "BUILD_TIMESTAMP": BUILD_TIMESTAMP,
1368         "HUDSON_JOB_NAME": HUDSON_JOB_NAME,
1369         "HUDSON_BUILD_NUMBER": HUDSON_BUILD_NUMBER,
1370         "PROMOTED_BUILD_NUMBER": PROMOTED_BUILD_NUMBER,
1371         "PRODUCT_NAME": PRODUCT_NAME,
1372         "RELEASE_VERSION": RELEASE_VERSION,
1373         "RELEASE_SUFFIX": RELEASE_SUFFIX];
1374     task processVersionInfo(type: Copy, description: "Replace params in VersionInfo and copy file to destination") {
1375         doFirst { mkdir "$buildDir/gensrc/java" }
1376         from "src/main/version-info"
1377         into "$buildDir/gensrc/java/com/sun/javafx/runtime"
1378         filter {line->
1379             replacements.each() {k, v ->
1380                 line = line.replace("@$k@", v.toString());
1381             }
1382             line
1383         }
1384     }
1385 
1386     if (IS_COMPILE_JFR) {
1387         sourceSets.main.java.srcDirs += "src/main/java-jfr"
1388     }
1389 
1390     // Make sure to include $buildDir/gensrc/java that we previously created.
1391     // We DO NOT want to include src/main/version-info
1392 
1393     sourceSets.main.java.srcDirs += "$buildDir/gensrc/java"
1394 
1395     compileJava.dependsOn processVersionInfo
1396 }
1397 
1398 // The graphics module is needed for any graphical JavaFX application. It requires
1399 // the base module and includes the scene graph, layout, css, prism, windowing, etc.
1400 // This is a fairly complicated module. There are many different types of native components
1401 // that all need to be compiled.
1402 project(":graphics") {
1403 
1404     apply plugin: 'antlr'




1405 
1406     sourceSets {
1407         antlr  // antlr sources for JSLC
1408         jslc   // JSLC gramar subset
1409         main

1410         shaders // generated shaders (prism & decora)
1411         test
1412         stub
1413     }
1414 
1415     project.ext.buildModule = true
1416     project.ext.moduleRuntime = true
1417     project.ext.moduleName = "javafx.graphics"
1418 
1419     Set<String> testInclude = [ "test/**" ]
1420     configureJigsawTests(project, [ "base" ],
1421         null, testInclude,
1422         project.projectDir.path + "/src/test/addExports"
1423         )
1424 
1425     dependencies {
1426         compile project(":base")
1427         stubCompile group: "junit", name: "junit", version: "4.8.2",
1428         project(":base").sourceSets.test.output, sourceSets.main.output
1429 
1430         jslcCompile  group: "org.antlr", name: "antlr-complete", version: "3.5.2"
1431 
1432         antlr  group: "org.antlr", name: "antlr-complete", version: "3.5.2"
1433     }
1434 
1435     compileJslcJava.dependsOn(generateGrammarSource)
1436     compileJava.dependsOn(compileJslcJava)


1437 





1438     /*
1439     Graphics compilation is "complicated" by the generated shaders.
1440 
1441     We have two shader groups - Decora and Prism.
1442 
1443     The shader groups each will generate a custom compiler that
1444     then genarates the shader code. These compilers rely on the JSLC
1445     gramar parser which is antlr generated and compile separately.
1446 
1447     The decora compiler relies on compileJava - which is sourceSet.main.java
1448     It also accesses module private packages, so will need add-exports
1449 
1450     Once the shader java code is generated, we can compileFullJava
1451 
1452     After that, we can generate the required native header and then build the native code
1453     */
1454 
1455     project.task("processShaders") {
1456         // an empty task to hang the prism and decora shaders on
1457    }
1458 






























1459     project.task("compileFullJava", type: JavaCompile, dependsOn: processShaders) {
1460         description = "Compile all of the graphics java classes - main and shaders"

1461         classpath = configurations.compile

1462         source = project.sourceSets.main.java.srcDirs

1463         source += project.sourceSets.shaders.output



1464         destinationDir = project.sourceSets.main.output.classesDir





1465     }
1466     classes.dependsOn(compileFullJava)
1467 
1468     // Create a single "native" task which will depend on all the individual native tasks for graphics
1469     project.ext.nativeAllTask = task("native", group: "Build", description: "Compiles and Builds all native libraries for Graphics");
1470     project.ext.cleanNativeAllTask = task("cleanNative", group: "Build", description: "Clean all native libraries and objects for Graphics");
1471 
1472     // Add tasks for native compilation
1473     addNative(project, "glass");
1474     addNative(project, "prism")
1475     addNative(project, "prismSW")
1476     addNative(project, "font")
1477     addNative(project, "iio")
1478     addNative(project, "prismES2")
1479 
1480     if (IS_COMPILE_PANGO) {
1481         addNative(project, "fontFreetype")
1482         addNative(project, "fontPango")
1483     }
1484 
1485     if (IS_WINDOWS) {
1486         addNative(project, "prismD3D")
1487         // TODO need to hook this up to be executed only if PassThroughVS.h is missing or PassThroughVS.hlsl is changed
1488         task generateD3DHeaders(group: "Build") {
1489             enabled = IS_WINDOWS
1490             dependsOn javahWinPrismD3D
1491             inputs.file "src/main/native-prism-d3d/hlsl/Mtl1PS.hlsl"
1492             inputs.file "src/main/native-prism-d3d/hlsl/Mtl1VS.hlsl"
1493             inputs.file "src/main/native-prism-d3d/PassThroughVS.hlsl"
1494             outputs.dir "$buildDir/headers/PrismD3D/"
1495             outputs.dir "$buildDir/headers/PrismD3D/hlsl/"
1496             description = "Generate headers by compiling hlsl files"
1497             doLast {
1498                 mkdir file("$buildDir/headers/PrismD3D/hlsl")
1499                 def PS_3D_SRC = file("src/main/native-prism-d3d/hlsl/Mtl1PS.hlsl")
1500                 def VS_3D_SRC = file("src/main/native-prism-d3d/hlsl/Mtl1VS.hlsl")
1501                 def PASSTHROUGH_VS_SRC = file("src/main/native-prism-d3d/PassThroughVS.hlsl")
1502                 def jobs = [
1503                         ["$FXC", "/nologo", "/T", "vs_3_0", "/Fh", "$buildDir/headers/PrismD3D/PassThroughVS.h", "/E", "passThrough", "$PASSTHROUGH_VS_SRC"],
1504                         ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS.h", "/DSpec=0", "/DSType=0", "$PS_3D_SRC"],
1505                         ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_i.h", "/DSpec=0", "/DSType=0", "/DIllumMap=1", "$PS_3D_SRC"],
1506                         ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_s1n.h", "/DSpec=1", "/DSType=0", "$PS_3D_SRC"],
1507                         ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_s2n.h", "/DSpec=2", "/DSType=0", "$PS_3D_SRC"],
1508                         ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_s3n.h", "/DSpec=3", "/DSType=0", "$PS_3D_SRC"],
1509                         ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_s1t.h", "/DSpec=1", "/DSType=1", "$PS_3D_SRC"],
1510                         ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_s2t.h", "/DSpec=2", "/DSType=1", "$PS_3D_SRC"],


1578         }
1579 
1580         ccWinPrismD3D.dependsOn generateD3DHeaders
1581     }
1582 
1583     // The Decora and Prism JSL files have to be generated in a very specific set of steps.
1584     //      1) Compile the *Compile.java classes. These live in src/main/jsl-* and will be
1585     //         output to $buildDir/classes/jsl-compilers/* (where * == decora or prism).
1586     //      2) Generate source files from the JSL files contained in src/main/jsl-*. These
1587     //         will be output to $buildDir/gensrc/jsl-*
1588     //      3) Compile the JSL Java sources in $buildDir/gensrc/jsl-* and put the output
1589     //         into classes/jsl-*
1590     //      4) Compile the native JSL sources in $buildDir/gensrc/jsl-* and put the obj
1591     //         files into native/jsl-* and the resulting library into libs/jsl-*.dll|so|dylib
1592     //      5) Modify the jar step to include classes/jsl-*
1593     // The native library must be copied over during SDK creation time in the "sdk" task. In
1594     // addition to these steps, the clean task is created. Note that I didn't bother to create
1595     // a new task for each of the decora files, preferring instead just to create a rule?? Also
1596     // need "clean" tasks for each compile task.
1597 
1598     addJSL(project, "Decora", "com/sun/scenario/effect/impl/hw/d3d/hlsl") { sourceDir, destinationDir ->
1599         [[fileName: "ColorAdjust", generator: "CompileJSL", outputs: "-all"],
1600          [fileName: "Brightpass", generator: "CompileJSL", outputs: "-all"],
1601          [fileName: "SepiaTone", generator: "CompileJSL", outputs: "-all"],
1602          [fileName: "PerspectiveTransform", generator: "CompileJSL", outputs: "-all"],
1603          [fileName: "DisplacementMap", generator: "CompileJSL", outputs: "-all"],
1604          [fileName: "InvertMask", generator: "CompileJSL", outputs: "-all"],
1605          [fileName: "Blend", generator: "CompileBlend", outputs: "-all"],
1606          [fileName: "PhongLighting", generator: "CompilePhong", outputs: "-all"],
1607          [fileName: "LinearConvolve", generator: "CompileLinearConvolve", outputs: "-hw"],
1608          [fileName: "LinearConvolveShadow", generator: "CompileLinearConvolve", outputs: "-hw"]].each { settings ->
1609             javaexec {
1610                 executable = JAVA
1611                 workingDir = project.projectDir
1612                 main = settings.generator
1613                 classpath = configurations.compile + configurations.antlr
1614                 classpath += files(project.sourceSets.jslc.output.classesDir)
1615 
1616                 //classpath += files(project.sourceSets.jslc.resources) // not quite right..
1617                 classpath += files("${project.projectDir}/src/jslc/resources")
1618 
1619                 classpath += files("$buildDir/classes/main")
1620                 classpath += files("$buildDir/classes/jsl-compilers/decora")
1621                 args = ["-i", sourceDir, "-o", destinationDir, "-t", "-pkg", "com/sun/scenario/effect", "$settings.outputs", "$settings.fileName"]

1622             }
1623         }
1624     }
1625 
1626     task generateDecoraNativeHeaders(type: JavaHeaderTask, dependsOn: compileFullJava) {
1627         description = "Generates JNI Headers for Decora SSE Natives"
1628         source file("$buildDir/classes/main")
1629         include("com/sun/scenario/effect/impl/sw/sse/*");
1630         classpath = files("$buildDir/classes/main")
1631         classpath += files(project.sourceSets.jslc.output.classesDir)
1632         output = file("$buildDir/gensrc/headers/jsl-decora")
1633     }
1634 
1635     task nativeDecora(dependsOn: compileDecoraHLSLShaders, group: "Build") {
1636         description = "Generates JNI headers, compiles, and builds native dynamic library for Decora"
1637     }
1638     task cleanNativeDecora(type: Delete, group: "Build") {
1639         description = "Clean native objects for Decora"
1640     }
1641 
1642     def headerDir = file("$buildDir/gensrc/headers/jsl-decora")
1643     def nativeRootDir = project.file("$project.buildDir/native/jsl-decora")
1644     def libRootDir = project.file("$project.buildDir/libs/jsl-decora")
1645     // For each compile target, create cc and link tasks
1646     compileTargets { t ->
1647         def target = t.name
1648         def upperTarget = t.upper
1649         def capitalTarget = t.capital
1650         def targetProperties = rootProject.ext[upperTarget];
1651         def library = targetProperties.library
1652         def properties = targetProperties.get('decora')
1653         def nativeDir = file("$nativeRootDir/$target");
1654 
1655         def variants = properties.containsKey("variants") ? properties.variants : [""];
1656         variants.each { variant ->
1657             def variantProperties = variant == "" ? properties : properties.get(variant)
1658             def capitalVariant = variant.capitalize()
1659             def ccOutput = variant == "" ? nativeDir : file("$nativeDir/$variant")
1660 
1661             def ccTask = task("compileDecoraNativeShaders$capitalTarget$capitalVariant", type: CCTask, dependsOn: generateDecoraNativeHeaders) {
1662                 description = "Compiles Decora SSE natives for ${t.name}${capitalVariant != '' ? ' for variant ' + capitalVariant : ''}"
1663                 matches = ".*\\.cc"
1664                 source file("$buildDir/gensrc/jsl-decora")
1665                 source file(project.projectDir.path + "/src/main/native-decora")
1666                 headers = headerDir
1667                 params.addAll(variantProperties.ccFlags)
1668                 output(ccOutput)
1669                 compiler = variantProperties.compiler
1670                 cleanNativeDecora.delete ccOutput
1671             }
1672 
1673             def linkTask = task("linkDecoraNativeShaders$capitalTarget$capitalVariant", type: LinkTask, dependsOn: ccTask) {
1674                 description = "Creates native dynamic library for Decora SSE ${t.name}${capitalVariant != '' ? ' for variant ' + capitalVariant : ''}"
1675                 objectDir = ccOutput
1676                 linkParams.addAll(variantProperties.linkFlags)
1677                 lib = file("$libRootDir/$t.name/${library(variantProperties.lib)}")
1678                 linker = variantProperties.linker
1679                 cleanNativeDecora.delete "$libRootDir/$t.name/"
1680             }
1681 
1682             if (IS_WINDOWS && target == "win") {
1683                 def rcTask = project.task("rcDecoraNativeShaders$capitalTarget$capitalVariant", type: CompileResourceTask, dependsOn: generateDecoraNativeHeaders) {
1684                     description = "Compiles native sources for Decora SSE"
1685                     matches = ".*\\.rc"
1686                     compiler = variantProperties.rcCompiler
1687                     source(variantProperties.rcSource)
1688                     if (variantProperties.rcFlags) {
1689                         rcParams.addAll(variantProperties.rcFlags)
1690                     }
1691                     output(ccOutput)
1692                 }
1693                 linkTask.dependsOn rcTask;
1694             }
1695 
1696             nativeDecora.dependsOn(linkTask)
1697         }
1698     }
1699 
1700     // Prism JSL
1701     addJSL(project, "Prism", "com/sun/prism/d3d/hlsl") { sourceDir, destinationDir ->
1702         def inputFiles = fileTree(dir: sourceDir)
1703         inputFiles.include "**/*.jsl"
1704         inputFiles.each { file ->
1705             javaexec {
1706                 executable = JAVA
1707                 workingDir = project.projectDir
1708                 main = "CompileJSL"
1709                 classpath = configurations.compile + configurations.antlr
1710                 classpath += files(project.sourceSets.jslc.output.classesDir)
1711                 classpath += files(project.sourceSets.jslc.resources)
1712                 classpath += files("$buildDir/classes/jsl-compilers/prism",
1713                     project.projectDir.path + "/src/main/jsl-prism") // for the .stg
1714                 args = ["-i", sourceDir, "-o", destinationDir, "-t", "-pkg", "com/sun/prism", "-d3d", "-es2", "-name", "$file"]
1715             }
1716         }
1717     }
1718 
1719     nativePrism.dependsOn compilePrismHLSLShaders;
1720 
1721     project.nativeAllTask.dependsOn nativeDecora


1759             if (!f.exists()) allLibsPresent = false
1760         }
1761         if (allLibsPresent) return;
1762 
1763         for (File f : [configurations.compile.files, configurations.antlr.files].flatten()) {
1764             copy {
1765                 into libsDir
1766                 from f.getParentFile()
1767                 include "**/antlr-complete-3.5.2.jar"
1768                 includeEmptyDirs = false
1769             }
1770         }
1771     }
1772 }
1773 
1774 project(":controls") {
1775     project.ext.buildModule = true
1776     project.ext.moduleRuntime = true
1777     project.ext.moduleName = "javafx.controls"
1778 
1779     Set<String> testInclude = [ "test/**" ]
1780     configureJigsawTests(project, [ "base", "graphics" ],
1781         null, testInclude,
1782         project.projectDir.path + "/src/test/addExports"
1783     )





1784 
1785     dependencies {
1786         compile project(":base"), project(":graphics")
1787         // TODO not sure how to specify this? processResources project(":base"), project(":graphics")
1788         testCompile project(":graphics").sourceSets.test.output
1789         testCompile project(":base").sourceSets.test.output
1790     }
1791 
1792     test {
1793         def cssDir = file("$buildDir/classes/main/javafx")
1794         jvmArgs "-Djavafx.toolkit=test.com.sun.javafx.pgstub.StubToolkit",
1795             "-DCSS_META_DATA_TEST_DIR=$cssDir"
1796     }
1797 
1798     // TODO Css2Bin really should be moved out and put into buildSrc if it can be
1799     // TODO could change script to dynamically locate all .css files and create bss for them, probably better
1800     // TODO also not sure there is any benefit to having css files in the jfxrt.jar at all
1801     processResources << {
1802         ["$buildDir/resources/main/com/sun/javafx/scene/control/skin/caspian/caspian.css",
1803         "$buildDir/resources/main/com/sun/javafx/scene/control/skin/caspian/caspian-no-transparency.css",
1804         "$buildDir/resources/main/com/sun/javafx/scene/control/skin/caspian/embedded-qvga.css",
1805         "$buildDir/resources/main/com/sun/javafx/scene/control/skin/caspian/embedded.css",
1806         "$buildDir/resources/main/com/sun/javafx/scene/control/skin/caspian/fxvk.css",
1807         "$buildDir/resources/main/com/sun/javafx/scene/control/skin/caspian/highcontrast.css",
1808         "$buildDir/resources/main/com/sun/javafx/scene/control/skin/modena/modena.css",
1809         "$buildDir/resources/main/com/sun/javafx/scene/control/skin/modena/modena-no-transparency.css",
1810         "$buildDir/resources/main/com/sun/javafx/scene/control/skin/modena/touch.css"].each { css ->
1811             javaexec {
1812                 executable = JAVA
1813                 workingDir = project.projectDir
1814                 classpath files("$buildDir/classes/main",
1815                         project(":graphics").sourceSets.main.output,
1816                         project(":base").sourceSets.main.output)
1817                 main = "com.sun.javafx.css.parser.Css2Bin"
1818                 args css
1819             }
1820         }
1821     }
1822 }
1823 
1824 project(":swing") {
1825     /* should not be built, but needed in JMX
1826     tasks.all {
1827         if (!COMPILE_SWING) it.enabled = false
1828     }
1829     */
1830     project.ext.buildModule = COMPILE_SWING
1831     project.ext.moduleRuntime = true
1832     project.ext.moduleName = "javafx.swing"
1833 
1834     dependencies {
1835         compile project(":base"), project(":graphics")


1836     }
1837 
1838     Set<String> testInclude = [ "test/**" ]
1839     configureJigsawTests(project, [ "base", "graphics", "controls" ],
1840         null, testInclude,
1841         null // no addExports
1842     )


1843 
1844     test {
1845         enabled = IS_FULL_TEST && IS_AWT_TEST
1846     }
1847 }
1848 
1849 project(":swt") {
1850     tasks.all {
1851         if (!COMPILE_SWT) it.enabled = false
1852     }
1853 
1854     // javafx.swt is an automatic module
1855     project.ext.buildModule = false
1856 


1857     dependencies {
1858         compile project(":base"), project(":graphics")
1859         compile name: SWT_FILE_NAME
1860     }

1861     classes << {
1862         // Copy all of the download libraries to libs directory for the sake of the IDEs
1863         File libsDir = rootProject.file("build/libs");
1864         File swtLib = new File(libsDir, "swt-debug.jar")
1865         libsDir.mkdirs();
1866 
1867         // Skip copy if file is present.
1868         if (swtLib.exists()) return;
1869 
1870         for (File f : configurations.compile.files) {
1871             // Have to rename the swt jar because it is some platform specific name but
1872             // for the sake of the IDEs we need to have a single stable name that works
1873             // on every platform
1874             copy {
1875                 into libsDir
1876                 from f.getParentFile()
1877                 include "**/*swt*.jar"
1878                 includeEmptyDirs = false
1879                 rename ".*swt.*jar", "swt-debug\\.jar"
1880             }
1881         }
1882     }
1883 








1884     test {
1885         if (IS_JIGSAW_TEST) {

1886             enabled = false // FIXME: JIGSAW -- support this with modules
1887             logger.info("JIGSAW Testing disabled for swt")
1888         } else {
1889             enabled = IS_FULL_TEST && IS_SWT_TEST
1890             if (IS_MAC) {
1891                 enabled = false
1892                 logger.info("SWT tests are disabled on MAC, because Gradle test runner does not handle -XstartOnFirstThread properly (https://issues.gradle.org/browse/GRADLE-3290).")
1893             }
1894         }
1895     }
1896 }
1897 
1898 project(":fxml") {
1899     project.ext.buildModule = true
1900     project.ext.moduleRuntime = true
1901     project.ext.moduleName = "javafx.fxml"
1902 
1903     Set<String> testInclude = [ "test/**" ]
1904     configureJigsawTests(project, [ "base", "graphics" ],
1905         null, testInclude,
1906         project.projectDir.path + "/src/test/addExports"
1907     )






1908 
1909     dependencies {
1910         compile project(":base"),
1911                 project(":graphics"),
1912                 project(":controls")
1913         testCompile project(":graphics").sourceSets.test.output

1914     }

1915     test {
1916         // StubToolkit is not *really* needed here, but because some code inadvertently invokes performance
1917         // tracker and this attempts to fire up the toolkit and this looks for native libraries and fails,
1918         // we have to use the stub toolkit for now.
1919         jvmArgs "-Djavafx.toolkit=test.com.sun.javafx.pgstub.StubToolkit"
1920         // FIXME: change this to also allow JDK 9 boot jdk
1921         classpath += files("$JDK_HOME/jre/lib/ext/nashorn.jar")
1922     }
1923 }
1924 
1925 project(":jmx") {
1926     project.ext.buildModule = false // true
1927     project.ext.moduleRuntime = false
1928     project.ext.moduleName = "javafx.jmx"



1929     dependencies {
1930         compile project(":base")
1931         compile project(":graphics")
1932         compile project(":swing")
1933         compile project(":media")
1934     }
1935 
1936     // Tests are disabled until RT-33926 can be fixed
1937     test.enabled = false
1938 
1939     if (!DO_BUILD_SDK_FOR_TEST) {
1940        def javafxMxJar = new File(TEST_SDK_DIR, "lib/javafx-mx.jar")
1941        [test, compileTestJava].each {
1942            it.classpath = files(javafxMxJar) + it.classpath
1943        }
1944     }




1945 }
1946 
1947 project(":fxpackagerservices") {
1948     project.ext.buildModule = COMPILE_FXPACKAGER
1949     project.ext.moduleRuntime = false
1950     project.ext.moduleName = "jdk.packager.services"












1951     tasks.all {
1952         if (!COMPILE_FXPACKAGER) it.enabled = false
1953     }
1954 



1955     test {
1956         if (IS_JIGSAW_TEST) {
1957             enabled = false // FIXME: JIGSAW -- support this with modules
1958             logger.info("JIGSAW Testing disabled for fxpackagerservices")
1959         }
1960     }
1961 }
1962 
1963 project(":fxpackager") {
1964     project.ext.buildModule = COMPILE_FXPACKAGER
1965     project.ext.moduleRuntime = false
1966     project.ext.moduleName = "jdk.packager"












1967     manifest {
1968         attributes(
1969                 "Main-Class": "com.sun.javafx.tools.packager.Main"
1970         )
1971     }

1972     tasks.all {
1973         if (!COMPILE_FXPACKAGER) it.enabled = false
1974     }
1975 











1976     // fxpackager has a dependency on ant in order to build the ant jar,
1977     // and as such needs to point to the apache binary repository
1978     if (!BUILD_CLOSED) {
1979         repositories {
1980             maven {
1981                 url "https://repository.apache.org"
1982             }
1983         }
1984     }
1985 
1986     dependencies {
1987         compile group: "org.apache.ant", name: "ant", version: "1.8.2"
1988         compile project(":fxpackagerservices")
1989         testCompile project(":controls")




























1990     }
1991 
1992     // When producing the jar, we need to relocate a few class files
1993     // from their normal location to a resources/classes or resources/web-files
1994     // location
1995     jar {
1996         includeEmptyDirs = false
1997         archiveName = "ant-javafx.jar"
1998         includes = ["com/sun/javafx/tools/ant/**", "com/javafx/main/**", "resources/web-files/**"]

1999         eachFile { FileCopyDetails details ->
2000             if (details.path.startsWith("com/javafx/main")) {
2001                 details.path = "resources/classes/$details.path"
2002             }
2003         }
2004     }
2005 











2006     // The "man" task will create a $buildDir/man containing the man
2007     // files for the system being built
2008     task man(type: Copy) {
2009         includeEmptyDirs = false
2010         enabled = (IS_LINUX || IS_MAC) && COMPILE_FXPACKAGER
2011         from "src/main/man"
2012         into "$buildDir/man"
2013         exclude "**/*.html"
2014         if (IS_MAC) exclude "**/ja_JP.UTF-8/**"
2015     }
2016     processResources.dependsOn man
2017 


2018     // Compile the native launchers. These are included in jdk.packager.jmod.
2019     if (IS_WINDOWS && COMPILE_FXPACKAGER) {
2020         task buildWinLauncher(type: CCTask, group: "Build") {
2021             description = "Compiles native sources for the application co-bundle launcher";
2022             matches = "WinLauncher\\.cpp";
2023             params.addAll(WIN.launcher.ccFlags);
2024             output(file("$buildDir/native/WinLauncher"));
2025             source(file("src/main/native/launcher/win"));
2026             compiler = WIN.launcher.compiler
2027             exe = true;
2028             linkerOptions.addAll(WIN.launcher.linkFlags);
2029             doLast {
2030                 copy {
2031                     from "$buildDir/native/WinLauncher/WinLauncher.exe"
2032                     from "$MSVCR"
2033                     from "$MSVCP"
2034                     into "$buildDir/classes/main/com/oracle/tools/packager/windows"
2035                 }
2036             }
2037         }
2038         task compileWinLibrary(type: CCTask, group: "Build") {
2039             description = "Compiles native sources for the application co-bundle launcher library";
2040             matches = ".*\\.cpp"
2041             source(file("src/main/native/library/common"));
2042             params.addAll(WIN.launcherlibrary.ccFlags)
2043             output(file("$buildDir/native/WinLauncher/obj"));
2044             compiler = WIN.launcherlibrary.compiler
2045         }
2046         task linkWinLibrary(type: LinkTask, group: "Build", dependsOn: compileWinLibrary) {
2047             description = "Links native sources for the application co-bundle launcher library";
2048             objectDir = file("$buildDir/native/WinLauncher/obj")
2049             linkParams.addAll(WIN.launcherlibrary.linkFlags);
2050             lib = file("$buildDir/native/WinLauncher/packager.dll")
2051             linker = WIN.launcherlibrary.linker
2052             doLast {
2053                 copy {
2054                     from "$buildDir/native/WinLauncher/packager.dll"
2055                     into "$buildDir/classes/main/com/oracle/tools/packager/windows"
2056                 }
2057             }
2058         }
2059         task buildWinLauncherSvc(type: CCTask, group: "Build") {
2060             description = "Compiles native sources for the application co-bundle launcher";
2061             matches = "WinLauncherSvc\\.cpp";
2062             params.addAll(WIN.launcher.ccFlags);
2063             output(file("$buildDir/native/WinLauncherSvc"));
2064             source(file("src/main/native/service/win"));
2065             compiler = WIN.launcher.compiler
2066             exe = true;
2067             linkerOptions.addAll(WIN.launcher.linkFlags);
2068             doLast {
2069                 copy {
2070                     from "$buildDir/native/WinLauncherSvc/WinLauncherSvc.exe"
2071                     into "$buildDir/classes/main/com/oracle/tools/packager/windows"
2072                 }
2073             }
2074         }
2075         task buildIconSwap(type: CCTask, group: "Build") {
2076             description = "Compiles native sources for the application co-bundle launcher"
2077             matches = "IconSwap\\.cpp"
2078             params.addAll(WIN.iconLauncher.ccFlags)
2079             output(file("$buildDir/native/IconSwap"))
2080             source file("src/main/native/tools/win/iconswap")
2081             compiler = WIN.launcher.compiler
2082             exe = true
2083             linkerOptions.addAll(WIN.iconLauncher.linkFlags)
2084             doLast {
2085                 copy {
2086                     from "$buildDir/native/IconSwap/IconSwap.exe"
2087                     into "$buildDir/classes/main/com/oracle/tools/packager/windows"
2088                 }
2089             }
2090         }
2091         task compileVersionInfoSwap(type: CCTask, group: "Build") {
2092             description = "Compiles native sources for the VersionInfoSwap tool";
2093             matches = ".*\\.cpp"
2094             source(file("src/main/native/tools/win/versioninfoswap"));
2095             params.addAll(WIN.versionInfoLauncher.ccFlags)
2096             output(file("$buildDir/native/VersionInfoSwap/obj"));
2097             compiler = WIN.versionInfoLauncher.compiler
2098         }
2099         task linkVersionInfoSwap(type: LinkTask, group: "Build", dependsOn: compileVersionInfoSwap) {
2100             description = "Links native sources for the VersionInfoSwap tool";
2101             objectDir = file("$buildDir/native/VersionInfoSwap/obj")
2102             linkParams.addAll(WIN.versionInfoLauncher.linkFlags);
2103             lib = file("$buildDir/native/VersionInfoSwap/VersionInfoSwap.exe")
2104             linker = WIN.versionInfoLauncher.linker
2105             doLast {
2106                 copy {
2107                     from "$buildDir/native/VersionInfoSwap/VersionInfoSwap.exe"
2108                     into "$buildDir/classes/main/com/oracle/tools/packager/windows"
2109                 }
2110             }
2111         }
2112         task compileLauncher(dependsOn: [buildWinLauncher, linkWinLibrary, buildWinLauncherSvc, buildIconSwap, linkVersionInfoSwap])
2113         jar.dependsOn compileLauncher;
2114     } else if (IS_MAC && COMPILE_FXPACKAGER) {
2115         task buildMacLauncher(type: CCTask, group: "Build") {
2116             description = "Compiles native sources for the application co-bundle launcher"
2117             matches = ".*\\.m"
2118             source file("src/main/native/launcher/mac")
2119             params.addAll(MAC.launcher.ccFlags)
2120             compiler = MAC.launcher.compiler
2121             output(file("$buildDir/classes/main/com/oracle/tools/packager/mac"))
2122             outputs.file(file("$buildDir/classes/main/com/oracle/tools/packager/mac/JavaAppLauncher"))
2123             eachOutputFile = { f ->
2124                 return new File(f.getParent(), "JavaAppLauncher")
2125             }
2126         }
2127         task compileMacLibrary(type: CCTask, group: "Build") {
2128             description = "Compiles native sources for the application co-bundle launcher library"
2129             matches = ".*\\.cpp|.*\\.mm"
2130             source file("src/main/native/library/common");
2131             params.addAll(MAC.launcherlibrary.ccFlags)
2132             compiler = MAC.launcherlibrary.compiler
2133             output(file("$buildDir/native/maclauncher/obj"))
2134         }
2135         task linkMacLibrary(type: LinkTask, group: "Build", dependsOn: compileMacLibrary) {
2136             description = "Links native sources for the application co-bundle launcher library"
2137             objectDir = file("$buildDir/native/maclauncher/obj")
2138             linkParams.addAll(MAC.launcherlibrary.linkFlags)
2139             linker = MAC.launcherlibrary.linker
2140             lib = file("$buildDir/classes/main/com/oracle/tools/packager/mac/libpackager.dylib")
2141         }
2142         task compileLauncher(dependsOn: [buildMacLauncher, linkMacLibrary])
2143         jar.dependsOn compileLauncher;
2144     } else if (IS_LINUX && COMPILE_FXPACKAGER) {
2145         task compileLinuxLauncher(type: CCTask, group: "Build") {
2146             description = "Compiles native sources for the application co-bundle launcher"
2147             matches = ".*\\.cpp"
2148             source file("src/main/native/launcher/linux")
2149             params.addAll(LINUX.launcher.ccFlags)
2150             compiler = LINUX.launcher.compiler
2151             output(file("$buildDir/native/linuxlauncher/launcherobj"))
2152         }
2153         task linkLinuxLauncher(type: LinkTask, dependsOn: compileLinuxLauncher, group: "Build") {
2154             description = "Links native dynamic library for the application co-bundle launcher"
2155             objectDir = file("$buildDir/native/linuxlauncher/launcherobj")
2156             linkParams.addAll(LINUX.launcher.linkFlags)
2157             linker = LINUX.launcher.linker
2158             lib = file("$buildDir/classes/main/com/oracle/tools/packager/linux/JavaAppLauncher")
2159         }
2160         task compileLinuxLibrary(type: CCTask, group: "Build") {
2161             description = "Compiles native sources for the application co-bundle launcher library"
2162             matches = ".*\\.cpp"
2163             source file("src/main/native/library/common")
2164             params.addAll(LINUX.launcherlibrary.ccFlags)
2165             compiler = LINUX.launcherlibrary.compiler
2166             output(file("$buildDir/native/linuxlauncher/obj"))
2167         }
2168         task linkLinuxLibrary(type: LinkTask, dependsOn: compileLinuxLibrary, group: "Build") {
2169             description = "Links native dynamic library for the application co-bundle launcher library"
2170             objectDir = file("$buildDir/native/linuxlauncher/obj")
2171             linkParams.addAll(LINUX.launcherlibrary.linkFlags)
2172             linker = LINUX.launcherlibrary.linker
2173             lib = file("$buildDir/classes/main/com/oracle/tools/packager/linux/libpackager.so")
2174         }
2175         task compileLauncher(dependsOn: [linkLinuxLauncher, linkLinuxLibrary])
2176         jar.dependsOn compileLauncher;
2177     }
2178 
2179     // Builds the javapackager executable. For everything other than windows,
2180     // this is simply moving the existing shell script and ensuring it has proper
2181     // permissions. For Windows, this includes compiling the native executable
2182     if (IS_WINDOWS && COMPILE_FXPACKAGER){
2183         task buildJavaPackager(type: CCTask, group: "Build") {
2184             description = "Compiles native sources for javapackager.exe"
2185             matches = "javapackager\\.cpp"
2186             params.addAll(WIN.fxpackager.ccFlags)
2187             compiler = WIN.fxpackager.compiler
2188             output(file("$buildDir/native/javapackager"))
2189             source WIN.fxpackager.nativeSource
2190             doFirst {
2191                 copy {
2192                     mkdir "$buildDir/native"
2193                     mkdir "$buildDir/native/javapackager"
2194                     from file("src/main/native/javapackager/win/javapackager.manifest")
2195                     into file("$buildDir/native/javapackager")
2196                     filter { line->


2227                 })
2228                 copy {
2229                     from file("$buildDir/native/javapackager/javapackager.exe")
2230                     into file("$buildDir/javapackager")
2231                 }
2232             }
2233         }
2234     } else {
2235         task buildJavaPackager(group: "Build") {
2236             enabled = COMPILE_FXPACKAGER
2237             doLast {
2238                 copy {
2239                     from "src/main/native/javapackager/shell"
2240                     into "$buildDir/javapackager"
2241                     fileMode = 0755
2242                 }
2243             }
2244         }
2245     }
2246 
2247     jar.dependsOn buildJavaPackager

2248 
2249     classes << {
2250         // Copy all of the download libraries to libs directory for the sake of the IDEs
2251         File libsDir = rootProject.file("build/libs");
2252         File antLib = new File(libsDir, "ant-1.8.2.jar")
2253         libsDir.mkdirs();
2254 
2255         // Skip copy if file is present.
2256         if (antLib.exists()) return;
2257 
2258         for (File f : configurations.compile.files) {
2259             copy {
2260                 into libsDir
2261                 from f.getParentFile()
2262                 include "**/ant-1.8.2.jar"
2263                 includeEmptyDirs = false
2264             }
2265         }
2266     }
2267 


2305         from compileTestJava.destinationDir
2306         include "hello/**"
2307 
2308         destinationDir project.file("build/tmp/tests/appResources")
2309         archiveName "packagedMainApp.jar"
2310 
2311         manifest {
2312             attributes(
2313                 "JavaFX-Application-Class": "hello.TestPackager",
2314             )
2315         }
2316     }
2317 
2318     if (!DO_BUILD_SDK_FOR_TEST) {
2319         def antJavafxJar = new File(TEST_SDK_DIR, "lib/ant-javafx.jar")
2320         [compileTestJava, test].each {
2321             it.classpath = files(antJavafxJar) + it.classpath
2322         }
2323     }
2324 

2325     test {
2326         if (IS_JIGSAW_TEST) {
2327             enabled = false // FIXME: JIGSAW -- support this with modules
2328             logger.info("JIGSAW Testing disabled for fxpackager")
2329         }
2330 
2331         dependsOn packagerFXPackagedJar
2332         systemProperty "RETAIN_PACKAGER_TESTS", RETAIN_PACKAGER_TESTS
2333         systemProperty "TEST_PACKAGER_DMG", TEST_PACKAGER_DMG
2334         systemProperty "FULL_TEST", FULL_TEST
2335         executable = JIGSAW_JAVA;
2336     }
2337 
2338     def packagerDevOpts = []
2339     try {
2340         packagerDevOpts.addAll(PACKAGER_DEV_OPTS.split(' '))
2341     } catch (MissingPropertyException ignore) {
2342         packagerDevOpts.addAll("image")
2343     }
2344 
2345     task packagerDev(dependsOn: [jar, testClasses, packagerFakeJar], type:JavaExec) {
2346         workingDir = project.file("build/tmp/tests/appResources/")
2347         executable = JIGSAW_JAVA
2348         classpath = project.files("build/libs/ant-javafx.jar", "build/classes/test", "build/resources/test")
2349         main = "hello.SimpleBundle"
2350         args = [
2351                 '--module-path', JIGSAW_MODULES,
2352                 '-o', "$projectDir/build/dev",
2353                 '-all',
2354                 packagerDevOpts
2355         ].flatten()
2356     }
2357 
2358     task buildRedistributableFiles() {
2359         def projectDir = "tools/java/redistributable-files"
2360         def sourceDir = "src/$projectDir"
2361         def buildDir = "build/$projectDir"
2362 
2363         doLast {
2364             exec {
2365                 commandLine(JIGSAW_JAVAC)
2366                 args("-d")
2367                 args("$buildDir")
2368                 args("$sourceDir/RedistributableFiles.java")
2369             }
2370         }
2371     }
2372 
2373     task runRedistributableFiles() {
2374         def projectDir = "tools/java/redistributable-files"
2375         def sourceDir = "src/$projectDir"
2376         def buildDir = "build/$projectDir"
2377         def resourceDir = "build/resources/main/jdk/packager/internal/resources/tools/redistributable-files"
2378 
2379         doLast {
2380             def fxmodules = ""
2381 
2382             if (!file("$JIGSAW_MODULES/jdk.packager.jmod").exists()) {
2383                 moduleProjList.each { project ->
2384                     if (fxmodules.isEmpty()) {
2385                         fxmodules = project.ext.moduleName
2386                     }
2387                     else {
2388                         fxmodules += "," + project.ext.moduleName
2389                     }
2390                 }
2391             }
2392 
2393             exec {
2394                 commandLine(JIGSAW_JAVA)
2395                 args("-classpath")
2396                 args("$buildDir")
2397                 args("RedistributableFiles")
2398                 args("--module-path")
2399                 args("$JIGSAW_MODULES")
2400                 args("--exclude-filelist")
2401                 args("$sourceDir/exclude_modules.list")
2402                 args("--out-file")
2403                 args("$resourceDir/redistributable.list")
2404 
2405                 if (!fxmodules.isEmpty()) {
2406                     args("--add-modules")
2407                     args("$fxmodules")
2408                 }
2409             }
2410         }
2411     }
2412 
2413     runRedistributableFiles.dependsOn buildRedistributableFiles
2414     processResources.dependsOn runRedistributableFiles
2415 }
2416 
2417 project(":media") {
2418     configurations {
2419         media
2420     }
2421 
2422     project.ext.buildModule = true
2423     project.ext.moduleRuntime = true
2424     project.ext.moduleName = "javafx.media"
2425 














2426     dependencies {
2427         compile project(":base"), project(":graphics")
2428     }
2429 
2430     compileJava.dependsOn updateCacheIfNeeded
2431 
2432     sourceSets {
2433         tools {
2434             java.srcDir "src/tools/java"
2435         }

2436     }
2437 
2438     compileToolsJava {
2439         enabled = IS_COMPILE_MEDIA
2440         classpath = sourceSets.main.output;



2441     }
2442 
2443     project.ext.makeJobsFlag = IS_WINDOWS && IS_DEBUG_NATIVE ? "-j1" : "-j5";
2444     project.ext.buildType = IS_DEBUG_NATIVE ? "Debug" : "Release";
2445 
2446     def nativeSrcDir = file("${projectDir}/src/main/native")
2447     def generatedHeadersDir = file("${buildDir}/gensrc/headers")
2448 
2449     task generateHeaders(dependsOn: compileJava) {
2450         enabled = IS_COMPILE_MEDIA
2451         doLast {
2452             def classpath = sourceSets.main.output;
2453             mkdir generatedHeadersDir;
2454 
2455             def classesList = ["com.sun.media.jfxmedia.logging.Logger",
2456                              "com.sun.media.jfxmedia.track.AudioTrack",
2457                              "com.sun.media.jfxmedia.control.VideoDataBuffer",
2458                              "com.sun.media.jfxmedia.control.VideoFormat\$FormatTypes",
2459                              "com.sun.media.jfxmediaimpl.NativeAudioClip",
2460                              "com.sun.media.jfxmediaimpl.NativeMediaPlayer",
2461                              "com.sun.media.jfxmediaimpl.NativeVideoBuffer",
2462                              "com.sun.media.jfxmediaimpl.platform.gstreamer.GSTPlatform",
2463                              "com.sun.media.jfxmediaimpl.platform.gstreamer.GSTMedia",
2464                              "com.sun.media.jfxmediaimpl.platform.gstreamer.GSTMediaPlayer",
2465                              "com.sun.media.jfxmediaimpl.NativeAudioEqualizer",
2466                              "com.sun.media.jfxmediaimpl.NativeEqualizerBand",
2467                              "com.sun.media.jfxmediaimpl.NativeAudioSpectrum"]
2468             if (IS_MAC) {
2469                 classesList.addAll( ["com.sun.media.jfxmediaimpl.platform.osx.OSXPlatform",
2470                                      "com.sun.media.jfxmediaimpl.platform.osx.OSXMedia",
2471                                      "com.sun.media.jfxmediaimpl.platform.osx.OSXMediaPlayer"] );
2472             }
2473             exec {
2474                 commandLine ("${JAVAH}", "-d", "${generatedHeadersDir}", "-classpath", "${classpath.asPath}");
2475                 args classesList;
2476             }
2477         }
2478     }
2479 
2480     task generateMediaErrorHeader(dependsOn: [compileToolsJava, compileJava]) {
2481         enabled = IS_COMPILE_MEDIA

2482         doLast {
2483             def classpath = files(sourceSets.main.output, sourceSets.tools.output);
2484             def sourcepath = sourceSets.main.java.srcDirs;
2485             def headerpath = file("$generatedHeadersDir/jfxmedia_errors.h");
2486             def srcRoot = (sourcepath.toArray())[0];
2487 
2488             mkdir generatedHeadersDir;
2489 
2490             exec {
2491                 commandLine("$JAVA", "-classpath", "${classpath.asPath}");
2492                 args("headergen.HeaderGen", "$headerpath", "$srcRoot");



2493             }
2494         }

2495     }
2496 
2497     task buildNativeTargets {
2498         enabled = IS_COMPILE_MEDIA
2499     }
2500 
2501     compileTargets { t->
2502         def targetProperties = project.rootProject.ext[t.upper]
2503         def nativeOutputDir = file("${buildDir}/native/${t.name}")
2504         def projectDir = t.name.startsWith("arm") ? "linux" : t.name
2505         def mediaProperties = targetProperties.media
2506         // Makefile for OSX needs to know if we're building for parfait
2507         def compileParfait = IS_COMPILE_PARFAIT ? "true" : "false"
2508 
2509         def buildNative = task("build${t.capital}Native", dependsOn: [generateHeaders, generateMediaErrorHeader]) {
2510             enabled = targetProperties.compileMediaNative
2511             if (!targetProperties.compileMediaNative) {
2512                 println("Not compiling native Media for ${t.name} per configuration request");
2513             }
2514 
2515             doLast {
2516                 exec {
2517                     commandLine ("make", "${makeJobsFlag}", "-C", "${nativeSrcDir}/jfxmedia/projects/${projectDir}")
2518                     args("JAVA_HOME=${JDK_HOME}", "GENERATED_HEADERS_DIR=${generatedHeadersDir}",
2519                          "OUTPUT_DIR=${nativeOutputDir}", "BUILD_TYPE=${buildType}", "BASE_NAME=jfxmedia",
2520                          "COMPILE_PARFAIT=${compileParfait}",
2521                          IS_64 ? "ARCH=x64" : "ARCH=x32",
2522                         "CC=${mediaProperties.compiler}", "LINKER=${mediaProperties.linker}")
2523 
2524                     if (t.name == "win") {
2525                         environment(WINDOWS_NATIVE_COMPILE_ENVIRONMENT)
2526                         args( "RESOURCE=${nativeOutputDir}/${buildType}/${WIN.media.jfxmediaRcFile}")
2527                     } else {
2528                         if (t.name.startsWith("arm")) {
2529                             args("EXTRA_CFLAGS=${mediaProperties.extra_cflags}", "EXTRA_LDFLAGS=${mediaProperties.extra_ldflags}")


2712     }
2713 
2714     jar {
2715         exclude("headergen/**")
2716 
2717         dependsOn compileJava
2718         if (IS_COMPILE_MEDIA) {
2719             dependsOn buildNativeTargets
2720         }
2721     }
2722 }
2723 
2724 project(":web") {
2725     configurations {
2726         webkit
2727     }
2728     project.ext.buildModule = true
2729     project.ext.moduleRuntime = true
2730     project.ext.moduleName = "javafx.web"
2731 
2732     Set<String> testInclude = [ "test/**" ]
2733     configureJigsawTests(project, [ "base", "graphics" ],
2734         null, testInclude,
2735         project.projectDir.path + "/src/test/addExports"
2736         )





2737 
2738     dependencies {
2739         compile project(":base"), project(":graphics"), project(":controls"), project(":media")
2740     }
2741 
2742     compileJava.dependsOn updateCacheIfNeeded
2743 
2744     task webArchiveJar(type: Jar) {
2745         from (project.file("$projectDir/src/test/resources/test/html")) {
2746             include "**/archive-*.*"
2747         }
2748         archiveName = "webArchiveJar.jar"
2749         destinationDir = file("$buildDir/testing/resources")
2750     }
2751 



























2752     test {

2753         if (!IS_JIGSAW_TEST) {
2754         //TODO: support this in Jake
2755         // Run web tests in headless mode
2756         systemProperty 'glass.platform', 'Monocle'
2757         systemProperty 'monocle.platform', 'Headless'
2758         systemProperty 'prism.order', 'sw'
2759         }

2760         dependsOn webArchiveJar
2761         def testResourceDir = file("$buildDir/testing/resources")
2762         jvmArgs "-DWEB_ARCHIVE_JAR_TEST_DIR=$testResourceDir"
2763     }
2764 
2765     if (!IS_COMPILE_WEBKIT) {
2766         // Include wrapper classes that are otherwise generated by native build
2767         sourceSets.main.java.srcDirs += "src/main/java-wrappers"
2768     }
2769 
2770     task generateHeaders(dependsOn: compileJava) {
2771         doLast {
2772             def classpath = files("$buildDir/classes/main",
2773                                   project(":graphics").sourceSets.main.output.classesDir)
2774             def dest = file("$buildDir/gensrc/headers");
2775             mkdir dest;
2776             exec {
2777                 commandLine("$JAVAH", "-d", "$dest",
2778                             "-classpath", "${classpath.asPath}");
2779                 args("java.lang.Character",
2780                      "java.net.IDN",
2781                      "com.sun.webkit.ContextMenu",
2782                      "com.sun.webkit.ContextMenuItem",
2783                      "com.sun.webkit.CursorManager",
2784                      "com.sun.webkit.PageCache",
2785                      "com.sun.webkit.PopupMenu",
2786                      "com.sun.webkit.SharedBuffer",
2787                      "com.sun.webkit.WatchdogTimer",
2788                      "com.sun.webkit.WebPage",
2789                      "com.sun.webkit.LoadListenerClient",
2790                      "com.sun.webkit.event.WCFocusEvent",
2791                      "com.sun.webkit.event.WCKeyEvent",
2792                      "com.sun.webkit.event.WCMouseEvent",
2793                      "com.sun.webkit.event.WCMouseWheelEvent",
2794                      "com.sun.webkit.graphics.GraphicsDecoder",
2795                      "com.sun.webkit.graphics.RenderMediaControls",
2796                      "com.sun.webkit.graphics.RenderTheme",
2797                      "com.sun.webkit.graphics.ScrollBarTheme",
2798                      "com.sun.webkit.graphics.WCMediaPlayer",
2799                      "com.sun.webkit.graphics.WCGraphicsManager",
2800                      "com.sun.webkit.graphics.WCRenderQueue",
2801                      "com.sun.webkit.graphics.WCPath",
2802                      "com.sun.webkit.graphics.WCPathIterator",
2803                      "com.sun.webkit.Timer",
2804                      "com.sun.webkit.WCFrameView",
2805                      "com.sun.webkit.WCPasteboard",
2806                      "com.sun.webkit.WCPluginWidget",
2807                      "com.sun.webkit.dom.JSObject",
2808                      "com.sun.webkit.network.SocketStreamHandle",
2809                      "com.sun.webkit.network.URLLoader",
2810                      "com.sun.webkit.text.TextBreakIterator",
2811                      "com.sun.webkit.text.TextNormalizer");
2812             }
2813         }
2814     }
2815 
2816     task compileGenerated()
2817 
2818     compileTargets { t ->
2819         def targetProperties = project.rootProject.ext[t.upper]
2820         def classifier = (t.name != "linux" && t.name != "win") ? t.name :
2821                           IS_64 ? "${t.name}-amd64" : "${t.name}-i586"
2822         dependencies {
2823             webkit group: "com.sun.webkit", name: "webview-deps",
2824                    version: "1.3.1", classifier: "$classifier", ext: "zip"
2825         }
2826 
2827         def webkitOutputDir = cygpath("$buildDir/${t.name}")
2828         def webkitConfig = IS_DEBUG_NATIVE ? "Debug" : "Release"
2829 
2830         def compileNativeTask = task("compileNative${t.capital}", dependsOn: generateHeaders) << {
2831             println "Building Webkit configuration /$webkitConfig/ into $webkitOutputDir"

2832 



2833             def dependencyFile = configurations.webkit.filter(
2834                     { File f -> f.getName().contains(classifier) }
2835                 ).getSingleFile()
2836             ant.unzip(src:  dependencyFile,
2837                       dest: webkitOutputDir)
2838 
2839             exec {
2840                 workingDir("$projectDir/src/main/native")
2841                 commandLine("perl", "Tools/Scripts/set-webkit-configuration", "--$webkitConfig")
2842                 environment(["WEBKIT_OUTPUTDIR" : webkitOutputDir])
2843             }
2844 
2845             exec {
2846                 workingDir("$projectDir/src/main/native")
2847                 def cmakeArgs = "-DENABLE_TOOLS=1"
2848                 if (t.name == "win") {
2849                     String parfaitPath = IS_COMPILE_PARFAIT ? System.getenv().get("PARFAIT_PATH") + ";" : "";
2850                     Map environmentSettings = new HashMap(WINDOWS_NATIVE_COMPILE_ENVIRONMENT)
2851                     environmentSettings["PATH"] = parfaitPath + "$WINDOWS_VS_PATH"
2852                     /* To build with ICU:


2884                 if (IS_64) {
2885                     targetCpuBitDepthSwitch = "--64-bit"
2886                 } else {
2887                     targetCpuBitDepthSwitch = "--32-bit"
2888                 }
2889 
2890                 commandLine("perl", "Tools/Scripts/build-webkit",
2891                     "--java", "--icu-unicode", targetCpuBitDepthSwitch,
2892                     "--cmakeargs=${cmakeArgs}")
2893             }
2894 
2895             def library = rootProject.ext[t.upper].library
2896             copy {
2897                 from "$webkitOutputDir/$webkitConfig/lib/${library('jfxwebkit')}"
2898                 into "$buildDir/libs/${t.name}"
2899             }
2900             copy {
2901                 from "$webkitOutputDir/$webkitConfig/lib/${library('DumpRenderTreeJava')}"
2902                 into "$buildDir/test/${t.name}"
2903             }


2904         }
2905 
2906         if (IS_WINDOWS && t.name == "win") {
2907             def webkitProperties = project.rootProject.ext[t.upper].webkit
2908             def rcTask = project.task("rc${t.capital}", type: CompileResourceTask) {
2909                 compiler = webkitProperties.rcCompiler
2910                 source(webkitProperties.rcSource)
2911                 if (webkitProperties.rcFlags) {
2912                     rcParams.addAll(webkitProperties.rcFlags)
2913                 }
2914                 output(file("$webkitOutputDir/$webkitConfig/WebCore/obj"))
2915             }
2916             compileNativeTask.dependsOn rcTask
2917         }
2918 
2919         def compileGeneratedTask = task("compileGenerated${t.capital}", type: JavaCompile, dependsOn: compileNativeTask) {
2920             def gensrcDir = "$webkitOutputDir/$webkitConfig/DerivedSources/WebCore/nativeJava/java"
2921             doFirst {



2922                 copy {
2923                     from "$projectDir/src/main/java-wrappers/com/sun/webkit/dom/EventListenerImpl.java"
2924                     into "$gensrcDir/com/sun/webkit/dom"





2925                 }
2926             }
2927             classpath = files(project.sourceSets.main.output.classesDir)
2928             source gensrcDir
2929             destinationDir = file("$buildDir/classes/main")






2930         }
2931 
2932         compileGenerated.dependsOn compileGeneratedTask
2933 
2934         if (!targetProperties.compileWebnodeNative) {
2935             println("Not compiling native Webkit for ${t.name} per configuration request");
2936             compileNativeTask.enabled = false
2937         }
2938     }
2939 
2940     def drtClasses = "com/sun/javafx/webkit/drt/**"
2941     jar.exclude(drtClasses)
2942     task drtJar(type: Jar, dependsOn: compileJava) {
2943         archiveName = "drt.jar"
2944         destinationDir = file("$buildDir/test")
2945         from "$buildDir/classes/main"
2946         include drtClasses
2947     }
2948 
2949     if (IS_COMPILE_WEBKIT) {
2950         jar.dependsOn compileGenerated, drtJar
2951     }
2952 }
2953 
2954 // This project is for system tests that need to run with a full SDK.
2955 // Most of them display a stage or do other things that preclude running
2956 // them in a shared JVM or as part of the "smoke test" run (which must
2957 // not pop up any windows or use audio). As such, they are only enabled
2958 // when FULL_TEST is specified, and each test runs in its own JVM
2959 project(":systemTests") {
2960 




2961     dependencies {
2962         testCompile project(":graphics").sourceSets.test.output
2963         testCompile project(":base").sourceSets.test.output
2964         testCompile project(":controls").sourceSets.test.output
2965         testCompile project(":swing").sourceSets.test.output
2966     }
2967 
2968     Set<String> testInclude = [ "test/**" ]
2969     configureJigsawTests(project, [ "base", "graphics", "controls", "swing", "fxml", "web" ],
2970         null, testInclude,
2971         project.projectDir.path + "/src/test/addExports"
2972     )

















































2973 
2974     test {
2975         enabled = IS_FULL_TEST







2976         if (!IS_USE_ROBOT) {
2977             // Disable all robot-based visual tests
2978             exclude("test/robot/**");
2979         }
2980         if (!IS_AWT_TEST) {
2981             // Disable all AWT-based tests
2982             exclude("**/javafx/embed/swing/*.*");
2983             exclude("**/com/sun/javafx/application/Swing*.*");
2984         }
2985 
2986         forkEvery = 1
2987     }
2988 }
2989 
2990 allprojects {
2991     // The following block is a workaround for the fact that presently Gradle
2992     // can't set the -XDignore.symbol.file flag, because it appears that the
2993     // javac API is lacking support for it. So what we'll do is find any Compile
2994     // task and manually provide the options necessary to fire up the
2995     // compiler with the right settings.
2996     //
2997     // Also, we need to remove jfxrt.jar from the ext classpath (if it is there)
2998     tasks.withType(JavaCompile) { compile ->
2999         if (compile.options.hasProperty("useAnt")) {
3000             compile.options.useAnt = true
3001             compile.options.useDepend = IS_USE_DEPEND
3002         } else if (compile.options.hasProperty("incremental")) {
3003             compile.options.incremental = IS_INCREMENTAL
3004         }
3005         compile.options.debug = true // we always generate debugging info in the class files
3006         compile.options.debugOptions.debugLevel = IS_DEBUG_JAVA ? "source,lines,vars" : "source,lines"
3007         compile.options.fork = true

3008         compile.options.forkOptions.executable = JAVAC

3009         compile.options.warnings = IS_LINT
3010         compile.options.compilerArgs = ["-XDignore.symbol.file", "-encoding", "UTF-8"]
3011         if (!DO_BUILD_SDK_FOR_TEST) {
3012             compile.classpath = files(jfxrtJarFromSdk) + compile.classpath














3013         }
3014 
3015         // Add in the -Xlint options
3016         if (IS_LINT) {
3017             LINT.split("[, ]").each { s ->
3018                 compile.options.compilerArgs += "-Xlint:$s"
3019             }
3020         }






















3021     }
3022 }
3023 
3024 // fxpackager requires JDK 9 to compile
3025 project(":fxpackager") {
3026     tasks.withType(JavaCompile) { compile ->
3027         compile.options.forkOptions.executable = JIGSAW_JAVAC
3028         compile.options.compilerArgs = [
3029                 "--add-exports", "java.base/sun.security.pkcs=ALL-UNNAMED",
3030                 "--add-exports", "java.base/sun.security.timestamp=ALL-UNNAMED",
3031                 "--add-exports", "java.base/sun.security.x509=ALL-UNNAMED",
3032                 "-encoding", "UTF-8"]
3033     }
3034 }
3035 
3036 // fxpackagerservices requires JDK 9 to compile
3037 project(":fxpackagerservices") {
3038     tasks.withType(JavaCompile) { compile ->
3039         compile.options.forkOptions.executable = JIGSAW_JAVAC
3040         compile.options.compilerArgs = [
3041                 "-encoding", "UTF-8"]
3042     }




















3043 }
3044 
3045 /******************************************************************************
3046  *                                                                            *
3047  *                             Top Level Tasks                                *
3048  *                                                                            *
3049  *  These are the tasks which are defined only for the top level project and  *
3050  *  not for any sub projects. These are generally the entry point that is     *
3051  *  used by Hudson and by the continuous build system.                        *
3052  *                                                                            *
3053  *****************************************************************************/
3054 
3055 task clean() {
3056     group = "Basic"
3057     description = "Deletes the build directory and the build directory of all sub projects"
3058     getSubprojects().each { subProject ->
3059         dependsOn(subProject.getTasksByName("clean", true));
3060     }
3061     doLast {
3062         delete(buildDir);
3063     }
3064 }
3065 
3066 task cleanAll() {
3067     group = "Basic"
3068     description = "Scrubs the repo of build artifacts"
3069     dependsOn(clean)
3070     doLast {
3071         //delete(".gradle"); This causes problems on windows.
3072         delete("buildSrc/build");
3073     }
3074 }
3075 
3076 task javadoc(type: Javadoc) {













3077     enabled = IS_BUILD_JAVADOC
3078     group = "Basic"
3079     description = "Generates the JavaDoc for all the public API"
3080     executable = JAVADOC
3081     def projectsToDocument = [
3082             project(":base"), project(":graphics"), project(":controls"), project(":media"),
3083             project(":swing"), /*project(":swt"),*/ project(":fxml"), project(":web")]
3084     source(projectsToDocument.collect({
3085         [it.sourceSets.main.java]
3086     }));
3087     setDestinationDir(new File(buildDir, 'javadoc'));
3088     // FIXME: The following is a workaround for JDK-8151191; it should be
3089     // reverted once that bug is fixed
3090     classpath += files(projectsToDocument.collect { project ->
3091         project.sourceSets.main.java.srcDirs
3092     });
3093     /*
3094     // Might need a classpath
3095     classpath = files(projectsToDocument.collect { project ->
3096         project.sourceSets.main.compileClasspath
3097     });
3098     classpath += files(projectsToDocument.collect { project ->
3099         project.sourceSets.main.output
3100     });
3101     */
3102     exclude("com/**/*", "Compile*", "javafx/builder/**/*", "javafx/scene/accessibility/**/*");
3103     options.windowTitle("${javadocTitle}")
3104     options.header("${javadocHeader}")
3105     options.bottom("${javadocBottom}")
3106     if (BUILD_CLOSED) {
3107         options.linksOffline(JDK_DOCS, JDK_DOCS_CLOSED);
3108     } else {
3109         options.links(JDK_DOCS);
3110     }
3111     options.addBooleanOption("XDignore.symbol.file").setValue(true);
3112     options.addBooleanOption("Xdoclint:none").setValue(!IS_DOC_LINT);
3113     options.addBooleanOption("javafx").setValue(true);
3114     options.addBooleanOption("use").setValue(true);






3115     doLast {
3116         projectsToDocument.each { p ->
3117             copy {
3118                 from "$p.projectDir/src/main/docs"
3119                 into "$buildDir/javadoc"
3120             }
3121         }
3122     }
3123 
3124     dependsOn(projectsToDocument.collect { project -> project.getTasksByName("classes", true)});
3125 }
3126 
3127 task jfxrt() {
3128     if (DO_BUILD_SDK_FOR_TEST) {
3129         rootProject.getTasksByName("compileTestJava", true).each { t ->
3130             if (t.enabled) t.dependsOn(jfxrt)
3131         }
3132     }
3133 }
3134 
3135 task sdk() {
3136     if (DO_BUILD_SDK_FOR_TEST) {
3137         rootProject.getTasksByName("test", true).each { t ->
3138             if (t.enabled) t.dependsOn(sdk)
3139         }
3140     }
3141 }
3142 
3143 task appsjar() {
3144     dependsOn(sdk)
3145     // Note: the jar dependencies get added elsewhere see project(":apps")
3146 }
3147 
3148 // these are empty tasks, allowing us to depend on the task, which may have other
3149 // real work items added later.
3150 task copyAppsArtifacts() {
3151     dependsOn(appsjar)
3152 }
3153 
3154 task apps() {


3232 task all() {
3233     dependsOn(sdk,publicExports,apps,perf,zips)
3234 }
3235 
3236 
3237 // Construct list of subprojects that are modules
3238 ext.moduleProjList = []
3239 subprojects {
3240     if (project.hasProperty("buildModule") && project.ext.buildModule) {
3241         rootProject.ext.moduleProjList += project
3242         println "module: $project (buildModule=YES)"
3243     } else {
3244         println "module: $project (buildModule=NO)"
3245     }
3246 }
3247 
3248 
3249 // Create the legacy sdk from the modular-sdk
3250 
3251 compileTargets { t ->
3252     def targetProperties = project.ext[t.upper]
3253     def platformPrefix = targetProperties.platformPrefix
3254     def sdkDirName = "${platformPrefix}sdk"
3255     def modularSdkDirName = "${platformPrefix}modular-sdk"
3256     def modularSdkDir = "${rootProject.buildDir}/${modularSdkDirName}"
3257     def modulesDir = "${modularSdkDir}/modules"
3258     def modulesCmdsDir = "${modularSdkDir}/modules_cmds"
3259     def modulesLibsDir = "${modularSdkDir}/modules_libs"
3260 
3261     // The jfxrt task is responsible for creating the legacy jfxrt.jar. A developer may
3262     // have multiple SDK's on their system at any one time, depending on which
3263     // cross compiles they have done. For example, I might have:
3264     //      build/ios-sdk/lib/jfxrt.jar
3265     //      build/armhf-sdk/lib/jfxrt.jar
3266     // and so forth. The default host build will always install into 'sdk'
3267     // allowing for uses where a known sdk path is needed (like IDEs)
3268     //      build/sdk/lib/jfxrt.jar
3269     // This arrangement allows for multiple independent SDKs to
3270     // exist on a developer's system.
3271     def jfxrtTask = task("jfxrt$t.capital", type: Jar) {
3272         group = "Basic"
3273         description = "Creates the jfxrt.jar for the $t.name target"
3274         archiveName = "build/${sdkDirName}/lib/jfxrt.jar";
3275         includeEmptyDirs = false
3276 
3277         moduleProjList.each { project ->
3278             if (project.ext.moduleRuntime) {
3279                 from("${modulesDir}/${project.ext.moduleName}");
3280             }
3281         }
3282 
3283         dependsOn(subprojects.collect { project -> project.getTasksByName("assemble", true)});
3284     }
3285 
3286     def jfxrtIndexTask = task("jfxrtIndex$t.capital") {
3287         //the following is a workaround for the lack of indexing in gradle 1.4 through 1.7
3288         dependsOn(jfxrtTask)
3289 
3290         doLast() {
3291             ant.jar (update: true, index: true, destfile: jfxrtTask.archiveName)
3292         }
3293     }
3294     jfxrt.dependsOn(jfxrtIndexTask)
3295 


3296     def javafxSwtTask = task("javafxSwt$t.capital", type: Jar) {
3297         enabled = COMPILE_SWT
3298         group = "Basic"
3299         description = "Creates the javafx-swt.jar for the $t.name target"
3300         archiveName = "${project(":swt").buildDir}/libs/javafx-swt.jar";
3301         includeEmptyDirs = false
3302         from("${project(":swt").buildDir}/classes/main");
3303         include("**/javafx/embed/swt/**")
3304 
3305         dependsOn(subprojects.collect { project -> project.getTasksByName("assemble", true)});
3306     }
3307 
3308     def javafxSwtIndexTask = task("javafxSwtIndex$t.capital") {
3309         //the following is a workaround for the lack of indexing in gradle 1.4 through 1.7
3310         dependsOn(javafxSwtTask)
3311 
3312         doLast() {
3313             ant.jar (update: true, index: true, destfile: javafxSwtTask.archiveName)
3314         }
3315     }
3316     jfxrt.dependsOn(javafxSwtIndexTask)
3317 
3318     def jmxTask = task ("jmx${t.capital}", type: Jar) {
3319         group = "Basic"
3320         description = "Creates the javafx-mx.jar"
3321         archiveName = "build/${sdkDirName}/lib/javafx-mx.jar";
3322         includeEmptyDirs = false
3323         from project(":jmx").buildDir.path + "/classes/main"
3324         from project(":jmx").buildDir.path + "/resources/main"
3325         dependsOn project(":jmx").assemble
3326     }
3327 
3328     // The 'sdk' task will build the rest of the legacy SDK, and depends
3329     // on the 'jfxrtTask' task. After executing this task the sdk bundle for
3330     // the current COMPILE_TARGETS will be fully created.
3331     def sdkTask = task("sdk$t.capital") {
3332         group = "Basic"
3333         description = "Creates the SDK for $t.name"
3334         doLast {
3335             copy {
3336                 moduleProjList.each { project ->
3337                     from "${modulesLibsDir}/${project.ext.moduleName}"
3338                 }
3339                 into "build/${sdkDirName}/lib"
3340                 exclude("*.dll")
3341             }
3342             copy {
3343                 moduleProjList.each { project ->
3344                     from "${modulesLibsDir}/${project.ext.moduleName}"
3345                 }
3346                 into "build/${sdkDirName}/bin"
3347                 include("*.dll")
3348             }
3349 
3350             copy {
3351                 moduleProjList.each { project ->
3352                     from "${modulesCmdsDir}/${project.ext.moduleName}"
3353                 }
3354                 into "build/${sdkDirName}/bin"
3355             }
3356 
3357             // FIXME: JIGSAW -- update this for modules
3358             // Copy over the javadocs that were generated. This is done rather than just generating
3359             // the docs into the "right place" because for a cross-compile you only need one set of
3360             // docs but need to have a copy in each created sdk
3361             if (IS_BUILD_JAVADOC) {
3362                 copy {
3363                     from "build/javadoc"
3364                     into "build/${sdkDirName}/docs/api"
3365                 }
3366             }
3367 
3368             // FIXME: JIGSAW -- update this for modules
3369             // Copy over the javafx-src bundle
3370             if (IS_BUILD_SRC_ZIP) {
3371                 copy {
3372                     from "build/javafx-src.zip"
3373                     into "build/${sdkDirName}"
3374                 }
3375             }
3376 
3377             // FIXME: JIGSAW -- update this for modules
3378             // Copy over the javapackager man files
3379             copy {
3380                 from "${project(":fxpackager").buildDir}/man"
3381                 into "build/${sdkDirName}/man"
3382             }
3383         }
3384         dependsOn(jmxTask);
3385         dependsOn(jfxrtIndexTask)
3386         dependsOn(javafxSwtIndexTask)
3387         dependsOn(javadoc)
3388         dependsOn(src)
3389     }
3390 
3391     def generateSymbols = targetProperties.containsKey('generateSymbols') ? targetProperties.generateSymbols : false
3392     if (generateSymbols) {
3393         def exportedSymbolsTask = project.task("exportedSymbols${t.capital}", type: ExportedSymbolsTask, dependsOn: sdkTask, group: "Build") {
3394             description = "Generates exported symbols file for iOS build (from .a libraries)"
3395             def libDirName = "build/${sdkDirName}/$targetProperties.libDest"
3396             libDir = file("$libDirName")
3397             outputFile = file("$libDirName/exported.symbols")
3398             excludes = targetProperties.generateSymbolsExcludes
3399         }
3400         sdk.dependsOn(exportedSymbolsTask)
3401     }
3402 
3403     sdk.dependsOn(sdkTask)
3404 }
3405 
3406 /*
3407  * This clause changes the way we handle a build.gradle within ./apps
3408  * It does a few things:
3409  *   modifies the classpath used to include the built runttime classes
3410  *   provides for copying the build applications to the artifacts tree
3411  *
3412  * The applications to be built will be under ./apps, but also must
3413  * be listed in the applications listed in the setting variable: JFXApplications
3414  */
3415 ext.JFXRT_CP =
3416     files(
3417         project(":base").sourceSets.main.output.classesDir,
3418         project(":graphics").sourceSets.main.output.classesDir,
3419         project(":controls").sourceSets.main.output.classesDir,
3420         project(":fxml").sourceSets.main.output.classesDir,
3421         project(":swing").sourceSets.main.output.classesDir, //NOTE - used by 3Dviewer
3422         "${project(":media").buildDir}/classes/main",
3423         "${project(":web").buildDir}/classes/main",
3424     )
3425 
3426 project(":apps") {
3427     // The apps build is Ant based, and gradle lets us "import" ant build.xml
3428     // into our configuration.
3429 
3430     ant.importBuild 'build.xml'
3431 
3432     compileTargets { t ->
3433         // The apps build is Ant based, and gradle lets us "import" ant apps/build.xml
3434         // into our configuration.

3435 
3436         // override the apps build.xml with an explicit pointer to our jar.
3437         def platformPrefix = rootProject.ext[t.upper].platformPrefix
3438         def sdkDirName = "${platformPrefix}sdk"
3439         def jfxrtJar = "${rootProject.buildDir}/${sdkDirName}/lib/jfxrt.jar"


3440 
3441         def appsJar = project.task("appsJar${t.capital}") {
3442             dependsOn(sdk)
3443             doLast() {
3444               ant.properties['targetBld'] = "$t.name"
3445               if (!rootProject.ext[t.upper].compileSwing) {
3446                 ant.properties['JFX_CORE_ONLY'] = 'true'
3447               }
3448               ant.properties['jfxbuild.jfxrt.jar'] = jfxrtJar
3449               ant.properties['platforms.JDK_1.8.home'] = "${rootProject.ext.JDK_HOME}"
3450               ant.project.executeTarget("sampleAppsJar")
3451               ant.project.executeTarget("scenebuilderSampleAppsJar")
3452               if (!t.name.startsWith("arm")) {
3453                 ant.project.executeTarget("scenebuilderAppJar")
3454               }
3455             }
3456         }
3457         rootProject.appsjar.dependsOn(appsJar)
3458 
3459         def appsClean = project.task("appsClean${t.capital}") {
3460             doLast() {
3461               ant.properties['targetBld'] = "$t.name"
3462               ant.properties['platforms.JDK_1.8.home'] = "${rootProject.ext.JDK_HOME}"
3463               ant.project.executeTarget("sampleAppsClean")
3464               ant.project.executeTarget("scenebuilderSampleAppsClean")
3465               if (!t.name.startsWith("arm")) {
3466                 ant.project.executeTarget("scenebuilderAppClean")
3467               }
3468             }
3469         }
3470         rootProject.clean.dependsOn(appsClean)
3471     }
3472 }
3473 
3474 
3475 /******************************************************************************
3476  *                                                                            *
3477  *                               Modules                                      *
3478  *                                                                            *
3479  *****************************************************************************/
3480 
3481 ext.moduleDependencies = [file("dependencies")]
3482 
3483 task buildModules {
3484 }
3485 
3486 // Combine the classes, lib, and bin for each module
3487 compileTargets { t ->
3488     def targetProperties = project.ext[t.upper]
3489 
3490     def platformPrefix = targetProperties.platformPrefix
3491     def modularSdkDirName = "${platformPrefix}modular-sdk"
3492     def modularSdkDir = "${rootProject.buildDir}/${modularSdkDirName}"
3493     def modulesDir = "${modularSdkDir}/modules"
3494     def modulesCmdsDir = "${modularSdkDir}/modules_cmds"
3495     def modulesLibsDir = "${modularSdkDir}/modules_libs"
3496     def modulesSrcDir = "${modularSdkDir}/modules_src"
3497     def modulesConfDir = "${modularSdkDir}/modules_conf"
3498     def modulesMakeDir = "${modularSdkDir}/make"
3499     final File patchmoduleFile = file("${rootProject.buildDir}/patchmodule.args")

3500 
3501     project.files(patchmoduleFile);
3502 
3503     def zipTask = project.task("buildModuleZip$t.capital", type: Zip, group: "Build") {
3504         enabled = IS_BUILD_MODULE_ZIP
3505 
3506         // FIXME: JIGSAW -- this should be moved to a sub-directory so we can keep the same name
3507         def jfxBundle = "${platformPrefix}javafx-exports.zip"
3508 
3509         doFirst() {
3510             file("${rootProject.buildDir}/${jfxBundle}").delete()
3511         }
3512 
3513         archiveName = jfxBundle
3514         destinationDir = file("${rootProject.buildDir}")
3515         includeEmptyDirs = false
3516         from "${modularSdkDir}"
3517     }
3518     buildModules.dependsOn(zipTask)
3519 
3520     def buildModulesTask = task("buildModules$t.capital", group: "Build") {
3521         doLast {
3522             moduleProjList.each { project ->
3523 
3524                 // Copy classes, bin, and lib directories
3525 
3526                 def moduleName = project.ext.moduleName
3527                 def buildDir = project.buildDir
3528 
3529                 def srcClassesDir = "${buildDir}/${platformPrefix}module-classes"
3530                 def dstClassesDir = "${modulesDir}/${moduleName}"
3531                 copy {
3532                     from srcClassesDir
3533                     into dstClassesDir

3534                 }
3535 
3536                 def srcCmdsDir = "${buildDir}/${platformPrefix}module-bin"
3537                 def dstCmdsDir = "${modulesCmdsDir}/${moduleName}"
3538                 copy {
3539                     from srcCmdsDir
3540                     into dstCmdsDir
3541                 }
3542 
3543                 def srcLibsDir = "${buildDir}/${platformPrefix}module-lib"
3544                 def dstLibsDir = "${modulesLibsDir}/${moduleName}"
3545                 copy {
3546                     from srcLibsDir
3547                     into dstLibsDir
3548                 }
3549 
3550                 // Copy module-info.java
3551                 def srcModuleInfoDir = "${project.projectDir}/src/main/module-info"
3552                 def dstModuleInfoDir = "${modulesSrcDir}/${moduleName}"
3553                 copy {
3554                     from srcModuleInfoDir
3555                     into dstModuleInfoDir
3556                     if (!IS_COMPILE_JFR && project.name.equals("base")) {
3557                         filter { line-> line.contains("requires jdk.jfr;") ? "" : line }
3558                     }
3559                 }
3560 
3561                 // Copy make/build.properties
3562                 def srcMakeDir = "${project.projectDir}/make"
3563                 def dstMakeDir = "${modulesMakeDir}/${moduleName}"
3564                 copy {
3565                     from srcMakeDir
3566                     into dstMakeDir
3567                 }
3568             }
3569 
3570             // Copy dependencies/*/module-info.java.extra


3571             def dependencyRoots = moduleDependencies
3572             if (rootProject.hasProperty("closedModuleDepedencies")) {
3573                 dependencyRoots = [dependencyRoots, closedModuleDepedencies].flatten()
3574             }
3575             copy {


3576                 dependencyRoots.each { root ->
3577                     from root



































3578                 }
3579                 into modulesSrcDir
3580             }
3581 
3582             // concatecate java.policy files into a single file
3583             //
3584             def outputPolicyDir = "${modulesConfDir}/java.base/security"
3585             def outputPolicyFile = file("${outputPolicyDir}/java.policy.extra")
3586             mkdir outputPolicyDir
3587             outputPolicyFile.delete()
3588             moduleProjList.each { project ->
3589                 def policyDir = "${project.projectDir}/src/main/conf/security"
3590                 def policyFile = file("${policyDir}/java.policy")
3591                 if (policyFile.exists()) outputPolicyFile << policyFile.text
3592             }
3593         }
3594     }
3595     zipTask.dependsOn(buildModulesTask);
3596     buildModules.dependsOn(buildModulesTask)
3597 
3598     def buildModulesPatchTask = task("buildModulesPatch$t.capital", group: "Build") {


3599         doLast() {
3600             patchmoduleFile.delete()
3601 
3602             logger.info("Creating patchmodule.args file ${patchmoduleFile}")
3603             String thepath=cygpath("${rootProject.buildDir}/sdk/${targetProperties.libDest}")
3604 
3605             patchmoduleFile <<  "-Djava.library.path=${thepath}\n"
3606             moduleProjList.each { project ->
3607                 def moduleName = project.ext.moduleName
3608                 def dstModuleDir = cygpath("${modulesDir}/${moduleName}")
3609                 patchmoduleFile <<  "--patch-module ${moduleName}=\"${dstModuleDir}\"\n"
3610             }


3611         }
3612     }

3613 
3614     buildModulesPatchTask.dependsOn(buildModulesTask)
3615     buildModules.dependsOn(buildModulesPatchTask)












3616 
3617     def isWindows = IS_WINDOWS && t.name == "win";
3618     def isMac = IS_MAC && t.name == "mac";
3619 
3620     // Create layout for modular classes
3621     moduleProjList.each { project ->
3622         def buildModuleClassesTask = project.task("buildModule$t.capital", group: "Build") {
3623             dependsOn(project.assemble)
3624             def buildDir = project.buildDir
3625             def sourceBuildDirs = [
3626                 "${buildDir}/classes/main",
3627                 "${buildDir}/resources/main"
3628             ]
3629             doLast {
3630                 def moduleClassesDir = "$buildDir/${platformPrefix}module-classes"
3631                 copy {
3632                     includeEmptyDirs = false
3633                     sourceBuildDirs.each { d ->
3634                         from d
3635                     }
3636                     into moduleClassesDir
3637 
3638                     // Exclude obsolete, experimental, or non-shipping code
3639                     exclude("version.rc")
3640                     exclude("com/sun/glass/ui/swt")
3641                     exclude("com/sun/javafx/tools/ant")
3642                     exclude("com/javafx/main")
3643                     if (!IS_INCLUDE_NULL3D) {
3644                         exclude ("com/sun/prism/null3d")
3645                     }
3646                     if (!IS_INCLUDE_ES2) {
3647                            exclude("com/sun/prism/es2",


3820             // javafx.media native libraries
3821 
3822             copy {
3823                 into "${mediaProject.buildDir}/${moduleNativeDirName}"
3824 
3825                 def mediaBuildType = project(":media").ext.buildType
3826                 if (IS_COMPILE_MEDIA) {
3827                     [ "fxplugins", "gstreamer-lite", "jfxmedia" ].each { name ->
3828                         from ("${mediaProject.buildDir}/native/${t.name}/${mediaBuildType}/${library(name)}") }
3829 
3830                     if (t.name == "mac") {
3831                         // OSX media natives
3832                         [ "jfxmedia_qtkit", "jfxmedia_avf", "glib-lite" ].each { name ->
3833                             from ("${mediaProject.buildDir}/native/${t.name}/${mediaBuildType}/${library(name)}") }
3834                     } else if (t.name == "linux") {
3835                         from("${mediaProject.buildDir}/native/${t.name}/${mediaBuildType}") { include "libavplugin*.so" }
3836                     } else from ("${mediaProject.buildDir}/native/${t.name}/${mediaBuildType}/${library("glib-lite")}")
3837                 } else {
3838                     if (t.name != "android"  && t.name != "dalvik" ) {
3839                         [ "fxplugins", "gstreamer-lite", "jfxmedia" ].each { name ->
3840                             from ("$LIBRARY_STUB/${library(name)}") }
3841                     }
3842 
3843                     if (t.name == "mac") {
3844                         // copy libjfxmedia_{avf,qtkit}.dylib if they exist
3845                         [ "jfxmedia_qtkit", "jfxmedia_avf", "glib-lite" ].each { name ->
3846                             from ("$LIBRARY_STUB/${library(name)}") }
3847                     } else if (t.name == "linux") {
3848                         from(LIBRARY_STUB) { include "libavplugin*.so" }
3849                     }
3850                     else if (t.name != "android"  && t.name != "dalvik" ) {
3851                         from ("$LIBRARY_STUB/${library("glib-lite")}")
3852                     }
3853                 }
3854             }
3855 
3856 
3857             // javafx.web native libraries
3858 
3859             copy {
3860                 into "${webProject.buildDir}/${moduleNativeDirName}"
3861 
3862                 if (IS_COMPILE_WEBKIT) {
3863                     from ("${webProject.buildDir}/libs/${t.name}/${library('jfxwebkit')}")
3864                 } else {
3865                     if (t.name != "android" && t.name != "ios" && t.name != "dalvik") {
3866                         from ("$LIBRARY_STUB/${library('jfxwebkit')}")
3867                     }
3868                 }
3869             }
3870 
3871             // FIXME: the following is a hack to workaround the fact that there
3872             // is no way to deliver javafx-swt.jar other than in one of the
3873             // existing runtime modules.
3874             if (COMPILE_SWT) {
3875                 // Copy javafx-swt.jar to the javafx-graphics module lib dir
3876                 copy {
3877                     from "${swtProject.buildDir}/libs/javafx-swt.jar"
3878                     into "${graphicsProject.buildDir}/${platformPrefix}module-lib"
3879                 }
3880             }
3881 
3882             // javafx.packager libraries and executable
3883 
3884             // Copy over the javapackager libs
3885             copy {
3886                 from "${packagerProject.buildDir}/libs"
3887                 into "${packagerProject.buildDir}/${platformPrefix}module-lib"
3888             }
3889 
3890             // Copy over the javapackager executable
3891             if (t.name == "win" || t.name == "linux" || t.name == "mac") {
3892                 copy {
3893                     from "${packagerProject.buildDir}/javapackager"
3894                     into "${packagerProject.buildDir}/${platformPrefix}module-bin"
3895                 }
3896             }
3897 
3898         }
3899     }
3900     buildModulesTask.dependsOn(buildModuleLibsTask)
3901 
3902     def sdkTask = tasks.getByName("sdk${t.capital}");
3903     sdkTask.dependsOn(buildModulesTask)
3904 }
3905 sdk.dependsOn(buildModules)
3906 
3907 void configureJigsawTests(
3908         Project p,
3909         List<String> moduleDeps,
3910         Set<String> patchInc,
3911         Set<String> testsInc,
3912         String addExportsFile
3913         ) {
3914 
3915     if(!IS_JIGSAW_TEST) {
3916         return
3917     }
3918 
3919     p.configurations {
3920         jigsawTest
3921     }
3922 
3923     p.dependencies {
3924         jigsawTest group: "junit", name: "junit", version: "4.8.2"
3925     }
3926 
3927     compileTargets { t ->
3928 
3929         def targetProperties = project.rootProject.ext[t.upper]


3930 
3931         def modularSdkDirName = "${targetProperties.platformPrefix}modular-sdk"
3932         def modularSdkDir = "${rootProject.buildDir}/${modularSdkDirName}"
3933         def modulesDir = "${modularSdkDir}/modules"
3934 
3935         boolean useModule = true
3936         String moduleName
3937         if(!p.hasProperty('moduleName')) {
3938             useModule = false
3939             moduleName = "systemTests"
3940         } else {
3941             moduleName = p.moduleName
3942         }
3943 
3944         logger.info("configuring $p.name for modular test copy");
3945 
3946         def testingDir = "${rootProject.buildDir}/${targetProperties.platformPrefix}testing";
3947         def patchesDir = new File("${testingDir}/modules");
3948         File patchPolicyFile = new File("${testingDir}/java.patch.policy");
3949         File patchmoduleFile = new File("${testingDir}/patchmodule.args");
3950 
3951         String javaLibraryPath = "${rootProject.buildDir}/sdk/$targetProperties.libDest"
3952 
3953         def jigsawPatchesBaseDir = new File("${testingDir}/modules/$moduleName");
3954         def jigsawPatchesTestDir = new File("${testingDir}/tests/$moduleName");
3955 
3956         p.files(patchPolicyFile);
3957         p.files(patchmoduleFile);
3958 
3959         def srcClassesDir = "${p.buildDir}/${targetProperties.platformPrefix}module-classes"
3960         Task classes =  p.task("jigsawCopyClasses${t.capital}", type: Copy, dependsOn: [p.classes]) {
3961 
3962             enabled = useModule
3963 
3964             from srcClassesDir
3965             into jigsawPatchesBaseDir
3966         }
3967 
3968         Task shims =  p.task("jigsawCopyShims${t.capital}", type: Copy, dependsOn: [p.testClasses]) {
3969             //from p.sourceSets.test.output.classesDir
3970 
3971             enabled = useModule
3972 
3973             from p.sourceSets.test.output
3974             into jigsawPatchesBaseDir
3975             if (patchInc != null) {
3976                 include patchInc
3977             } else {
3978                 include "**/*"
3979             }
3980             if (testsInc != null) {
3981                 exclude testsInc
3982             }
3983             includeEmptyDirs = false
3984             doLast() {
3985                 logger.info("project $p.name finished jigsawCopyShims to $jigsawPatchesBaseDir");
3986             }
3987         }
3988 
3989         Task alltests =  p.task("jigsawCopyTests${t.capital}", type: Copy, dependsOn: [p.testClasses]) {
3990             from p.sourceSets.test.output
3991             into jigsawPatchesTestDir
3992             if (patchInc != null) {
3993                 exclude patchInc
3994             }
3995             if (testsInc != null) {
3996                 include testsInc
3997             } else {
3998                 include "**/*"
3999             }
4000             includeEmptyDirs = false
4001             doLast() {
4002                 logger.info("project $p.name finished jigsawCopyTests to $jigsawPatchesTestDir");
4003             }
4004         }
4005 
4006         // create & use just one of these per platform
4007         String nameis = "moduleTestPatchPolicy${t.capital}"
4008         Task patchPerms = null
4009         if (rootProject.hasProperty(nameis)) {
4010             patchPerms = rootProject.tasks[nameis]
4011         } else {
4012             patchPerms = rootProject.task(nameis) {
4013                 outputs.file(patchPolicyFile)
4014                 outputs.file(patchmoduleFile)
4015                 doLast() {
4016                     logger.info("Creating test patch.policy file ${patchPolicyFile}")
4017                     logger.info("Creating test patch.policy file ${patchmoduleFile}")
4018 
4019                     delete(patchPolicyFile)
4020                     delete(patchmoduleFile)
4021                     mkdir(testingDir)
4022                     String thepath=cygpath("${rootProject.buildDir}/sdk/${targetProperties.libDest}")
4023 
4024                     patchmoduleFile <<  "-Djava.library.path=${thepath}\n"
4025                     moduleProjList.each { project ->
4026                         String themod = file("${patchesDir}/${project.ext.moduleName}").toURI()
4027                         patchPolicyFile <<  "grant codeBase \"${themod}\" {\n" +
4028                         "    permission java.security.AllPermission;\n" +
4029                         "};\n"
4030 
4031                         def dstModuleDir = cygpath("${patchesDir}/${project.ext.moduleName}")
4032                         patchmoduleFile <<  "--patch-module ${project.ext.moduleName}=\"${dstModuleDir}\"\n"
4033                     }
4034                 }
4035             }
4036         }
4037 
4038         Task jigsawTestsTask =  p.task("jigsawTests${t.capital}", dependsOn: [classes, shims, alltests, patchPerms ]) {
4039             doLast() {
4040                 logger.info("project $p.name finished jigsawTests${t.capital}");
4041             }
4042         }
4043 
4044         FileCollection testclasspath = p.files(p.configurations.jigsawTest)
4045 
4046         p.test.dependsOn jigsawTestsTask
4047 
4048         if (moduleDeps != null) {
4049             moduleDeps.each() {s->
4050                 logger.info("adding dep to project $p.name $s");
4051                 Project pdep = rootProject.project(s);
4052                 def jigsawTask = pdep.tasks.getByName("jigsawTests${t.capital}");
4053                 jigsawTestsTask.dependsOn jigsawTask;
4054 
4055                 testclasspath += p.files(pdep.ext.jigsawPatchesTestDir);
4056             }
4057         }
4058 
4059         testclasspath += p.files(jigsawPatchesTestDir);
4060 
4061         p.ext.jigsawTestClasspath = testclasspath
4062         p.ext.jigsawPatchesTestDir = jigsawPatchesTestDir
4063         p.ext.jigsawTestClasses = jigsawTestsTask
4064 
4065         p.ext.argclasspathFile = "$testingDir/classpath_"+p.name+".txt"
4066 
4067         p.test {
4068             if (IS_FORCE_TESTS) {
4069                 dependsOn 'cleanTest'
4070             }
4071 
4072             scanForTestClasses = false
4073             include("**/*Test.*")
4074 
4075             if (IS_JIGSAW_TEST) {
4076                 dependsOn jigsawTestsTask
4077 
4078                 doFirst {
4079                     classpath = testclasspath
4080                     p.sourceSets.test.runtimeClasspath = testclasspath
4081                 }
4082 
4083                 String bcp = "-Xbootclasspath/a:" + rootProject.projectDir.path + "/buildSrc/build/libs/buildSrc.jar"
4084 
4085                 systemProperties 'worker.debug': IS_WORKER_DEBUG
4086                 systemProperties 'worker.patchmodule.file': cygpath(patchmoduleFile.path)
4087                 if (addExportsFile != null) {
4088                     systemProperties 'worker.exports.file': cygpath(addExportsFile)
4089                 }
4090                 systemProperties 'worker.classpath.file': cygpath(p.ext.argclasspathFile)
4091                 systemProperties 'worker.java.cmd': JIGSAW_JAVA
4092 
4093                 systemProperties 'worker.isJigsaw': true
4094 
4095                 systemProperties 'worker.patch.policy': cygpath(patchPolicyFile.path)
4096 
4097                 //systemProperties 'prism.order': 'sw'
4098                 //systemProperties 'glass.platform': 'Monocle'
4099                 //systemProperties
'glass.len': 'headless'
4100 
4101                 jvmArgs bcp, "workaround.GradleJUnitWorker"
4102 
4103                 environment("JDK_HOME", JIGSAW_HOME);
4104                 executable (JIGSAW_JAVA);
4105 
4106               }
4107         }
4108 
4109     }


4110 


4111 }

4112 
4113 task checkrepo() {
4114     doLast {
4115         logger.info("checking for whitespace (open)");
4116         exec {
4117             if (IS_WINDOWS) {
4118                 commandLine  'bash', 'tools/scripts/checkWhiteSpace'
4119             } else {
4120                 commandLine  'bash', 'tools/scripts/checkWhiteSpace', '-x'
4121             }
4122         }
4123     }
4124 }
4125 
4126 task checkrepoall() {
4127     doLast {
4128         logger.info("checking for all whitespace (open)");
4129         exec {
4130             if (IS_WINDOWS) {
4131                 commandLine  'bash', 'tools/scripts/checkWhiteSpace', '-a'


4150 if (BUILD_CLOSED) {
4151     apply from: supplementalBuildFile
4152 }
4153 
4154 task showFlags {
4155 }
4156 
4157 compileTargets { t ->
4158     // Every platform must define these variables
4159     def props = project.ext[t.upper];
4160     showFlags.dependsOn(
4161         project.task("showFlags$t.upper") {
4162             doLast() {
4163                 println "Properties set for $t.upper"
4164                 props.each { println it }
4165             }
4166         }
4167     )
4168 
4169 }
4170 
   1 // FIXME: KCR SDK
   2 /*
   3  * Copyright (c) 2013, 2016, 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  * The main build script for JavaFX.
  29  *
  30  * MUST FIX tasks to complete:
  31  *  - build check -- making sure the final artifact has the right bits
  32  *      - some things worth automatically sanity checking:
  33  *          - are there images in the javadocs?
  34  *          - are all of the expected dylibs etc there?



  35  *  - Perform sanity checking to make sure a JDK exists with javac, javah, etc
  36  *  - Support building with no known JDK location, as long as javac, javah, etc are on the path
  37  *  - Check all of the native flags. We're adding weight to some libs that don't need it, and so forth.
  38  *
  39  * Additional projects to work on as we go:
  40  *  - Add "developer debug". This is where the natives do not have debug symbols, but the Java code does
  41  *  - The genVSproperties.bat doesn't find the directory where RC.exe lives. So it is hard coded. Might be a problem.
  42  *  - special tasks for common needs, such as:
  43  *      - updating copyright headers
  44  *      - stripping trailing whitespace (?)
  45  *  - checkstyle
  46  *  - findbugs
  47  *  - re needs?
  48  *  - sqe testing
  49  *  - API change check
  50  *  - Pushing results to a repo?
  51  *  - ServiceWithSecurityManagerTest fails to complete when run from gradle.
  52  *  - Integrate Parfait reports for C code
  53  *  - FXML Project tests are not running
  54  */


 239  *  All properties defined using ext. are immediately available throughout    *
 240  *  the script as variables that can be used. These variables are attached    *
 241  *  to the root project (whereas if they were defined as def variables then   *
 242  *  they would only be available within the root project scope).              *
 243  *                                                                            *
 244  *  All properties defined using the "defineProperty" method can be replaced  *
 245  *  on the command line by using the -P flag. For example, to override the    *
 246  *  location of the binary plug, you would specify -PBINARY_PLUG=some/where   *
 247  *                                                                            *
 248  *****************************************************************************/
 249 
 250 // If the ../rt-closed directory exists, then we are doing a closed build.
 251 // In this case, build and property files will be read from
 252 // ../rt-closed/closed-build.gradle and ../rt-closed/closed-properties.gradle
 253 // respectively
 254 
 255 def closedDir = file("../rt-closed")
 256 def buildClosed = closedDir.isDirectory()
 257 ext.BUILD_CLOSED = buildClosed
 258 
 259 ext.RUNARGSFILE = "run.args"
 260 ext.COMPILEARGSFILE = "compile.args"
 261 
 262 ext.TESTCOMPILEARGSFILE = "testcompile.args"
 263 ext.TESTRUNARGSFILE = "testrun.args"
 264 ext.TESTJAVAPOLICYFILE = 'test.java.policy'
 265 
 266 ext.MODULESOURCEPATH = "modulesourcepath.args"
 267 
 268 // These variables indicate what platform is running the build. Is
 269 // this build running on a Mac, Windows, or Linux machine? 32 or 64 bit?
 270 ext.OS_NAME = System.getProperty("os.name").toLowerCase()
 271 ext.OS_ARCH = System.getProperty("os.arch")
 272 ext.IS_64 = OS_ARCH.toLowerCase().contains("64")
 273 ext.IS_MAC = OS_NAME.contains("mac") || OS_NAME.contains("darwin")
 274 ext.IS_WINDOWS = OS_NAME.contains("windows")
 275 ext.IS_LINUX = OS_NAME.contains("linux")
 276 
 277 // Verify that the architecture & OS are supported configurations. Note that
 278 // at present building on PI is not supported, but we would only need to make
 279 // some changes on assumptions on what should be built (like SWT / Swing) and
 280 // such and we could probably make it work.
 281 if (!IS_MAC && !IS_WINDOWS && !IS_LINUX) fail("Unsupported build OS ${OS_NAME}")
 282 if (IS_WINDOWS && OS_ARCH != "x86" && OS_ARCH != "amd64") {
 283     fail("Unknown and unsupported build architecture: $OS_ARCH")
 284 } else if (IS_MAC && OS_ARCH != "x86_64") {
 285     fail("Unknown and unsupported build architecture: $OS_ARCH")
 286 } else if (IS_LINUX && OS_ARCH != "i386" && OS_ARCH != "amd64") {
 287     fail("Unknown and unsupported build architecture: $OS_ARCH")
 288 }
 289 
 290 
 291 // Get the JDK_HOME automatically based on the version of Java used to execute gradle. Or, if specified,
 292 // use a user supplied JDK_HOME, STUB_RUNTIME, JAVAC, all of which may be specified
 293 // independently (or we'll try to get the right one based on other supplied info). Sometimes the
 294 // JRE might be the thing that is being used instead of the JRE embedded in the JDK, such as:
 295 //    c:\Program Files (x86)\Java\jdk1.8.0\jre
 296 //    c:\Program Files (x86)\Java\jre8\
 297 // Because of this, you may sometimes get the jdk's JRE (in which case the logic we used to have here
 298 // was correct and consistent with all other platforms), or it might be the standalone JRE (for the love!).
 299 def envJavaHome = cygpath(System.getenv("JDK_HOME"))
 300 if (envJavaHome == null || envJavaHome.equals("")) envJavaHome = cygpath(System.getenv("JAVA_HOME"))
 301 def javaHome = envJavaHome == null || envJavaHome.equals("") ? System.getProperty("java.home") : envJavaHome
 302 def javaHomeFile = file(javaHome)
 303 defineProperty("JDK_HOME",
 304         javaHomeFile.name == "jre" ?
 305         javaHomeFile.getParent().toString() :
 306         javaHomeFile.name.startsWith("jre") ?
 307         new File(javaHomeFile.getParent(), "jdk1.${javaHomeFile.name.substring(3)}.0").toString() :
 308         javaHome) // we have to bail and set it to something and this is as good as any!
 309 ext.JAVA_HOME = JDK_HOME
 310 












 311 defineProperty("JAVA", cygpath("$JDK_HOME/bin/java${IS_WINDOWS ? '.exe' : ''}"))

 312 defineProperty("JAVAC", cygpath("$JDK_HOME/bin/javac${IS_WINDOWS ? '.exe' : ''}"))

 313 defineProperty("JAVAH", cygpath("$JDK_HOME/bin/javah${IS_WINDOWS ? '.exe' : ''}"))
 314 defineProperty("JAVADOC", cygpath("$JDK_HOME/bin/javadoc${IS_WINDOWS ? '.exe' : ''}"))
 315 defineProperty("JDK_DOCS", "https://docs.oracle.com/javase/8/docs/api/")
 316 defineProperty("JDK_JMODS", cygpath(System.getenv("JDK_JMODS")) ?: cygpath(System.getenv("JDK_HOME") + "/jmods"))
 317 
 318 defineProperty("javaRuntimeVersion", System.getProperty("java.runtime.version"))
 319 def javaVersionInfo = parseJavaVersion(javaRuntimeVersion)
 320 defineProperty("javaVersion", javaVersionInfo[0])
 321 defineProperty("javaBuildNumber", javaVersionInfo[1])
 322 
 323 loadProperties("$projectDir/build.properties")
 324 
 325 // Look for stub runtime in either JDK or modular-sdk dir layout
 326 
 327 def String closedCacheStubRuntime = cygpath("$projectDir") + "/../caches/modular-sdk"


 328 
 329 def String jdkStubRuntime = cygpath("$JDK_HOME")


 330 
 331 defineProperty("STUB_RUNTIME", BUILD_CLOSED ? closedCacheStubRuntime : jdkStubRuntime)
 332 
 333 def cachedStub = STUB_RUNTIME.equals(closedCacheStubRuntime)
 334 
 335 if (cachedStub) {
 336     def stubModulesLib = "$STUB_RUNTIME/modules_libs"
 337     def dirSuffix = (IS_MAC || IS_WINDOWS) ? "" : "/$OS_ARCH"
 338     defineProperty("MEDIA_STUB", "$stubModulesLib/javafx.media$dirSuffix")
 339     defineProperty("WEB_STUB", "$stubModulesLib/javafx.web$dirSuffix")
 340 } else {
 341     def libraryStub = IS_MAC ? "$STUB_RUNTIME/lib" :
 342                       IS_WINDOWS ? "$STUB_RUNTIME/bin" :
 343                       "$STUB_RUNTIME/lib/$OS_ARCH"
 344 
 345     defineProperty("MEDIA_STUB", libraryStub)
 346     defineProperty("WEB_STUB", libraryStub)
 347 }
 348 
 349 defineProperty("UPDATE_STUB_CACHE", (cachedStub ? 'true' : 'false'))
 350 
 351 def supplementalPreBuildFile = file("$closedDir/closed-pre-build.gradle");
 352 def supplementalBuildFile = file("$closedDir/closed-build.gradle");
 353 
 354 if (BUILD_CLOSED) {
 355     apply from: supplementalPreBuildFile
 356 }
 357 
 358 // GRADLE_VERSION_CHECK specifies whether to fail the build if the
 359 // gradle version check fails
 360 defineProperty("GRADLE_VERSION_CHECK", "true")
 361 ext.IS_GRADLE_VERSION_CHECK = Boolean.parseBoolean(GRADLE_VERSION_CHECK)
 362 
 363 // COMPILE_WEBKIT specifies whether to build all of webkit.
 364 defineProperty("COMPILE_WEBKIT", "false")
 365 ext.IS_COMPILE_WEBKIT = Boolean.parseBoolean(COMPILE_WEBKIT)
 366 
 367 // COMPILE_MEDIA specifies whether to build all of media.
 368 defineProperty("COMPILE_MEDIA", "false")
 369 ext.IS_COMPILE_MEDIA = Boolean.parseBoolean(COMPILE_MEDIA)
 370 
 371 // COMPILE_PANGO specifies whether to build javafx_font_pango.
 372 defineProperty("COMPILE_PANGO", "${IS_LINUX}")
 373 ext.IS_COMPILE_PANGO = Boolean.parseBoolean(COMPILE_PANGO)
 374 
 375 // COMPILE_HARFBUZZ specifies whether to use Harfbuzz.
 376 defineProperty("COMPILE_HARFBUZZ", "false")
 377 ext.IS_COMPILE_HARFBUZZ = Boolean.parseBoolean(COMPILE_HARFBUZZ)
 378 
 379 // COMPILE_PARFAIT specifies whether to build parfait
 380 defineProperty("COMPILE_PARFAIT", "false")
 381 ext.IS_COMPILE_PARFAIT = Boolean.parseBoolean(COMPILE_PARFAIT)
 382 
 383 // FIXME: update the default when using 9 (pre-jigsaw) as boot jdk
 384 // COMPILE_JFR specifies whether to build code that logs to JRockit Flight Recorder
 385 defineProperty("COMPILE_JFR", Boolean.toString(file("$JDK_HOME/jre/lib/jfr.jar").exists()))
 386 ext.IS_COMPILE_JFR = Boolean.parseBoolean(COMPILE_JFR)
 387 
 388 // BUILD_FXPACKAGER enables building the packager modules and native code
 389 defineProperty("BUILD_FXPACKAGER", "true")
 390 ext.IS_BUILD_FXPACKAGER = Boolean.parseBoolean(BUILD_FXPACKAGER)
 391 
 392 // RETAIN_PACKAGER_TESTS specifies whether the tests in fxpackager should
 393 // keep generated files instead of attempting to automatically delete them
 394 defineProperty("RETAIN_PACKAGER_TESTS", "false")
 395 ext.IS_RETAIN_PACKAGER_TESTS = Boolean.parseBoolean(RETAIN_PACKAGER_TESTS)
 396 
 397 // TEST_PACKAGER_DMG whether tests that create DMG files via hdiutil
 398 // should be run.  On OSX 10.7 this tends to hang automated builds
 399 defineProperty("TEST_PACKAGER_DMG", "false")
 400 ext.IS_TEST_PACKAGER_DMG = Boolean.parseBoolean(TEST_PACKAGER_DMG)
 401 
 402 // Define the SWT.jar that we are going to have to download during the build process based
 403 // on what platform we are compiling from (not based on our target).
 404 ext.SWT_FILE_NAME = IS_MAC ? "org.eclipse.swt.cocoa.macosx.x86_64_3.7.2.v3740f" :
 405     IS_WINDOWS && IS_64 ? "org.eclipse.swt.win32.win32.x86_64_3.7.2.v3740f" :
 406     IS_WINDOWS && !IS_64 ? "org.eclipse.swt.win32.win32.x86_3.7.2.v3740f" :
 407     IS_LINUX && IS_64 ? "org.eclipse.swt.gtk.linux.x86_64_3.7.2.v3740f" :
 408     IS_LINUX && !IS_64 ? "org.eclipse.swt.gtk.linux.x86_3.7.2.v3740f" : ""
 409 
 410 // Build javadocs only if BUILD_JAVADOC=true
 411 defineProperty("BUILD_JAVADOC", "false")
 412 ext.IS_BUILD_JAVADOC = Boolean.parseBoolean(BUILD_JAVADOC)
 413 
 414 // Specifies whether to build the javafx-src bundle
 415 defineProperty("BUILD_SRC_ZIP", "false")
 416 ext.IS_BUILD_SRC_ZIP = Boolean.parseBoolean(BUILD_SRC_ZIP)
 417 
 418 // Specifies whether to build the javafx-exports bundle
 419 defineProperty("BUILD_MODULE_ZIP", "true")
 420 ext.IS_BUILD_MODULE_ZIP = Boolean.parseBoolean(BUILD_MODULE_ZIP)
 421 
 422 // Specifies whether to run full tests (true) or smoke tests (false)
 423 defineProperty("FULL_TEST", "false")
 424 ext.IS_FULL_TEST = Boolean.parseBoolean(FULL_TEST);
 425 



 426 defineProperty("FORCE_TESTS", "false")
 427 ext.IS_FORCE_TESTS = Boolean.parseBoolean(FORCE_TESTS);
 428 
 429 // Specifies whether to run robot-based visual tests (only used when FULL_TEST is also enabled)
 430 defineProperty("USE_ROBOT", "false")
 431 ext.IS_USE_ROBOT = Boolean.parseBoolean(USE_ROBOT);
 432 
 433 // Specified whether to run tests in headless mode
 434 defineProperty("HEADLESS_TEST", "false")
 435 ext.IS_HEADLESS_TEST = Boolean.parseBoolean(HEADLESS_TEST);
 436 
 437 // Specifies whether to run system tests that depend on AWT (only used when FULL_TEST is also enabled)
 438 defineProperty("AWT_TEST", "true")
 439 ext.IS_AWT_TEST = Boolean.parseBoolean(AWT_TEST);
 440 
 441 // Specifies whether to run system tests that depend on SWT (only used when FULL_TEST is also enabled)
 442 defineProperty("SWT_TEST", "true")
 443 ext.IS_SWT_TEST = Boolean.parseBoolean(SWT_TEST);
 444 
 445 // Specifies whether to run unstable tests (true) - tests that don't run well with Hudson builds


 554 // Check whether the COMPILE_TARGETS property has been specified (if so, it was done by
 555 // the user and not by this script). If it has not been defined then default
 556 // to building the normal desktop build for this machine
 557 project.ext.set("defaultHostTarget", IS_MAC ? "mac" : IS_WINDOWS ? "win" : IS_LINUX ? "linux" : "");
 558 defineProperty("COMPILE_TARGETS", "$defaultHostTarget")
 559 
 560 // Flag indicating whether to import cross compile tools
 561 def importCrossTools = BUILD_CLOSED ? true : false;
 562 if (!importCrossTools && hasProperty("IMPORT_CROSS_TOOLS")) {
 563     importCrossTools = Boolean.parseBoolean(IMPORT_CROSS_TOOLS);
 564 }
 565 ext.IS_IMPORT_CROSS_TOOLS = importCrossTools
 566 
 567 // Location of the cross compile tools
 568 def crossToolsDir = "../crosslibs"
 569 if (hasProperty("CROSS_TOOLS_DIR")) {
 570     crossToolsDir = CROSS_TOOLS_DIR
 571 }
 572 ext.CROSS_TOOLS_DIR = file(crossToolsDir)
 573 
 574 // Specifies whether to run tests with the existing javafx.* modules instead of compiling a new one
 575 defineProperty("BUILD_SDK_FOR_TEST", "true")
 576 ext.DO_BUILD_SDK_FOR_TEST = Boolean.parseBoolean(BUILD_SDK_FOR_TEST)
 577 













 578 // All "classes" and "jar" tasks and their dependencies would be disabled
 579 // when running with DO_BUILD_SDK_FOR_TEST=false as they're unneeded for running tests
 580 if (!DO_BUILD_SDK_FOR_TEST) {
 581     gradle.taskGraph.useFilter({ task -> !task.name.equals("classes") && !task.name.equals("jar") })
 582 }
 583 
 584 /**
 585  * Fetch/Check that external tools are present for the build. This method
 586  * will conditionally download the packages from project defined ivy repositories
 587  * and unpack them into the specified destdir
 588  *
 589  * @param configName A unique name to distinguish the configuration (ie "ARMSFV6")
 590  * @param packages A list of required packages (with extensions .tgz, .zip)
 591  * @param destdir where the packages should be unpacked
 592  * @param doFetch if true, the named packages will be download
 593  */
 594 void fetchExternalTools(String configName, List packages, File destdir, boolean doFetch) {
 595     if (doFetch) {
 596         // create a unique configuration for this fetch
 597         def String fetchToolsConfig = "fetchTools$configName"


 673         }
 674     } else { // !doFetch - so just check they are present
 675         // check that all the dirs are really there
 676         def List<String> errors = []
 677         packages.each { pkgname->
 678             def String basename = pkgname.substring(0,pkgname.lastIndexOf("."))
 679             def File pkgdir = file("$destdir/$basename")
 680 
 681             if (!pkgdir.isDirectory()) {
 682                 errors.add(pkgname)
 683             }
 684         }
 685         if (errors.size > 0) {
 686             throw new GradleException("Error: missing tool packages: $errors")
 687         } else {
 688             logger.quiet "all tool packages are present $packages"
 689         }
 690     }
 691 }
 692 
 693 // Make an forked ANT call.
 694 // This needs to be forked so that ant can be used with the right JDK and updated modules
 695 // for testing obscure things like packaging of apps
 696 void ant(String conf,   // platform configuration
 697          String dir,    // directory to run from
 698          String target, // ant target
 699          List<String>  params // parameters (usually -Dxxx=yyy)
 700          ) {
 701     // Try to use ANT_HOME
 702     String antHomeEnv = System.getenv("ANT_HOME")
 703     String antHome = antHomeEnv != null ? cygpath(antHomeEnv) : null;
 704     String ant = (antHome != null && !antHome.equals("")) ? "$antHome/bin/ant" : "ant";
 705 
 706     exec {
 707         workingDir = dir
 708         environment("JDK_HOME", JDK_HOME)
 709         environment("JAVA_HOME", JDK_HOME)
 710         if (IS_WINDOWS) {
 711             environment([
 712                     "VCINSTALLDIR"         : WINDOWS_VS_VCINSTALLDIR,
 713                     "VSINSTALLDIR"         : WINDOWS_VS_VSINSTALLDIR,
 714                     "DEVENVDIR"            : WINDOWS_VS_DEVENVDIR,
 715                     "MSVCDIR"              : WINDOWS_VS_MSVCDIR,
 716                     "INCLUDE"              : WINDOWS_VS_INCLUDE,
 717                     "LIB"                  : WINDOWS_VS_LIB,
 718                     "LIBPATH"              : WINDOWS_VS_LIBPATH,
 719                     "DXSDK_DIR"            : WINDOWS_DXSDK_DIR
 720             ]);
 721             commandLine "cmd", "/c", ant, "-Dbuild.compiler=javac1.7"
 722         } else {
 723             commandLine ant, "-Dbuild.compiler=javac1.7"
 724         }
 725         if ((conf != null) && !rootProject.defaultHostTarget.equals(conf)) {
 726             def targetProperties = rootProject.ext[t.trim().toUpperCase()]
 727             args("-Dcross.platform=$conf")
 728             if (targetProperties.containsKey('arch')) {
 729                 args("-Dcross.platform.arch=${targetProperties.arch}")
 730             }
 731         }
 732         if (params != null) {
 733             params.each() { s->
 734                 args(s)
 735             }
 736         }
 737         args(target);
 738     }
 739 }
 740 
 741 List<String> computeLibraryPath(boolean working) {
 742     List<String> lp = []
 743     List<String> modsWithNative = [ 'graphics', 'media', 'web' ]
 744 
 745     // the build/modular-sdk area
 746     def platformPrefix = ""
 747     def modularSdkDirName = "${platformPrefix}modular-sdk"
 748     def modularSdkDir = "${rootProject.buildDir}/${modularSdkDirName}"
 749     def modulesLibsDir = "${modularSdkDir}/modules_libs"
 750     String suffix = ""
 751 
 752     if (!HOST_MODULES_ARCH.equals("")) {
 753         suffix = "/${HOST_MODULES_ARCH}"
 754     }
 755 
 756 
 757     modsWithNative.each() { m ->
 758         lp << cygpath("${modulesLibsDir}/javafx.${m}${suffix}")
 759     }
 760     return lp
 761 }
 762 
 763 // Return list with the arguments needed for --patch-module for the provided projects
 764 // used with Java executables ie. tests
 765 List<String> computePatchModuleArgs(List<String> deps, boolean test) {
 766      List<String> pma = []
 767 
 768      deps.each {String projname ->
 769          def proj = project(projname)
 770          if (proj.hasProperty("moduleName")) {
 771              File dir = proj.sourceSets.main.output.classesDir
 772              if (test && proj.sourceSets.hasProperty('shims')) {
 773                 dir = proj.sourceSets.shims.output.classesDir
 774              }
 775              String moduleName = proj.ext.moduleName
 776              String dirpath = cygpath("${dir}/${moduleName}")
 777              pma += "--patch-module=${moduleName}=${dirpath}"
 778          }
 779      }
 780 
 781     pma += "-Djava.library.path=" + computeLibraryPath(true).join(File.pathSeparator)
 782 
 783     return pma
 784 }
 785 
 786 // Return a list containing the --upgrade-module-path
 787 // used with Javac
 788 List<String> computeModulePathArgs(String  pname, List<String> deps, boolean test) {
 789      List<String> mpa = [ '--upgrade-module-path' ]
 790      String mp = null
 791      deps.each {String projname ->
 792          def proj = project(projname)
 793          // for a non test set of args, we don't want the current module in the list
 794          // for a test test, we do need it to update what we built
 795 
 796          if (proj.hasProperty("moduleName") &&
 797                  proj.buildModule &&
 798                      !(!test && proj.name.equals(pname))) {
 799                  File dir;
 800                  if (test && proj.sourceSets.hasProperty('shims')) {
 801                     dir = new File(proj.sourceSets.shims.output.classesDir, proj.ext.moduleName);
 802                  } else {
 803                     dir = new File(proj.sourceSets.main.output.classesDir, proj.ext.moduleName);
 804                  }
 805                  if (mp == null) {
 806                      mp = dir.path
 807                  } else {
 808                      mp = mp + File.pathSeparator + dir.path
 809                  }
 810              }
 811          }
 812 
 813          // in some cases like base we could end up with an empty
 814          // path... make sure we don't pass one back
 815          if (mp == null) {
 816              return null
 817          }
 818 
 819          mpa += mp
 820          return mpa
 821     }
 822 
 823     void writeCompileArgsFile(File dest, List<String>path) {
 824         dest.delete()
 825 
 826         logger.info("Creating file ${dest.path}")
 827         dest << "--upgrade-module-path\n"
 828 
 829         dest << "\"\\\n"
 830         path.each() { e->
 831             dest << "  "
 832             dest << cygpath(e)
 833             dest << File.pathSeparator
 834             dest << "\\\n"
 835         }
 836         dest << "\"\n"
 837     }
 838 
 839 void writeRunArgsFile(File dest, List<String> libpath, List<String> modpath) {
 840 
 841     dest.delete()
 842 
 843     logger.info("Creating file ${dest.path}")
 844 
 845     dest <<  "-Djava.library.path=\"\\\n"
 846     libpath.each() { e->
 847         dest << "  "
 848         dest << e
 849         dest << File.pathSeparator
 850         dest << "\\\n"
 851     }
 852     dest <<  "  \"\n"
 853 
 854     modpath.each { e ->
 855         dest <<  "--patch-module \""
 856         dest << e
 857         dest << "\"\n"
 858     }
 859 }
 860 
 861 // perform common project manipulation for modules
 862 void commonModuleSetup(Project p, List<String> moduleChain) {
 863 
 864     p.ext.moduleChain = moduleChain
 865 
 866     if (p.hasProperty("moduleName")) {
 867         p.ext.moduleDir = new File (p.sourceSets.main.output.classesDir, "${p.moduleName}")
 868     }
 869 
 870     def mpa = computeModulePathArgs(p.name, moduleChain, false)
 871     if (mpa != null) {
 872         p.ext.modulePathArgs = mpa
 873     }
 874 
 875     p.ext.testModulePathArgs = computeModulePathArgs(p.name, moduleChain, true)
 876     p.ext.patchModuleArgs = computePatchModuleArgs(moduleChain ,false)
 877     p.ext.testPatchModuleArgs = computePatchModuleArgs(moduleChain, true)
 878 
 879     moduleChain.each() {e ->
 880         if (!e.equals(p.name)) {
 881             p.compileJava.dependsOn(project(e).classes)
 882             p.compileTestJava.dependsOn(project(e).testClasses)
 883         }
 884     }
 885 
 886     // read in any addExports file
 887     File addExportsFile = new File(p.projectDir,"src/test/addExports")
 888     if (addExportsFile.exists()) {
 889         List<String> ae = []
 890         addExportsFile.eachLine { line ->
 891             line = line.trim()
 892             if (!(line.startsWith("#") || line.equals(""))) {
 893                 // one line arguments are a bit easier to debug
 894                 //if (line.startsWith('--add-exports ')) {
 895                 //    line = line.replaceFirst('--add-exports ', '--add-exports=')
 896                 //}
 897                 line = line.replace('--add-exports *', '--add-exports=')
 898                 ae += line.split(' ')
 899             }
 900         }
 901         p.ext.addExports  = ae.flatten()
 902     }
 903 }
 904 
 905 // Now we need to define the native compilation tasks. The set of parameters to
 906 // native compilation depends on the target platform (and also to some extent what platform
 907 // you are compiling on). These settings are contained in various gradle files
 908 // such as mac.gradle and linux.gradle and armhf.gradle. Additionally, the developer
 909 // can specify COMPILE_FLAGS_FILE to be a URL or path to a different gradle file
 910 // that will contain the appropriate flags.
 911 defineProperty("COMPILE_FLAGS_FILES", COMPILE_TARGETS.split(",").collect {"buildSrc/${it.trim()}.gradle"}.join(","))
 912 if (COMPILE_TARGETS == "all") {
 913     def tmp = []
 914     File buildSrcDir = file("buildSrc")
 915     buildSrcDir.listFiles().each { File f ->
 916         if (f.isFile() && f.name.endsWith(".gradle") && !f.name.equals("build.gradle")) {
 917             def target = f.name.substring(0, f.name.lastIndexOf('.gradle')).toUpperCase(Locale.ROOT)
 918             apply from: f
 919             if (project.ext["${target}"].canBuild) {
 920                 tmp.add(target)
 921             }
 922         }
 923     }
 924     COMPILE_FLAGS_FILES = tmp.collect { "buildSrc/${it}.gradle"}.join(",")


 928         logger.info("Applying COMPILE_FLAGS_FILE '$it'")
 929         apply from: it
 930     }
 931 }
 932 
 933 if (COMPILE_TARGETS != "") {
 934     def tmp = []
 935     COMPILE_TARGETS.split(",").each {target ->
 936         if (project.ext["${target.toUpperCase(Locale.ROOT)}"].canBuild) {
 937             tmp.add(target)
 938         }
 939     }
 940     COMPILE_TARGETS = tmp.collect { "${it.toLowerCase()}"}.join(",")
 941 }
 942 
 943 // Sanity check the expected properties all exist
 944 compileTargets { t ->
 945     // Every platform must define these variables
 946     if (!project.hasProperty(t.upper)) throw new Exception("ERROR: Incorrectly configured compile flags file, missing ${t.name} property")
 947     def props = project.ext[t.upper];
 948     // FIXME: KCR -- remove libDest in favor of modLibDest
 949     ["compileSwing", "compileSWT", "compileFXPackager", "libDest"].each { prop ->
 950         if (!props.containsKey(prop)) throw new Exception("ERROR: Incorrectly configured compile flags file, missing ${prop} property on ${t.name}")
 951     }
 952 }
 953 
 954 // Various build flags may be set by the different target files, such as
 955 // whether to build Swing, SWT, FXPackager, etc. We iterate over all
 956 // compile targets and look for these settings in our properties. Note that
 957 // these properties cannot be set from the command line, but are set by
 958 // the target build files such as armv6hf.gradle or mac.gradle.
 959 ext.COMPILE_SWING = false;
 960 ext.COMPILE_SWT = false;
 961 ext.COMPILE_FXPACKAGER = false;
 962 compileTargets { t ->
 963     def targetProperties = project.rootProject.ext[t.upper]
 964 
 965     if (targetProperties.compileSwing) COMPILE_SWING = true
 966     if (targetProperties.compileSWT) COMPILE_SWT = true
 967     if (IS_BUILD_FXPACKAGER && targetProperties.compileFXPackager) COMPILE_FXPACKAGER = true
 968 
 969     if (!targetProperties.containsKey('compileWebnodeNative')) {
 970         // unless specified otherwise, we will compile native Webnode if IS_COMPILE_WEBKIT
 971         targetProperties.compileWebnodeNative = true
 972     }
 973 
 974     if (!targetProperties.containsKey('compileMediaNative')) {
 975         // unless specified otherwise, we will compile native Media if IS_COMPILE_MEDIA
 976         targetProperties.compileMediaNative = true
 977     }
 978 
 979     if (!targetProperties.containsKey('includeSWT')) targetProperties.includeSWT = true
 980     if (!targetProperties.containsKey('includeSwing')) targetProperties.includeSwing = true
 981     if (!targetProperties.containsKey('includeNull3d')) targetProperties.includeNull3d = true
 982     if (!targetProperties.containsKey('includeLens')) targetProperties.includeLens = false
 983     if (!targetProperties.containsKey('includeMonocle')) targetProperties.includeMonocle = false
 984     if (!targetProperties.containsKey('includeEGL')) targetProperties.includeEGL = false
 985 
 986     if (!targetProperties.containsKey('includeGTK')) targetProperties.includeGTK = IS_LINUX
 987 
 988     if (!targetProperties.containsKey('modLibDest')) targetProperties.modLibDest = targetProperties.libDest
 989 
 990     if (!targetProperties.containsKey('modulesArch')) targetProperties.modulesArch = ""
 991 
 992     // This value is used as a prefix for various directories under ./build,
 993     // such as sdk, to allow for a common name for the hosted build
 994     // (for use when building apps) and a unique name for cross builds.
 995     if (rootProject.defaultHostTarget.equals(t.name)) {
 996         // use a simple common default for the "host" build
 997         targetProperties.platformPrefix=""
 998         rootProject.ext.HOST_MODULES_ARCH = targetProperties.modulesArch
 999     } else {
1000         // and a more complex one for cross builds
1001         targetProperties.platformPrefix="${t.name}-"
1002     }
1003 }
1004 
1005 /******************************************************************************
1006  *                                                                            *
1007  *                         Build Setup Sanity Checks                          *
1008  *                                                                            *
1009  *  Here we do a variety of checks so that if the version of Java you are     *
1010  *  building with is misconfigured, or you are using the wrong version of     *
1011  *  gradle, etc you will get some kind of helpful error / warning message     *
1012  *                                                                            *
1013  *****************************************************************************/
1014 
1015 // Sanity check that we actually have a list of compile targets to execute
1016 if (COMPILE_TARGETS == null || COMPILE_TARGETS == "") {
1017     throw new Exception("Unable to determine compilation platform, must specify valid COMPILE_TARGETS!")
1018 }
1019 
1020 // Make sure JDK_HOME/bin/java exists
1021 if (!file(JAVA).exists()) throw new Exception("Missing or incorrect path to 'java': '$JAVA'. Perhaps bad JDK_HOME? $JDK_HOME")

1022 if (!file(JAVAC).exists()) throw new Exception("Missing or incorrect path to 'javac': '$JAVAC'. Perhaps bad JDK_HOME? $JDK_HOME")

1023 if (!file(JAVAH).exists()) throw new Exception("Missing or incorrect path to 'javah': '$JAVAH'. Perhaps bad JDK_HOME? $JDK_HOME")
1024 if (!file(JAVADOC).exists()) throw new Exception("Missing or incorrect path to 'javadoc': '$JAVADOC'. Perhaps bad JDK_HOME? $JDK_HOME")
1025 
1026 // Determine the verion of Java in JDK_HOME. It looks like this:
1027 //
1028 // $ java -version
1029 // java version "1.7.0_45"
1030 // Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
1031 // Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)
1032 //
1033 // We need to parse the second line
1034 def inStream = new java.io.BufferedReader(new java.io.InputStreamReader(new java.lang.ProcessBuilder(JAVA, "-fullversion").start().getErrorStream()));
1035 try {
1036     String v = inStream.readLine().trim();
1037     if (v != null) {
1038         int ib = v.indexOf("full version \"");
1039         if (ib != -1) {
1040             String str = v.substring(ib);
1041             String ver = str.substring(str.indexOf("\"") + 1, str.size() - 1);
1042 


1048     }
1049 } finally {
1050     inStream.close();
1051 }
1052 if (!project.hasProperty("jdkRuntimeVersion")) throw new Exception("Unable to determine the version of Java in JDK_HOME at $JDK_HOME");
1053 
1054 
1055 
1056 // Verify that CONF is something useful
1057 if (CONF != "Release" && CONF != "Debug" && CONF != "DebugNative") {
1058     logger.warn("Unknown configuration CONF='$CONF'. Treating as 'Release'")
1059 }
1060 
1061 // If the number of compile threads is less than 1 then we have a problem!
1062 if (Integer.parseInt(NUM_COMPILE_THREADS.toString()) < 1) {
1063     logger.warn("NUM_COMPILE_THREADS was specified as '$NUM_COMPILE_THREADS' which is less than the minimum value of 1. " +
1064             "Building with a value of 1 instead.")
1065     NUM_COMPILE_THREADS = 1
1066 }
1067 
1068 // Check for Gradle 3.1, error if < 3.0.
1069 if (gradle.gradleVersion != "3.1") {
1070     def ver = gradle.gradleVersion.split("[\\.]");
1071     def gradleMajor = Integer.parseInt(ver[0]);
1072     def gradleMinor = Integer.parseInt(ver[1]);
1073     def err = "";
1074     if (gradleMajor < 3) {
1075         err = "Gradle version too old: ${gradle.gradleVersion}; must be at least 3.0"
1076     }
1077 
1078     if (IS_GRADLE_VERSION_CHECK && err != "") {
1079         fail(err);
1080     }
1081 
1082     logger.warn("*****************************************************************");
1083     logger.warn("Unsupported gradle version $gradle.gradleVersion in use.");
1084     logger.warn("Only version 3.1 is supported. Use this version at your own risk");
1085     if ( err != "") logger.warn(err);
1086     logger.warn("*****************************************************************");
1087 }
1088 
1089 /******************************************************************************
1090  *                                                                            *
1091  *                      Logging of Properties and Settings                    *
1092  *                                                                            *
1093  *  Log some of the settings we've determined. We could log more here, it     *
1094  *  doesn't really hurt.                                                      *
1095  *                                                                            *
1096  *****************************************************************************/
1097 
1098 logger.quiet("gradle.gradleVersion: $gradle.gradleVersion")
1099 logger.quiet("OS_NAME: $OS_NAME")
1100 logger.quiet("OS_ARCH: $OS_ARCH")
1101 logger.quiet("JAVA_HOME: $JAVA_HOME")
1102 logger.quiet("JDK_HOME: $JDK_HOME")

1103 logger.quiet("java.runtime.version: ${javaRuntimeVersion}")
1104 logger.quiet("java version: ${javaVersion}")
1105 logger.quiet("java build number: ${javaBuildNumber}")
1106 logger.quiet("jdk.runtime.version: ${jdkRuntimeVersion}")
1107 logger.quiet("jdk version: ${jdkVersion}")
1108 logger.quiet("jdk build number: ${jdkBuildNumber}")
1109 logger.quiet("minimum jdk version: ${jfxBuildJdkVersionMin}")
1110 logger.quiet("minimum jdk build number: ${jfxBuildJdkBuildnumMin}")
1111 logger.quiet("STUB_RUNTIME: $STUB_RUNTIME")
1112 logger.quiet("CONF: $CONF")
1113 logger.quiet("NUM_COMPILE_THREADS: $NUM_COMPILE_THREADS")
1114 logger.quiet("COMPILE_TARGETS: $COMPILE_TARGETS")
1115 logger.quiet("COMPILE_FLAGS_FILES: $COMPILE_FLAGS_FILES")
1116 logger.quiet("HUDSON_JOB_NAME: $HUDSON_JOB_NAME")
1117 logger.quiet("HUDSON_BUILD_NUMBER: $HUDSON_BUILD_NUMBER")
1118 logger.quiet("PROMOTED_BUILD_NUMBER: $PROMOTED_BUILD_NUMBER")
1119 logger.quiet("PRODUCT_NAME: $PRODUCT_NAME")
1120 logger.quiet("RELEASE_VERSION: $RELEASE_VERSION")
1121 logger.quiet("RELEASE_SUFFIX: $RELEASE_SUFFIX")
1122 logger.quiet("RELEASE_VERSION_SHORT: $RELEASE_VERSION_SHORT")


1156  * @param name The name of the project, such as "prism-common". This name is used
1157  *        in the name of the generated task, such as ccPrismCommon, and also
1158  *        in the name of the final library, such as libprism-common.dylib.
1159  */
1160 void addNative(Project project, String name) {
1161     // TODO if we want to handle 32/64 bit windows in the same build,
1162     // Then we will need to modify the win compile target to be win32 or win64
1163     def capitalName = name.split("-").collect{it.capitalize()}.join()
1164     def nativeTask = project.task("native$capitalName", group: "Build") {
1165         description = "Generates JNI headers, compiles, and builds native dynamic library for $name for all compile targets"
1166     }
1167     def cleanTask = project.task("cleanNative$capitalName", type: Delete, group: "Build") {
1168         description = "Clean native objects for $name"
1169     }
1170     if (project.hasProperty("nativeAllTask")) project.nativeAllTask.dependsOn nativeTask
1171     project.assemble.dependsOn(nativeTask)
1172     if (project.hasProperty("cleanNativeAllTask")) project.cleanNativeAllTask.dependsOn cleanTask
1173 
1174     // Each of the different compile targets will be placed in a sub directory
1175     // of these root dirs, with the name of the dir being the name of the target

1176     def nativeRootDir = project.file("$project.buildDir/native/$name")
1177     def libRootDir = project.file("$project.buildDir/libs/$name")
1178     // For each compile target, create a javah / cc / link triplet
1179     compileTargets { t ->
1180         def targetProperties = project.rootProject.ext[t.upper]
1181         def library = targetProperties.library
1182         def properties = targetProperties.get(name)
1183         def nativeDir = file("$nativeRootDir/${t.name}")
1184         def headerDir = file("${project.buildDir}/gensrc/headers/${project.moduleName}")
1185 
1186         // If there is not a library clause in the properties, assume it is not wanted
1187         if (!targetProperties.containsKey(name)) {
1188             println("Ignoring native library ${name}. Not defined in ${t.name} project properties");
1189             return
1190         }
1191 
1192         // check for the property disable${name} = true
1193         def String disableKey = "disable${name}"
1194         def boolean disabled = targetProperties.containsKey(disableKey) ? targetProperties.get(disableKey) : false
1195         if (disabled) {
1196             println("Native library ${name} disabled in ${t.name} project properties");
1197             return
1198         }
1199 


















1200         def variants = properties.containsKey("variants") ? properties.variants : [""];
1201         variants.each { variant ->
1202             def variantProperties = variant == "" ? properties : properties.get(variant)
1203             def capitalVariant = variant.capitalize()
1204             def ccOutput = variant == "" ? nativeDir : file("$nativeDir/$variant")
1205             def ccTask = project.task("cc${t.capital}$capitalName$capitalVariant", type: CCTask, group: "Build") {
1206                 description = "Compiles native sources for ${name} for ${t.name}${capitalVariant != '' ? ' for variant ' + capitalVariant : ''}"
1207                 matches = ".*\\.c|.*\\.cpp|.*\\.m|.*\\.cc"
1208                 headers = headerDir
1209                 output(ccOutput)
1210                 params.addAll(variantProperties.ccFlags)
1211                 compiler = variantProperties.compiler
1212                 source(variantProperties.nativeSource)
1213                 cleanTask.delete ccOutput
1214             }
1215             def linkTask = project.task("link${t.capital}$capitalName$capitalVariant", type: LinkTask, dependsOn: ccTask, group: "Build") {
1216                 description = "Creates native dynamic library for $name for ${t.name}${capitalVariant != '' ? ' for variant ' + capitalVariant : ''}"
1217                 objectDir = ccOutput
1218                 linkParams.addAll(variantProperties.linkFlags)
1219                 lib = file("$libRootDir/${t.name}/${variant == '' ? library(properties.lib) : library(variantProperties.lib)}")
1220                 linker = variantProperties.linker
1221                 cleanTask.delete "$libRootDir/${t.name}"
1222             }
1223             nativeTask.dependsOn(linkTask)
1224             if (IS_WINDOWS && t.name == "win") {
1225                 def rcTask = project.task("rc$capitalName$capitalVariant", type: CompileResourceTask, group: "Build") {
1226                     description = "Compiles native sources for $name"
1227                     matches = ".*\\.rc"
1228                     compiler = variantProperties.rcCompiler
1229                     source(variantProperties.rcSource)
1230                     if (variantProperties.rcFlags) {
1231                         rcParams.addAll(variantProperties.rcFlags)
1232                     }
1233                     output(ccOutput)
1234                 }
1235                 linkTask.dependsOn rcTask;
1236             }
1237         }
1238 
1239         def useLipo = targetProperties.containsKey('useLipo') ? targetProperties.useLipo : false
1240         if (useLipo) {
1241             def lipoTask = project.task("lipo${t.capital}$capitalName", type: LipoTask, group: "Build") {
1242                 description = "Creates native fat library for $name for ${t.name}"
1243                 libDir = file("$libRootDir/${t.name}")
1244                 lib = file("$libRootDir/${t.name}/${library(properties.lib)}")
1245             }
1246             nativeTask.dependsOn(lipoTask)
1247         }
1248     }
1249 }
1250 
1251 void addJSL(Project project, String name, String pkg, List<String> addExports, Closure compile) {
1252     def lowerName = name.toLowerCase()
1253 
1254     def compileCompilers = project.task("compile${name}Compilers",
1255             type: JavaCompile,
1256             dependsOn: project.compileJava) {
1257         description = "Compile the $name JSL Compilers"
1258 
1259         classpath = project.files(project.sourceSets.main.output.classesDir) +
1260                project.files(project.sourceSets.jslc.output.classesDir) +
1261                project.configurations.antlr
1262         source = [project.file("src/main/jsl-$lowerName")]
1263         destinationDir = project.file("$project.buildDir/classes/jsl-compilers/$lowerName")
1264 
1265         if (addExports != null) {
1266             options.compilerArgs.addAll(addExports)
1267         }
1268     }
1269 
1270     def generateShaders = project.task("generate${name}Shaders",
1271             dependsOn: compileCompilers) {
1272         description = "Generate $name shaders from JSL"
1273         def sourceDir = project.file("src/main/jsl-$lowerName")
1274         def destinationDir = project.file("$project.buildDir/gensrc/jsl-$lowerName")
1275         inputs.dir sourceDir
1276         outputs.dir destinationDir
1277         doLast {
1278             compile(sourceDir, destinationDir)
1279         }
1280     }
1281 
1282     def compileHLSLShaders = project.task("compile${name}HLSLShaders",
1283             dependsOn: generateShaders,
1284             type: CompileHLSLTask) {
1285         enabled = IS_WINDOWS
1286         description = "Compile $name HLSL files into .obj files"
1287         matches = ".*\\.hlsl"
1288         output project.file("$project.buildDir/hlsl/$name/$pkg")
1289         source project.file("$project.buildDir/gensrc/jsl-$lowerName/$pkg")
1290     }
1291 
1292     def processShaders = project.task("process${name}Shaders",
1293             dependsOn: [generateShaders, compileHLSLShaders],
1294             type: Copy,
1295             description: "Copy hlsl / frag shaders to build/resources/jsl-$lowerName") {
1296         from("$project.buildDir/hlsl/$name") {
1297             include "**/*.obj"
1298         }
1299         from("$project.buildDir/gensrc/jsl-$lowerName") {
1300             include("**/*.frag")
1301         }
1302         //into project.sourceSets.main.output.resourcesDir
1303         into project.moduleDir
1304     }
1305 
1306     project.processShaders.dependsOn(processShaders)
1307     project.sourceSets.shaders.output.dir("$project.buildDir/gensrc/jsl-$lowerName", builtBy: processShaders )
1308 
1309 }
1310 
1311 /**
1312  * Parses a JDK version string. The string must be in one of the following
1313  * two formats:
1314  *
1315  *     major.minor.subminor
1316  * or
1317  *     major.minor.subminor_update
1318  *
1319  * In both cases a list of 4 integers is returned, with element 3 set to
1320  * 0 in the former case.
1321  */
1322 List parseJdkVersion(String version) {
1323     def arr = version.split("[_\\.]");


1341     }
1342     return 0;
1343 }
1344 
1345 // Task to verify the minimum level of Java needed to build JavaFX
1346 task verifyJava() {
1347     doLast {
1348         def status = compareJdkVersion(jdkVersion, jfxBuildJdkVersionMin);
1349         if (status < 0) {
1350             fail("java version mismatch: JDK version (${jdkVersion}) < minimum version (${jfxBuildJdkVersionMin})")
1351         } else if (status == 0) {
1352             def buildNum = Integer.parseInt(jdkBuildNumber)
1353             def minBuildNum = Integer.parseInt(jfxBuildJdkBuildnumMin)
1354             if (buildNum != 0 && buildNum < minBuildNum) {
1355                 fail("JDK build number ($buildNum) < minimum build number ($minBuildNum)")
1356             }
1357         }
1358     }
1359 }
1360 
















1361 task updateCacheIfNeeded() {
1362     // an empty task we can add to as needed for UPDATE_STUB_CACHE
1363 }
1364 
1365 task createTestArgfiles {
1366     // an empty task we can add to as needed
1367 }
1368 
1369 
1370 /*****************************************************************************
1371 *        Project definitions (dependencies, etc)                             *
1372 *****************************************************************************/
1373 
1374 void addJCov(p, test) {
1375     test.doFirst {
1376         def jcovJVMArgument =
1377                 "include=javafx," +
1378                 "include=com.sun.javafx," +
1379                 "include=com.sun.glass," +
1380                 "include=com.sun.openpisces," +
1381                 "include=com.sun.pisces," +
1382                 "include=com.sun.prism," +
1383                 "include=com.sun.scenario," +
1384                 "include=com.sun.webkit," +
1385                 "exclude=com," +
1386                 "exclude=java," +
1387                 "exclude=javax," +
1388                 "exclude=\"**.test\"," +
1389                 "exclude=\"**.*Test\"," +


1406                         "-output", ".",
1407                         "-source", p.sourceSets.main.java.srcDirs.collect{p.file(it)}.join(":"),
1408                         "report.xml"
1409                 ]
1410             }
1411         }
1412     }
1413 }
1414 
1415 allprojects {
1416     // We want to configure all projects as java projects and use the same compile settings
1417     // etc, except for the root project which we just want to ignore (and for now media)
1418     if (project == rootProject) {
1419        return
1420     }
1421     if (project.path.startsWith(":apps")) {
1422         // Lets handle the apps tree differently, as it is a collection of ant builds,
1423         // and the ant importer collides with the 'apply plugin:java'
1424         return
1425     }
1426 
1427     // All of our projects are java projects
1428 
1429     apply plugin: "java"
1430     sourceCompatibility = 1.9
1431 
1432     // Setup the repositories that we'll download libraries from. Maven Central is
1433     // just easy for most things. The custom "ivy" repo is for downloading SWT. The way it
1434     // works is to setup the download URL such that it will resolve to the actual jar file
1435     // to download. See SWT_FILE_NAME for the name of the jar that will be used as the
1436     // "artifact" in the pattern below. Note that the closed builds use different repositories
1437     // so if you are debugging a closed-build artifact related build issue, check out the
1438     // closed gradle file instead.
1439     if (!BUILD_CLOSED) {
1440         repositories {
1441             mavenCentral()
1442             ivy {
1443                 url "http://download.eclipse.org/eclipse/updates/3.7/R-3.7.2-201202080800/plugins/"
1444                 layout "pattern", {
1445                     artifact "[artifact].[ext]"
1446                 }
1447             }
1448         }
1449     }
1450 
1451     // By default all of our projects require junit for testing so we can just
1452     // setup this dependency here.
1453     dependencies {
1454         testCompile group: "junit", name: "junit", version: "4.8.2"
1455         if (BUILD_CLOSED && DO_JCOV)  {
1456             testCompile name: "jcov"
1457         }
1458     }
1459 
1460     compileJava.dependsOn verifyJava






1461 
1462     // At the moment the ASM library shipped with Gradle that is used to
1463     // discover the different test classes fails on Java 8, so in order
1464     // to have sourceCompatibility set to 1.8 I have to also turn scanForClasses off
1465     // and manually specify the includes / excludes. At the moment we use
1466     // Java 7 but when we switch to 8 this will be needed, and probably again when
1467     // we start building with Java 9.
1468     test {
1469         executable = JAVA;
1470         enableAssertions = true;
1471         testLogging.exceptionFormat = "full";
1472         scanForTestClasses = false;
1473         include("**/*Test.*");
1474         if (BUILD_CLOSED && DO_JCOV) {
1475             addJCov(project, test)
1476         }
1477 
1478         if (IS_HEADLESS_TEST) {
1479             systemProperty 'glass.platform', 'Monocle'
1480             systemProperty 'monocle.platform', 'Headless'
1481             systemProperty 'prism.order', 'sw'
1482             systemProperty 'com.sun.javafx.gestures.zoom', 'true'
1483             systemProperty 'com.sun.javafx.gestures.rotate', 'true'
1484             systemProperty 'com.sun.javafx.gestures.scroll', 'true'
1485         }
1486 
1487         systemProperty 'unstable.test', IS_UNSTABLE_TEST




1488     }
1489 
1490     compileTestJava {





























1491     }
1492 }
1493 
1494 // These strings define the module-source-path to be used in compilation.
1495 // They need to contain the full paths to the sources and the * will be
1496 // used to infer the module name that is used.
1497 project.ext.defaultModuleSourcePath =
1498     cygpath(rootProject.projectDir.path + '/modules/*/src/main/java') +
1499         File.pathSeparator  +
1500     cygpath(rootProject.projectDir.path + '/modules/*/build/gensrc/{java,jsl-decora,jsl-prism}')
1501 
1502 // graphics pass one
1503 project.ext.defaultModuleSourcePath_GraphicsOne =
1504     cygpath(rootProject.projectDir.path + '/modules/*/src/main/java') +
1505         File.pathSeparator  +
1506     cygpath(rootProject.projectDir.path + '/modules/*/build/gensrc/{java,jsl-decora,jsl-prism}')
1507 
1508 // web pass one
1509 project.ext.defaultModuleSourcePath_WebOne =
1510     cygpath(rootProject.projectDir.path + '/modules/*/src/main/java')
1511 
1512 // Compiling the test shim files too.
1513 project.ext.defaultModuleSourcePathShim =
1514     cygpath(rootProject.projectDir.path + '/modules/*/src/{main,shims}/java') +
1515         File.pathSeparator  +
1516     cygpath(rootProject.projectDir.path + '/modules/*/build/gensrc/{java,jsl-decora,jsl-prism}')
1517 
1518 // The "base" project is our first module and the most basic one required for
1519 // all other modules. It is useful even for non-GUI applications.
1520 project(":base") {
1521     project.ext.buildModule = true
1522     project.ext.moduleRuntime = true
1523     project.ext.moduleName = "javafx.base"
1524 
1525     sourceSets {
1526         main
1527         shims
1528         test
1529     }
1530 
1531     dependencies {
1532         testCompile group: "junit", name: "junit", version: "4.8.2"
1533     }
1534 
1535     commonModuleSetup(project, [ 'base' ])
1536 
1537     project.ext.moduleSourcePath = defaultModuleSourcePath
1538     project.ext.moduleSourcePathShim = defaultModuleSourcePathShim
1539 
1540     // We need to take the VersionInfo.java file and replace the various
1541     // properties within it
1542     def replacements = [
1543         "BUILD_TIMESTAMP": BUILD_TIMESTAMP,
1544         "HUDSON_JOB_NAME": HUDSON_JOB_NAME,
1545         "HUDSON_BUILD_NUMBER": HUDSON_BUILD_NUMBER,
1546         "PROMOTED_BUILD_NUMBER": PROMOTED_BUILD_NUMBER,
1547         "PRODUCT_NAME": PRODUCT_NAME,
1548         "RELEASE_VERSION": RELEASE_VERSION,
1549         "RELEASE_SUFFIX": RELEASE_SUFFIX];
1550     task processVersionInfo(type: Copy, description: "Replace params in VersionInfo and copy file to destination") {
1551         doFirst { mkdir "$buildDir/gensrc/java" }
1552         from "src/main/version-info"
1553         into "$buildDir/gensrc/java/com/sun/javafx/runtime"
1554         filter {line->
1555             replacements.each() {k, v ->
1556                 line = line.replace("@$k@", v.toString());
1557             }
1558             line
1559         }
1560     }
1561 
1562 //    if (IS_COMPILE_JFR) {
1563 //        sourceSets.main.java.srcDirs += "src/main/java-jfr"
1564 //    }
1565 
1566     // Make sure to include $buildDir/gensrc/java that we previously created.
1567     // We DO NOT want to include src/main/version-info
1568 
1569     sourceSets.main.java.srcDirs += "$buildDir/gensrc/java"
1570 
1571     compileJava.dependsOn processVersionInfo
1572 }
1573 
1574 // The graphics module is needed for any graphical JavaFX application. It requires
1575 // the base module and includes the scene graph, layout, css, prism, windowing, etc.
1576 // This is a fairly complicated module. There are many different types of native components
1577 // that all need to be compiled.
1578 project(":graphics") {
1579 
1580     project.ext.buildModule = true
1581     project.ext.moduleRuntime = true
1582     project.ext.moduleName = "javafx.graphics"
1583 
1584     getConfigurations().create("antlr");
1585 
1586     sourceSets {

1587         jslc   // JSLC gramar subset
1588         main
1589         shims
1590         shaders // generated shaders (prism & decora)
1591         test
1592         stub
1593     }
1594 










1595     dependencies {
1596         stubCompile group: "junit", name: "junit", version: "4.8.2"




1597 
1598         antlr group: "org.antlr", name: "antlr-complete", version: "3.5.2"
1599     }
1600 
1601     project.ext.moduleSourcePath = defaultModuleSourcePath_GraphicsOne
1602     project.ext.moduleSourcePathShim = defaultModuleSourcePathShim
1603 
1604     commonModuleSetup(project, [ 'base', 'graphics' ])
1605 
1606     List<String> decoraAddExports = [
1607             '--add-exports=javafx.graphics/com.sun.scenario.effect=ALL-UNNAMED',
1608             '--add-exports=javafx.graphics/com.sun.scenario.effect.light=ALL-UNNAMED',
1609             '--add-exports=javafx.graphics/com.sun.scenario.effect.impl.state=ALL-UNNAMED'
1610             ]
1611     /*
1612     Graphics compilation is "complicated" by the generated shaders.
1613 
1614     We have two shader groups - Decora and Prism.
1615 
1616     The shader groups each will generate a custom compiler that
1617     then genarates the shader code. These compilers rely on the JSLC
1618     gramar parser which is antlr generated and compile separately.
1619 
1620     The decora compiler relies on compileJava - which is sourceSet.main.java
1621     It also accesses module private packages, so will need add-exports
1622 
1623     Once the shader java code is generated, we can compileFullJava
1624 
1625     After that, we can generate the required native header and then build the native code
1626     */
1627 
1628     project.task("processShaders") {
1629         // an empty task to hang the prism and decora shaders on
1630     }
1631 
1632     // Generate the JSLC support grammar
1633     project.task("generateGrammarSource", type: JavaExec) {
1634         // use antlr to generate our grammar.
1635         // note: the antlr plugin creates some issues with the other compiles
1636         // so we will do this by hand
1637 
1638         File wd = file(project.projectDir.path + "/src/jslc/antlr")
1639 
1640         executable = JAVA
1641         classpath = project.configurations.antlr
1642         workingDir = wd
1643         main = "org.antlr.Tool"
1644 
1645         args = [
1646             "-o",
1647             "$buildDir/gensrc/antlr",
1648             "com/sun/scenario/effect/compiler/JSL.g" ]
1649 
1650         inputs.dir wd
1651         outputs.dir file("$buildDir/gensrc/antlr")
1652     }
1653     sourceSets.jslc.java.srcDirs += "$buildDir/gensrc/antlr"
1654 
1655     // and compile the JSLC support classes
1656     compileJslcJava.dependsOn(generateGrammarSource)
1657     compileJslcJava.classpath = project.configurations.antlr
1658 
1659     compileJava.dependsOn(compileJslcJava)
1660 
1661     // this task is the "second pass" compile of all of the module classes
1662     project.task("compileFullJava", type: JavaCompile, dependsOn: processShaders) {
1663         description = "Compile all of the graphics java classes - main and shaders"
1664 
1665         classpath = configurations.compile
1666 
1667         source = project.sourceSets.main.java.srcDirs
1668         source += "$buildDir/gensrc/java"
1669         source += project.sourceSets.shaders.output
1670 
1671         project.sourceSets.shims.java.srcDirs += project.sourceSets.shaders.output
1672 
1673         destinationDir = project.sourceSets.main.output.classesDir
1674         options.compilerArgs.addAll([
1675             '-h', "$buildDir/gensrc/headers/",  // Note: this creates the native headers
1676             '-implicit:none',
1677             '--module-source-path', defaultModuleSourcePath
1678             ] )
1679     }
1680     classes.dependsOn(compileFullJava)
1681 
1682     // Create a single "native" task which will depend on all the individual native tasks for graphics
1683     project.ext.nativeAllTask = task("native", group: "Build", description: "Compiles and Builds all native libraries for Graphics");
1684     project.ext.cleanNativeAllTask = task("cleanNative", group: "Build", description: "Clean all native libraries and objects for Graphics");
1685 
1686     // Add tasks for native compilation
1687     addNative(project, "glass");
1688     addNative(project, "prism")
1689     addNative(project, "prismSW")
1690     addNative(project, "font")
1691     addNative(project, "iio")
1692     addNative(project, "prismES2")
1693 
1694     if (IS_COMPILE_PANGO) {
1695         addNative(project, "fontFreetype")
1696         addNative(project, "fontPango")
1697     }
1698 
1699     if (IS_WINDOWS) {
1700         addNative(project, "prismD3D")
1701         // TODO need to hook this up to be executed only if PassThroughVS.h is missing or PassThroughVS.hlsl is changed
1702         task generateD3DHeaders(group: "Build") {
1703             enabled = IS_WINDOWS

1704             inputs.file "src/main/native-prism-d3d/hlsl/Mtl1PS.hlsl"
1705             inputs.file "src/main/native-prism-d3d/hlsl/Mtl1VS.hlsl"
1706             inputs.file "src/main/native-prism-d3d/PassThroughVS.hlsl"
1707             outputs.dir "$buildDir/headers/PrismD3D/"
1708             outputs.dir "$buildDir/headers/PrismD3D/hlsl/"
1709             description = "Generate headers by compiling hlsl files"
1710             doLast {
1711                 mkdir file("$buildDir/headers/PrismD3D/hlsl")
1712                 def PS_3D_SRC = file("src/main/native-prism-d3d/hlsl/Mtl1PS.hlsl")
1713                 def VS_3D_SRC = file("src/main/native-prism-d3d/hlsl/Mtl1VS.hlsl")
1714                 def PASSTHROUGH_VS_SRC = file("src/main/native-prism-d3d/PassThroughVS.hlsl")
1715                 def jobs = [
1716                         ["$FXC", "/nologo", "/T", "vs_3_0", "/Fh", "$buildDir/headers/PrismD3D/PassThroughVS.h", "/E", "passThrough", "$PASSTHROUGH_VS_SRC"],
1717                         ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS.h", "/DSpec=0", "/DSType=0", "$PS_3D_SRC"],
1718                         ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_i.h", "/DSpec=0", "/DSType=0", "/DIllumMap=1", "$PS_3D_SRC"],
1719                         ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_s1n.h", "/DSpec=1", "/DSType=0", "$PS_3D_SRC"],
1720                         ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_s2n.h", "/DSpec=2", "/DSType=0", "$PS_3D_SRC"],
1721                         ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_s3n.h", "/DSpec=3", "/DSType=0", "$PS_3D_SRC"],
1722                         ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_s1t.h", "/DSpec=1", "/DSType=1", "$PS_3D_SRC"],
1723                         ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_s2t.h", "/DSpec=2", "/DSType=1", "$PS_3D_SRC"],


1791         }
1792 
1793         ccWinPrismD3D.dependsOn generateD3DHeaders
1794     }
1795 
1796     // The Decora and Prism JSL files have to be generated in a very specific set of steps.
1797     //      1) Compile the *Compile.java classes. These live in src/main/jsl-* and will be
1798     //         output to $buildDir/classes/jsl-compilers/* (where * == decora or prism).
1799     //      2) Generate source files from the JSL files contained in src/main/jsl-*. These
1800     //         will be output to $buildDir/gensrc/jsl-*
1801     //      3) Compile the JSL Java sources in $buildDir/gensrc/jsl-* and put the output
1802     //         into classes/jsl-*
1803     //      4) Compile the native JSL sources in $buildDir/gensrc/jsl-* and put the obj
1804     //         files into native/jsl-* and the resulting library into libs/jsl-*.dll|so|dylib
1805     //      5) Modify the jar step to include classes/jsl-*
1806     // The native library must be copied over during SDK creation time in the "sdk" task. In
1807     // addition to these steps, the clean task is created. Note that I didn't bother to create
1808     // a new task for each of the decora files, preferring instead just to create a rule?? Also
1809     // need "clean" tasks for each compile task.
1810 
1811     addJSL(project, "Decora", "com/sun/scenario/effect/impl/hw/d3d/hlsl", decoraAddExports) { sourceDir, destinationDir ->
1812         [[fileName: "ColorAdjust", generator: "CompileJSL", outputs: "-all"],
1813          [fileName: "Brightpass", generator: "CompileJSL", outputs: "-all"],
1814          [fileName: "SepiaTone", generator: "CompileJSL", outputs: "-all"],
1815          [fileName: "PerspectiveTransform", generator: "CompileJSL", outputs: "-all"],
1816          [fileName: "DisplacementMap", generator: "CompileJSL", outputs: "-all"],
1817          [fileName: "InvertMask", generator: "CompileJSL", outputs: "-all"],
1818          [fileName: "Blend", generator: "CompileBlend", outputs: "-all"],
1819          [fileName: "PhongLighting", generator: "CompilePhong", outputs: "-all"],
1820          [fileName: "LinearConvolve", generator: "CompileLinearConvolve", outputs: "-hw"],
1821          [fileName: "LinearConvolveShadow", generator: "CompileLinearConvolve", outputs: "-hw"]].each { settings ->
1822             javaexec {
1823                 executable = JAVA
1824                 workingDir = project.projectDir
1825                 main = settings.generator
1826                 classpath = configurations.compile + configurations.antlr
1827                 classpath += files(project.sourceSets.jslc.output.classesDir)
1828 
1829                 //classpath += files(project.sourceSets.jslc.resources) // not quite right..
1830                 classpath += files("${project.projectDir}/src/jslc/resources")
1831 
1832                 classpath += files("$buildDir/classes/main")
1833                 classpath += files("$buildDir/classes/jsl-compilers/decora")
1834                 jvmArgs += decoraAddExports
1835                 args += ["-i", sourceDir, "-o", destinationDir, "-t", "-pkg", "com/sun/scenario/effect", "$settings.outputs", "$settings.fileName"]
1836             }
1837         }
1838     }
1839 








1840 
1841     task nativeDecora(dependsOn: compileDecoraHLSLShaders, group: "Build") {
1842         description = "Generates JNI headers, compiles, and builds native dynamic library for Decora"
1843     }
1844     task cleanNativeDecora(type: Delete, group: "Build") {
1845         description = "Clean native objects for Decora"
1846     }
1847 
1848     def headerDir = file("$buildDir/gensrc/headers/javafx.graphics")
1849     def nativeRootDir = project.file("$project.buildDir/native/jsl-decora")
1850     def libRootDir = project.file("$project.buildDir/libs/jsl-decora")
1851     // For each compile target, create cc and link tasks
1852     compileTargets { t ->
1853         def target = t.name
1854         def upperTarget = t.upper
1855         def capitalTarget = t.capital
1856         def targetProperties = rootProject.ext[upperTarget];
1857         def library = targetProperties.library
1858         def properties = targetProperties.get('decora')
1859         def nativeDir = file("$nativeRootDir/$target");
1860 
1861         def variants = properties.containsKey("variants") ? properties.variants : [""];
1862         variants.each { variant ->
1863             def variantProperties = variant == "" ? properties : properties.get(variant)
1864             def capitalVariant = variant.capitalize()
1865             def ccOutput = variant == "" ? nativeDir : file("$nativeDir/$variant")
1866 
1867             def ccTask = task("compileDecoraNativeShaders$capitalTarget$capitalVariant", type: CCTask ) {
1868                 description = "Compiles Decora SSE natives for ${t.name}${capitalVariant != '' ? ' for variant ' + capitalVariant : ''}"
1869                 matches = ".*\\.cc"
1870                 source file("$buildDir/gensrc/jsl-decora")
1871                 source file(project.projectDir.path + "/src/main/native-decora")
1872                 headers = headerDir
1873                 params.addAll(variantProperties.ccFlags)
1874                 output(ccOutput)
1875                 compiler = variantProperties.compiler
1876                 cleanNativeDecora.delete ccOutput
1877             }
1878 
1879             def linkTask = task("linkDecoraNativeShaders$capitalTarget$capitalVariant", type: LinkTask, dependsOn: ccTask) {
1880                 description = "Creates native dynamic library for Decora SSE ${t.name}${capitalVariant != '' ? ' for variant ' + capitalVariant : ''}"
1881                 objectDir = ccOutput
1882                 linkParams.addAll(variantProperties.linkFlags)
1883                 lib = file("$libRootDir/$t.name/${library(variantProperties.lib)}")
1884                 linker = variantProperties.linker
1885                 cleanNativeDecora.delete "$libRootDir/$t.name/"
1886             }
1887 
1888             if (IS_WINDOWS && target == "win") {
1889                 def rcTask = project.task("rcDecoraNativeShaders$capitalTarget$capitalVariant", type: CompileResourceTask) {
1890                     description = "Compiles native sources for Decora SSE"
1891                     matches = ".*\\.rc"
1892                     compiler = variantProperties.rcCompiler
1893                     source(variantProperties.rcSource)
1894                     if (variantProperties.rcFlags) {
1895                         rcParams.addAll(variantProperties.rcFlags)
1896                     }
1897                     output(ccOutput)
1898                 }
1899                 linkTask.dependsOn rcTask;
1900             }
1901 
1902             nativeDecora.dependsOn(linkTask)
1903         }
1904     }
1905 
1906     // Prism JSL
1907     addJSL(project, "Prism", "com/sun/prism/d3d/hlsl", null) { sourceDir, destinationDir ->
1908         def inputFiles = fileTree(dir: sourceDir)
1909         inputFiles.include "**/*.jsl"
1910         inputFiles.each { file ->
1911             javaexec {
1912                 executable = JAVA
1913                 workingDir = project.projectDir
1914                 main = "CompileJSL"
1915                 classpath = configurations.compile + configurations.antlr
1916                 classpath += files(project.sourceSets.jslc.output.classesDir)
1917                 classpath += files(project.sourceSets.jslc.resources)
1918                 classpath += files("$buildDir/classes/jsl-compilers/prism",
1919                     project.projectDir.path + "/src/main/jsl-prism") // for the .stg
1920                 args = ["-i", sourceDir, "-o", destinationDir, "-t", "-pkg", "com/sun/prism", "-d3d", "-es2", "-name", "$file"]
1921             }
1922         }
1923     }
1924 
1925     nativePrism.dependsOn compilePrismHLSLShaders;
1926 
1927     project.nativeAllTask.dependsOn nativeDecora


1965             if (!f.exists()) allLibsPresent = false
1966         }
1967         if (allLibsPresent) return;
1968 
1969         for (File f : [configurations.compile.files, configurations.antlr.files].flatten()) {
1970             copy {
1971                 into libsDir
1972                 from f.getParentFile()
1973                 include "**/antlr-complete-3.5.2.jar"
1974                 includeEmptyDirs = false
1975             }
1976         }
1977     }
1978 }
1979 
1980 project(":controls") {
1981     project.ext.buildModule = true
1982     project.ext.moduleRuntime = true
1983     project.ext.moduleName = "javafx.controls"
1984 
1985     sourceSets {
1986         main
1987         shims
1988         test
1989     }
1990 
1991     project.ext.moduleSourcePath = defaultModuleSourcePath
1992     project.ext.moduleSourcePathShim = defaultModuleSourcePathShim
1993 
1994     commonModuleSetup(project, [ 'base', 'graphics', 'controls' ])
1995 
1996     dependencies {


1997         testCompile project(":graphics").sourceSets.test.output
1998         testCompile project(":base").sourceSets.test.output
1999     }
2000 
2001     test {
2002         def cssDir = file("$buildDir/classes/main/javafx")
2003         jvmArgs "-Djavafx.toolkit=test.com.sun.javafx.pgstub.StubToolkit",
2004             "-DCSS_META_DATA_TEST_DIR=$cssDir"
2005     }
2006 
2007     // TODO Css2Bin really should be moved out and put into buildSrc if it can be
2008     // TODO could change script to dynamically locate all .css files and create bss for them, probably better
2009     // TODO also not sure there is any benefit to having css files in the the runtime modules at all
2010     processResources << {
2011         ["$moduleDir/com/sun/javafx/scene/control/skin/caspian/caspian.css",
2012         "$moduleDir/com/sun/javafx/scene/control/skin/caspian/caspian-no-transparency.css",
2013         "$moduleDir/com/sun/javafx/scene/control/skin/caspian/embedded-qvga.css",
2014         "$moduleDir/com/sun/javafx/scene/control/skin/caspian/embedded.css",
2015         "$moduleDir/com/sun/javafx/scene/control/skin/caspian/fxvk.css",
2016         "$moduleDir/com/sun/javafx/scene/control/skin/caspian/highcontrast.css",
2017         "$moduleDir/com/sun/javafx/scene/control/skin/modena/modena.css",
2018         "$moduleDir/com/sun/javafx/scene/control/skin/modena/modena-no-transparency.css",
2019         "$moduleDir/com/sun/javafx/scene/control/skin/modena/touch.css"].each { css ->
2020             javaexec {
2021                 executable = JAVA
2022                 workingDir = project.projectDir
2023                 jvmArgs += patchModuleArgs


2024                 main = "com.sun.javafx.css.parser.Css2Bin"
2025                 args css
2026             }
2027         }
2028     }
2029 }
2030 
2031 project(":swing") {
2032     /* should not be built, but needed in JMX
2033     tasks.all {
2034         if (!COMPILE_SWING) it.enabled = false
2035     }
2036     */
2037     project.ext.buildModule = COMPILE_SWING
2038     project.ext.moduleRuntime = true
2039     project.ext.moduleName = "javafx.swing"
2040 
2041     sourceSets {
2042         main
2043         //shims // no test shims needed
2044         test
2045     }
2046 
2047     project.ext.moduleSourcePath = defaultModuleSourcePath
2048     project.ext.moduleSourcePathShim = defaultModuleSourcePathShim
2049 
2050     commonModuleSetup(project, [ 'base', 'graphics', 'swing' ])
2051 
2052     dependencies {
2053     }
2054 
2055     test {
2056         enabled = IS_FULL_TEST && IS_AWT_TEST
2057     }
2058 }
2059 
2060 project(":swt") {
2061     tasks.all {
2062         if (!COMPILE_SWT) it.enabled = false
2063     }
2064 
2065     // javafx.swt is an automatic module
2066     project.ext.buildModule = false
2067 
2068     commonModuleSetup(project, [ 'base', 'graphics' ])
2069 
2070     dependencies {

2071         compile name: SWT_FILE_NAME
2072     }
2073 
2074     classes << {
2075         // Copy all of the download libraries to libs directory for the sake of the IDEs
2076         File libsDir = rootProject.file("build/libs");
2077         File swtLib = new File(libsDir, "swt-debug.jar")
2078         libsDir.mkdirs();
2079 
2080         // Skip copy if file is present.
2081         if (swtLib.exists()) return;
2082 
2083         for (File f : configurations.compile.files) {
2084             // Have to rename the swt jar because it is some platform specific name but
2085             // for the sake of the IDEs we need to have a single stable name that works
2086             // on every platform
2087             copy {
2088                 into libsDir
2089                 from f.getParentFile()
2090                 include "**/*swt*.jar"
2091                 includeEmptyDirs = false
2092                 rename ".*swt.*jar", "swt-debug\\.jar"
2093             }
2094         }
2095     }
2096 
2097     compileJava.options.compilerArgs.addAll([
2098             "--add-exports=javafx.graphics/com.sun.glass.ui=ALL-UNNAMED",
2099             "--add-exports=javafx.graphics/com.sun.javafx.cursor=ALL-UNNAMED",
2100             "--add-exports=javafx.graphics/com.sun.javafx.embed=ALL-UNNAMED",
2101             "--add-exports=javafx.graphics/com.sun.javafx.stage=ALL-UNNAMED",
2102             "--add-exports=javafx.graphics/com.sun.javafx.tk=ALL-UNNAMED",
2103             ])
2104 
2105     test {
2106         enabled = IS_FULL_TEST && IS_SWT_TEST
2107 
2108         enabled = false // FIXME: JIGSAW -- support this with modules
2109         logger.info("JIGSAW Testing disabled for swt")
2110 

2111         if (IS_MAC) {
2112             enabled = false
2113             logger.info("SWT tests are disabled on MAC, because Gradle test runner does not handle -XstartOnFirstThread properly (https://issues.gradle.org/browse/GRADLE-3290).")
2114         }
2115     }

2116 }
2117 
2118 project(":fxml") {
2119     project.ext.buildModule = true
2120     project.ext.moduleRuntime = true
2121     project.ext.moduleName = "javafx.fxml"
2122 
2123     sourceSets {
2124         main
2125         shims
2126         test
2127     }
2128 
2129     project.ext.moduleSourcePath = defaultModuleSourcePath
2130     project.ext.moduleSourcePathShim = defaultModuleSourcePathShim
2131 
2132     commonModuleSetup(project, [ 'base', 'graphics', 'swing', 'controls', 'fxml' ])
2133 
2134 
2135     dependencies {



2136         testCompile project(":graphics").sourceSets.test.output
2137         testCompile project(":base").sourceSets.test.output
2138     }
2139 
2140     test {
2141         // StubToolkit is not *really* needed here, but because some code inadvertently invokes performance
2142         // tracker and this attempts to fire up the toolkit and this looks for native libraries and fails,
2143         // we have to use the stub toolkit for now.
2144         jvmArgs "-Djavafx.toolkit=test.com.sun.javafx.pgstub.StubToolkit"
2145         // FIXME: change this to also allow JDK 9 boot jdk
2146         classpath += files("$JDK_HOME/jre/lib/ext/nashorn.jar")
2147     }
2148 }
2149 
2150 project(":jmx") {
2151     project.ext.buildModule = false
2152     project.ext.moduleRuntime = false
2153     project.ext.moduleName = "javafx.jmx"
2154 
2155     commonModuleSetup(project, [ 'base', 'graphics', 'swing', 'controls', 'media', 'jmx' ])
2156 
2157     dependencies {




2158     }
2159 
2160     // Tests are permanently disabled
2161     test.enabled = false
2162 
2163     compileJava.options.compilerArgs.addAll([
2164             "--add-exports=javafx.graphics/com.sun.javafx.jmx=ALL-UNNAMED",
2165             "--add-exports=javafx.graphics/com.sun.scenario.animation=ALL-UNNAMED",
2166             "--add-exports=javafx.graphics/com.sun.scenario.animation.jmx=ALL-UNNAMED",
2167             "--add-exports=javafx.graphics/com.sun.javafx.stage=ALL-UNNAMED",
2168             "--add-exports=javafx.graphics/com.sun.javafx.scene=ALL-UNNAMED",
2169             "--add-exports=javafx.graphics/com.sun.javafx.tk=ALL-UNNAMED",
2170             "--add-exports=javafx.media/com.sun.media.jfxmedia=ALL-UNNAMED",
2171             "--add-exports=javafx.media/com.sun.media.jfxmedia.events=ALL-UNNAMED",
2172             ])
2173 }
2174 
2175 project(":fxpackagerservices") {
2176     project.ext.buildModule = COMPILE_FXPACKAGER
2177     project.ext.moduleRuntime = false
2178     project.ext.moduleName = "jdk.packager.services"
2179 
2180     sourceSets {
2181         main
2182         //shims // no test shims needed
2183         test
2184     }
2185 
2186     project.ext.moduleSourcePath = defaultModuleSourcePath
2187     project.ext.moduleSourcePathShim = defaultModuleSourcePathShim
2188 
2189     commonModuleSetup(project, [ 'base', 'graphics', 'controls' ])
2190 
2191     tasks.all {
2192         if (!COMPILE_FXPACKAGER) it.enabled = false
2193     }
2194 
2195 
2196     compileTestJava.enabled = false // FIXME: JIGSAW -- support this with modules
2197 
2198     test {

2199         enabled = false // FIXME: JIGSAW -- support this with modules
2200         logger.info("JIGSAW Testing disabled for fxpackagerservices")
2201     }

2202 }
2203 
2204 project(":fxpackager") {
2205     project.ext.buildModule = COMPILE_FXPACKAGER
2206     project.ext.moduleRuntime = false
2207     project.ext.moduleName = "jdk.packager"
2208 
2209     sourceSets {
2210         main
2211         //shims // no test shims needed
2212         test
2213     }
2214 
2215     project.ext.moduleSourcePath = defaultModuleSourcePath
2216     project.ext.moduleSourcePathShim = defaultModuleSourcePathShim
2217 
2218     commonModuleSetup(project, [ 'base', 'graphics', 'controls', 'fxpackagerservices', 'fxpackager' ])
2219 
2220     manifest {
2221         attributes(
2222                 "Main-Class": "com.sun.javafx.tools.packager.Main"
2223         )
2224     }
2225 
2226     tasks.all {
2227         if (!COMPILE_FXPACKAGER) it.enabled = false
2228     }
2229 
2230     sourceSets {
2231         main
2232         antplugin {
2233             java {
2234                 compileClasspath += main.output
2235                 runtimeClasspath += main.output
2236             }
2237         }
2238         test
2239     }
2240 
2241     // fxpackager has a dependency on ant in order to build the ant jar,
2242     // and as such needs to point to the apache binary repository
2243     if (!BUILD_CLOSED) {
2244         repositories {
2245             maven {
2246                 url "https://repository.apache.org"
2247             }
2248         }
2249     }
2250 
2251     dependencies {
2252         antpluginCompile group: "org.apache.ant", name: "ant", version: "1.8.2"
2253 
2254         testCompile project(":controls"),
2255             group: "org.apache.ant", name: "ant", version: "1.8.2",
2256             sourceSets.antplugin.output
2257     }
2258 
2259     //Note: these should be reflected in the module-info additions passed to the JDK
2260     compileJava.options.compilerArgs.addAll([
2261             "--add-exports=java.base/sun.security.timestamp=jdk.packager",
2262             "--add-exports=java.base/sun.security.x509=jdk.packager",
2263             "--add-exports=jdk.jdeps/com.sun.tools.jdeps=jdk.packager",
2264             "--add-exports=jdk.jlink/jdk.tools.jlink.internal.packager=jdk.packager",
2265 
2266             // Note: not in extras...
2267             "--add-exports=java.base/sun.security.pkcs=jdk.packager",
2268             "--add-exports=java.logging/java.util.logging=jdk.packager",
2269             ])
2270 
2271     compileAntpluginJava.dependsOn([ compileJava, processResources ])
2272     compileAntpluginJava.options.compilerArgs.addAll(
2273         computeModulePathArgs("antlib", project.moduleChain, false))
2274 
2275     task buildVersionFile() {
2276         File dir = new File("${project.projectDir}/build/resources/antplugin/resources");
2277         dir.mkdirs()
2278         File versionFile = new File(dir, "/version.properties");
2279         if (!versionFile.exists()) {
2280             versionFile << "version=$RELEASE_VERSION\n"
2281         }
2282         outputs.file(versionFile)
2283     }
2284 
2285     // When producing the ant-javafx.jar, we need to relocate a few class files
2286     // from their normal location to a resources/classes or resources/web-files
2287     // location
2288     task antpluginJar(type: Jar, dependsOn: [ compileJava, jar, compileAntpluginJava, buildVersionFile ]) {
2289         includeEmptyDirs = false
2290         archiveName = "ant-javafx.jar"
2291 
2292         from (sourceSets.antplugin.output) {
2293             eachFile { FileCopyDetails details ->
2294                 if (details.path.startsWith("com/javafx/main")) {
2295                     details.path = "resources/classes/$details.path"
2296                 }
2297             }
2298         }
2299 
2300         from (sourceSets.main.resources) {
2301             includes = [ "com/sun/javafx/tools/ant/antlib.xml" ]
2302         }
2303 
2304         from (sourceSets.main.output.resourcesDir) {
2305             includes = [ "resources/web-files/**" ]
2306         }
2307     }
2308 
2309     assemble.dependsOn(antpluginJar)
2310 
2311     // The "man" task will create a $buildDir/man containing the man
2312     // files for the system being built
2313     task man(type: Copy) {
2314         includeEmptyDirs = false
2315         enabled = (IS_LINUX || IS_MAC) && COMPILE_FXPACKAGER
2316         from "src/main/man"
2317         into "$buildDir/man"
2318         exclude "**/*.html"
2319         if (IS_MAC) exclude "**/ja_JP.UTF-8/**"
2320     }
2321     processResources.dependsOn man
2322 
2323     String buildClassesDir = "${sourceSets.main.output.classesDir}/${moduleName}"
2324 
2325     // Compile the native launchers. These are included in jdk.packager.jmod.
2326     if (IS_WINDOWS && COMPILE_FXPACKAGER) {
2327         task buildWinLauncher(type: CCTask, group: "Build") {
2328             description = "Compiles native sources for the application co-bundle launcher";
2329             matches = "WinLauncher\\.cpp";
2330             params.addAll(WIN.launcher.ccFlags);
2331             output(file("$buildDir/native/WinLauncher"));
2332             source(file("src/main/native/launcher/win"));
2333             compiler = WIN.launcher.compiler
2334             exe = true;
2335             linkerOptions.addAll(WIN.launcher.linkFlags);
2336             doLast {
2337                 copy {
2338                     from "$buildDir/native/WinLauncher/WinLauncher.exe"
2339                     from "$MSVCR"
2340                     from "$MSVCP"
2341                     into "${buildClassesDir}/main/com/oracle/tools/packager/windows"
2342                 }
2343             }
2344         }
2345         task compileWinLibrary(type: CCTask, group: "Build") {
2346             description = "Compiles native sources for the application co-bundle launcher library";
2347             matches = ".*\\.cpp"
2348             source(file("src/main/native/library/common"));
2349             params.addAll(WIN.launcherlibrary.ccFlags)
2350             output(file("$buildDir/native/WinLauncher/obj"));
2351             compiler = WIN.launcherlibrary.compiler
2352         }
2353         task linkWinLibrary(type: LinkTask, group: "Build", dependsOn: compileWinLibrary) {
2354             description = "Links native sources for the application co-bundle launcher library";
2355             objectDir = file("$buildDir/native/WinLauncher/obj")
2356             linkParams.addAll(WIN.launcherlibrary.linkFlags);
2357             lib = file("$buildDir/native/WinLauncher/packager.dll")
2358             linker = WIN.launcherlibrary.linker
2359             doLast {
2360                 copy {
2361                     from "$buildDir/native/WinLauncher/packager.dll"
2362                     into "${buildClassesDir}/com/oracle/tools/packager/windows"
2363                 }
2364             }
2365         }
2366         task buildWinLauncherSvc(type: CCTask, group: "Build") {
2367             description = "Compiles native sources for the application co-bundle launcher";
2368             matches = "WinLauncherSvc\\.cpp";
2369             params.addAll(WIN.launcher.ccFlags);
2370             output(file("$buildDir/native/WinLauncherSvc"));
2371             source(file("src/main/native/service/win"));
2372             compiler = WIN.launcher.compiler
2373             exe = true;
2374             linkerOptions.addAll(WIN.launcher.linkFlags);
2375             doLast {
2376                 copy {
2377                     from "$buildDir/native/WinLauncherSvc/WinLauncherSvc.exe"
2378                     into "${buildClassesDir}/com/oracle/tools/packager/windows"
2379                 }
2380             }
2381         }
2382         task buildIconSwap(type: CCTask, group: "Build") {
2383             description = "Compiles native sources for the application co-bundle launcher"
2384             matches = "IconSwap\\.cpp"
2385             params.addAll(WIN.iconLauncher.ccFlags)
2386             output(file("$buildDir/native/IconSwap"))
2387             source file("src/main/native/tools/win/iconswap")
2388             compiler = WIN.launcher.compiler
2389             exe = true
2390             linkerOptions.addAll(WIN.iconLauncher.linkFlags)
2391             doLast {
2392                 copy {
2393                     from "$buildDir/native/IconSwap/IconSwap.exe"
2394                     into "${buildClassesDir}/com/oracle/tools/packager/windows"
2395                 }
2396             }
2397         }
2398         task compileVersionInfoSwap(type: CCTask, group: "Build") {
2399             description = "Compiles native sources for the VersionInfoSwap tool";
2400             matches = ".*\\.cpp"
2401             source(file("src/main/native/tools/win/versioninfoswap"));
2402             params.addAll(WIN.versionInfoLauncher.ccFlags)
2403             output(file("$buildDir/native/VersionInfoSwap/obj"));
2404             compiler = WIN.versionInfoLauncher.compiler
2405         }
2406         task linkVersionInfoSwap(type: LinkTask, group: "Build", dependsOn: compileVersionInfoSwap) {
2407             description = "Links native sources for the VersionInfoSwap tool";
2408             objectDir = file("$buildDir/native/VersionInfoSwap/obj")
2409             linkParams.addAll(WIN.versionInfoLauncher.linkFlags);
2410             lib = file("$buildDir/native/VersionInfoSwap/VersionInfoSwap.exe")
2411             linker = WIN.versionInfoLauncher.linker
2412             doLast {
2413                 copy {
2414                     from "$buildDir/native/VersionInfoSwap/VersionInfoSwap.exe"
2415                     into "${buildClassesDir}/com/oracle/tools/packager/windows"
2416                 }
2417             }
2418         }
2419         task compileLauncher(dependsOn: [buildWinLauncher, linkWinLibrary, buildWinLauncherSvc, buildIconSwap, linkVersionInfoSwap])

2420     } else if (IS_MAC && COMPILE_FXPACKAGER) {
2421         task buildMacLauncher(type: CCTask, group: "Build") {
2422             description = "Compiles native sources for the application co-bundle launcher"
2423             matches = ".*\\.m"
2424             source file("src/main/native/launcher/mac")
2425             params.addAll(MAC.launcher.ccFlags)
2426             compiler = MAC.launcher.compiler
2427             output(file("${buildClassesDir}/com/oracle/tools/packager/mac"))
2428             outputs.file(file("${buildClassesDir}/main/com/oracle/tools/packager/mac/JavaAppLauncher"))
2429             eachOutputFile = { f ->
2430                 return new File(f.getParent(), "JavaAppLauncher")
2431             }
2432         }
2433         task compileMacLibrary(type: CCTask, group: "Build") {
2434             description = "Compiles native sources for the application co-bundle launcher library"
2435             matches = ".*\\.cpp|.*\\.mm"
2436             source file("src/main/native/library/common");
2437             params.addAll(MAC.launcherlibrary.ccFlags)
2438             compiler = MAC.launcherlibrary.compiler
2439             output(file("$buildDir/native/maclauncher/obj"))
2440         }
2441         task linkMacLibrary(type: LinkTask, group: "Build", dependsOn: compileMacLibrary) {
2442             description = "Links native sources for the application co-bundle launcher library"
2443             objectDir = file("$buildDir/native/maclauncher/obj")
2444             linkParams.addAll(MAC.launcherlibrary.linkFlags)
2445             linker = MAC.launcherlibrary.linker
2446             lib = file("${buildClassesDir}/com/oracle/tools/packager/mac/libpackager.dylib")
2447         }
2448         task compileLauncher(dependsOn: [buildMacLauncher, linkMacLibrary])

2449     } else if (IS_LINUX && COMPILE_FXPACKAGER) {
2450         task compileLinuxLauncher(type: CCTask, group: "Build") {
2451             description = "Compiles native sources for the application co-bundle launcher"
2452             matches = ".*\\.cpp"
2453             source file("src/main/native/launcher/linux")
2454             params.addAll(LINUX.launcher.ccFlags)
2455             compiler = LINUX.launcher.compiler
2456             output(file("$buildDir/native/linuxlauncher/launcherobj"))
2457         }
2458         task linkLinuxLauncher(type: LinkTask, dependsOn: compileLinuxLauncher, group: "Build") {
2459             description = "Links native dynamic library for the application co-bundle launcher"
2460             objectDir = file("$buildDir/native/linuxlauncher/launcherobj")
2461             linkParams.addAll(LINUX.launcher.linkFlags)
2462             linker = LINUX.launcher.linker
2463             lib = file("${buildClassesDir}/com/oracle/tools/packager/linux/JavaAppLauncher")
2464         }
2465         task compileLinuxLibrary(type: CCTask, group: "Build") {
2466             description = "Compiles native sources for the application co-bundle launcher library"
2467             matches = ".*\\.cpp"
2468             source file("src/main/native/library/common")
2469             params.addAll(LINUX.launcherlibrary.ccFlags)
2470             compiler = LINUX.launcherlibrary.compiler
2471             output(file("$buildDir/native/linuxlauncher/obj"))
2472         }
2473         task linkLinuxLibrary(type: LinkTask, dependsOn: compileLinuxLibrary, group: "Build") {
2474             description = "Links native dynamic library for the application co-bundle launcher library"
2475             objectDir = file("$buildDir/native/linuxlauncher/obj")
2476             linkParams.addAll(LINUX.launcherlibrary.linkFlags)
2477             linker = LINUX.launcherlibrary.linker
2478             lib = file("${buildClassesDir}/com/oracle/tools/packager/linux/libpackager.so")
2479         }
2480         task compileLauncher(dependsOn: [linkLinuxLauncher, linkLinuxLibrary])

2481     }
2482 
2483     // Builds the javapackager executable. For everything other than windows,
2484     // this is simply moving the existing shell script and ensuring it has proper
2485     // permissions. For Windows, this includes compiling the native executable
2486     if (IS_WINDOWS && COMPILE_FXPACKAGER){
2487         task buildJavaPackager(type: CCTask, group: "Build") {
2488             description = "Compiles native sources for javapackager.exe"
2489             matches = "javapackager\\.cpp"
2490             params.addAll(WIN.fxpackager.ccFlags)
2491             compiler = WIN.fxpackager.compiler
2492             output(file("$buildDir/native/javapackager"))
2493             source WIN.fxpackager.nativeSource
2494             doFirst {
2495                 copy {
2496                     mkdir "$buildDir/native"
2497                     mkdir "$buildDir/native/javapackager"
2498                     from file("src/main/native/javapackager/win/javapackager.manifest")
2499                     into file("$buildDir/native/javapackager")
2500                     filter { line->


2531                 })
2532                 copy {
2533                     from file("$buildDir/native/javapackager/javapackager.exe")
2534                     into file("$buildDir/javapackager")
2535                 }
2536             }
2537         }
2538     } else {
2539         task buildJavaPackager(group: "Build") {
2540             enabled = COMPILE_FXPACKAGER
2541             doLast {
2542                 copy {
2543                     from "src/main/native/javapackager/shell"
2544                     into "$buildDir/javapackager"
2545                     fileMode = 0755
2546                 }
2547             }
2548         }
2549     }
2550 
2551     assemble.dependsOn compileLauncher;
2552     assemble.dependsOn buildJavaPackager
2553 
2554     classes << {
2555         // Copy all of the download libraries to libs directory for the sake of the IDEs
2556         File libsDir = rootProject.file("build/libs");
2557         File antLib = new File(libsDir, "ant-1.8.2.jar")
2558         libsDir.mkdirs();
2559 
2560         // Skip copy if file is present.
2561         if (antLib.exists()) return;
2562 
2563         for (File f : configurations.compile.files) {
2564             copy {
2565                 into libsDir
2566                 from f.getParentFile()
2567                 include "**/ant-1.8.2.jar"
2568                 includeEmptyDirs = false
2569             }
2570         }
2571     }
2572 


2610         from compileTestJava.destinationDir
2611         include "hello/**"
2612 
2613         destinationDir project.file("build/tmp/tests/appResources")
2614         archiveName "packagedMainApp.jar"
2615 
2616         manifest {
2617             attributes(
2618                 "JavaFX-Application-Class": "hello.TestPackager",
2619             )
2620         }
2621     }
2622 
2623     if (!DO_BUILD_SDK_FOR_TEST) {
2624         def antJavafxJar = new File(TEST_SDK_DIR, "lib/ant-javafx.jar")
2625         [compileTestJava, test].each {
2626             it.classpath = files(antJavafxJar) + it.classpath
2627         }
2628     }
2629 
2630     compileTestJava.enabled = false // FIXME: JIGSAW -- support this with modules
2631     test {

2632         enabled = false // FIXME: JIGSAW -- support this with modules
2633         logger.info("JIGSAW Testing disabled for fxpackager")

2634 
2635         dependsOn packagerFXPackagedJar
2636         systemProperty "RETAIN_PACKAGER_TESTS", RETAIN_PACKAGER_TESTS
2637         systemProperty "TEST_PACKAGER_DMG", TEST_PACKAGER_DMG
2638         systemProperty "FULL_TEST", FULL_TEST
2639         executable = JAVA;
2640     }
2641 
2642     def packagerDevOpts = []
2643     try {
2644         packagerDevOpts.addAll(PACKAGER_DEV_OPTS.split(' '))
2645     } catch (MissingPropertyException ignore) {
2646         packagerDevOpts.addAll("image")
2647     }
2648 
2649     task packagerDev(dependsOn: [jar, testClasses, packagerFakeJar], type:JavaExec) {
2650         workingDir = project.file("build/tmp/tests/appResources/")
2651         executable = JAVA
2652         classpath = project.files("build/libs/ant-javafx.jar", "build/classes/test", "build/resources/test")
2653         main = "hello.SimpleBundle"
2654         args = [
2655                 '--module-path', JDK_JMODS,
2656                 '-o', "$projectDir/build/dev",
2657                 '-all',
2658                 packagerDevOpts
2659         ].flatten()
2660     }
2661 
2662     task buildRedistributableFiles() {
2663         def projectDir = "tools/java/redistributable-files"
2664         def sourceDir = "src/$projectDir"
2665         def buildDir = "build/$projectDir"
2666 
2667         doLast {
2668             exec {
2669                 commandLine(JAVAC)
2670                 args("-d")
2671                 args("$buildDir")
2672                 args("$sourceDir/RedistributableFiles.java")
2673             }
2674         }
2675     }
2676 
2677     task runRedistributableFiles() {
2678         def projectDir = "tools/java/redistributable-files"
2679         def sourceDir = "src/$projectDir"
2680         def buildDir = "build/$projectDir"
2681         def resourceDir = "build/resources/main/jdk/packager/internal/resources/tools/redistributable-files"
2682 
2683         doLast {
2684             def fxmodules = ""
2685 
2686             if (!file("$JDK_JMODS/jdk.packager.jmod").exists()) {
2687                 moduleProjList.each { project ->
2688                     if (fxmodules.isEmpty()) {
2689                         fxmodules = project.ext.moduleName
2690                     }
2691                     else {
2692                         fxmodules += "," + project.ext.moduleName
2693                     }
2694                 }
2695             }
2696 
2697             exec {
2698                 commandLine(JAVA)
2699                 args("-classpath")
2700                 args("$buildDir")
2701                 args("RedistributableFiles")
2702                 args("--module-path")
2703                 args("$JDK_JMODS")
2704                 args("--exclude-filelist")
2705                 args("$sourceDir/exclude_modules.list")
2706                 args("--out-file")
2707                 args("$resourceDir/redistributable.list")
2708 
2709                 if (!fxmodules.isEmpty()) {
2710                     args("--add-modules")
2711                     args("$fxmodules")
2712                 }
2713             }
2714         }
2715     }
2716 
2717     runRedistributableFiles.dependsOn buildRedistributableFiles
2718     processResources.dependsOn runRedistributableFiles
2719 }
2720 
2721 project(":media") {
2722     configurations {
2723         media
2724     }
2725 
2726     project.ext.buildModule = true
2727     project.ext.moduleRuntime = true
2728     project.ext.moduleName = "javafx.media"
2729 
2730     sourceSets {
2731         main
2732         //shims // no test shims needed
2733         test
2734         tools {
2735             java.srcDir "src/tools/java"
2736         }
2737     }
2738 
2739     project.ext.moduleSourcePath = defaultModuleSourcePath
2740     project.ext.moduleSourcePathShim = defaultModuleSourcePathShim
2741 
2742     commonModuleSetup(project, [ 'base', 'graphics', 'media' ])
2743 
2744     dependencies {

2745     }
2746 
2747     compileJava.dependsOn updateCacheIfNeeded
2748 
2749     compileJava {
2750         // generate the native headers during compile
2751         options.compilerArgs.addAll([
2752             '-h', "${project.buildDir}/gensrc/headers"
2753             ])
2754     }
2755 
2756     compileToolsJava {
2757         enabled = IS_COMPILE_MEDIA
2758         options.compilerArgs.addAll(project.modulePathArgs)
2759         options.compilerArgs.addAll([
2760             '--add-exports', 'javafx.media/com.sun.media.jfxmedia=ALL-UNNAMED',
2761             ])
2762     }
2763 
2764     project.ext.makeJobsFlag = IS_WINDOWS && IS_DEBUG_NATIVE ? "-j1" : "-j5";
2765     project.ext.buildType = IS_DEBUG_NATIVE ? "Debug" : "Release";
2766 
2767     def nativeSrcDir = file("${projectDir}/src/main/native")
2768     def generatedHeadersDir = file("${buildDir}/gensrc/headers/${project.moduleName}")































2769 
2770     task generateMediaErrorHeader(dependsOn: [compileToolsJava, compileJava]) {
2771         enabled = IS_COMPILE_MEDIA
2772         def headerpath = file("$generatedHeadersDir/jfxmedia_errors.h");
2773         doLast {
2774             def classpath = files(sourceSets.tools.output);
2775             def sourcepath = sourceSets.main.java.srcDirs;

2776             def srcRoot = (sourcepath.toArray())[0];
2777 
2778             mkdir generatedHeadersDir;
2779 
2780             exec {
2781                 commandLine("$JAVA");
2782                 args += patchModuleArgs
2783                 args +=  [ '--add-exports=javafx.media/com.sun.media.jfxmedia=ALL-UNNAMED' ]
2784                 args +=  [ '-classpath', "${classpath.asPath}" ]
2785                 args += [ "headergen.HeaderGen", "$headerpath", "$srcRoot" ]
2786             }
2787         }
2788         outputs.file(project.file("$headerpath"))
2789     }
2790 
2791     task buildNativeTargets {
2792         enabled = IS_COMPILE_MEDIA
2793     }
2794 
2795     compileTargets { t->
2796         def targetProperties = project.rootProject.ext[t.upper]
2797         def nativeOutputDir = file("${buildDir}/native/${t.name}")
2798         def projectDir = t.name.startsWith("arm") ? "linux" : t.name
2799         def mediaProperties = targetProperties.media
2800         // Makefile for OSX needs to know if we're building for parfait
2801         def compileParfait = IS_COMPILE_PARFAIT ? "true" : "false"
2802 
2803         def buildNative = task("build${t.capital}Native", dependsOn: [generateMediaErrorHeader]) {
2804             enabled = targetProperties.compileMediaNative
2805             if (!targetProperties.compileMediaNative) {
2806                 println("Not compiling native Media for ${t.name} per configuration request");
2807             }
2808 
2809             doLast {
2810                 exec {
2811                     commandLine ("make", "${makeJobsFlag}", "-C", "${nativeSrcDir}/jfxmedia/projects/${projectDir}")
2812                     args("JAVA_HOME=${JDK_HOME}", "GENERATED_HEADERS_DIR=${generatedHeadersDir}",
2813                          "OUTPUT_DIR=${nativeOutputDir}", "BUILD_TYPE=${buildType}", "BASE_NAME=jfxmedia",
2814                          "COMPILE_PARFAIT=${compileParfait}",
2815                          IS_64 ? "ARCH=x64" : "ARCH=x32",
2816                         "CC=${mediaProperties.compiler}", "LINKER=${mediaProperties.linker}")
2817 
2818                     if (t.name == "win") {
2819                         environment(WINDOWS_NATIVE_COMPILE_ENVIRONMENT)
2820                         args( "RESOURCE=${nativeOutputDir}/${buildType}/${WIN.media.jfxmediaRcFile}")
2821                     } else {
2822                         if (t.name.startsWith("arm")) {
2823                             args("EXTRA_CFLAGS=${mediaProperties.extra_cflags}", "EXTRA_LDFLAGS=${mediaProperties.extra_ldflags}")


3006     }
3007 
3008     jar {
3009         exclude("headergen/**")
3010 
3011         dependsOn compileJava
3012         if (IS_COMPILE_MEDIA) {
3013             dependsOn buildNativeTargets
3014         }
3015     }
3016 }
3017 
3018 project(":web") {
3019     configurations {
3020         webkit
3021     }
3022     project.ext.buildModule = true
3023     project.ext.moduleRuntime = true
3024     project.ext.moduleName = "javafx.web"
3025 
3026     sourceSets {
3027         main
3028         shims
3029         test
3030     }
3031 
3032     project.ext.moduleSourcePath = defaultModuleSourcePath
3033     project.ext.moduleSourcePathShim = defaultModuleSourcePathShim
3034 
3035     commonModuleSetup(project, [ 'base', 'graphics', 'controls', 'media', 'web' ])
3036 
3037     dependencies {

3038     }
3039 
3040     compileJava.dependsOn updateCacheIfNeeded
3041 
3042     task webArchiveJar(type: Jar) {
3043         from (project.file("$projectDir/src/test/resources/test/html")) {
3044             include "**/archive-*.*"
3045         }
3046         archiveName = "webArchiveJar.jar"
3047         destinationDir = file("$buildDir/testing/resources")
3048     }
3049 
3050     def gensrcDir = "${buildDir}/gensrc/java"
3051 
3052     // add in the wrappers to the compile
3053     sourceSets.main.java.srcDirs += "${gensrcDir}"
3054 
3055     if (IS_COMPILE_WEBKIT) {
3056         compileJava {
3057             // generate the native headers during compile
3058             // only needed if we are doing the native compile
3059             options.compilerArgs.addAll([
3060                 '-h', "${project.buildDir}/gensrc/headers"
3061                 ])
3062         }
3063     } else {
3064         // Instead of compiling native wrappers, use a pre-generated version
3065 
3066         // Copy these to a common location in the moduleSourcePath
3067         def copyWrappers = project.task("copyPreGeneratedWrappers", type: Copy) {
3068             enabled =  (!IS_COMPILE_WEBKIT)
3069 
3070             from "src/main/java-wrappers"
3071             into "${gensrcDir}"
3072         }
3073 
3074         compileJava.dependsOn(copyWrappers);
3075     }
3076 
3077     test {
3078         /*
3079         if (!IS_JIGSAW_TEST) {
3080         //TODO: support this in Jake
3081         // Run web tests in headless mode
3082         systemProperty 'glass.platform', 'Monocle'
3083         systemProperty 'monocle.platform', 'Headless'
3084         systemProperty 'prism.order', 'sw'
3085         }
3086         */
3087         dependsOn webArchiveJar
3088         def testResourceDir = file("$buildDir/testing/resources")
3089         jvmArgs "-DWEB_ARCHIVE_JAR_TEST_DIR=$testResourceDir"
3090     }
3091 
3092     // generate some headers that are not part of our build




3093     task generateHeaders(dependsOn: compileJava) {
3094         doLast {
3095             def dest = file("$buildDir/gensrc/headers/${project.moduleName}");


3096             mkdir dest;
3097             exec {
3098                 commandLine("$JAVAH", "-d", "$dest",);

3099                 args("java.lang.Character",
3100                      "java.net.IDN",
3101                      );






























3102             }
3103         }
3104     }
3105 
3106     task compileGenerated()
3107 
3108     compileTargets { t ->
3109         def targetProperties = project.rootProject.ext[t.upper]
3110         def classifier = (t.name != "linux" && t.name != "win") ? t.name :
3111                           IS_64 ? "${t.name}-amd64" : "${t.name}-i586"
3112         dependencies {
3113             webkit group: "com.sun.webkit", name: "webview-deps",
3114                    version: "1.3.1", classifier: "$classifier", ext: "zip"
3115         }
3116 
3117         def webkitOutputDir = cygpath("$buildDir/${t.name}")
3118         def webkitConfig = IS_DEBUG_NATIVE ? "Debug" : "Release"
3119 
3120         def compileNativeTask = task("compileNative${t.capital}", dependsOn: [generateHeaders, compileJava]) {
3121             println "Building Webkit configuration /$webkitConfig/ into $webkitOutputDir"
3122             enabled =  (IS_COMPILE_WEBKIT)
3123 
3124             outputs.dir("$webkitOutputDir/$webkitConfig/DerivedSources/WebCore/nativeJava/java")
3125 
3126             doLast {
3127                 def dependencyFile = configurations.webkit.filter(
3128                         { File f -> f.getName().contains(classifier) }
3129                     ).getSingleFile()
3130                 ant.unzip(src:  dependencyFile,
3131                           dest: webkitOutputDir)
3132 
3133                 exec {
3134                     workingDir("$projectDir/src/main/native")
3135                     commandLine("perl", "Tools/Scripts/set-webkit-configuration", "--$webkitConfig")
3136                     environment(["WEBKIT_OUTPUTDIR" : webkitOutputDir])
3137                 }
3138 
3139                 exec {
3140                     workingDir("$projectDir/src/main/native")
3141                     def cmakeArgs = "-DENABLE_TOOLS=1"
3142                     if (t.name == "win") {
3143                         String parfaitPath = IS_COMPILE_PARFAIT ? System.getenv().get("PARFAIT_PATH") + ";" : "";
3144                         Map environmentSettings = new HashMap(WINDOWS_NATIVE_COMPILE_ENVIRONMENT)
3145                         environmentSettings["PATH"] = parfaitPath + "$WINDOWS_VS_PATH"
3146                         /* To build with ICU:


3178                     if (IS_64) {
3179                         targetCpuBitDepthSwitch = "--64-bit"
3180                     } else {
3181                         targetCpuBitDepthSwitch = "--32-bit"
3182                     }
3183 
3184                     commandLine("perl", "Tools/Scripts/build-webkit",
3185                         "--java", "--icu-unicode", targetCpuBitDepthSwitch,
3186                         "--cmakeargs=${cmakeArgs}")
3187                 }
3188 
3189                 def library = rootProject.ext[t.upper].library
3190                 copy {
3191                     from "$webkitOutputDir/$webkitConfig/lib/${library('jfxwebkit')}"
3192                     into "$buildDir/libs/${t.name}"
3193                 }
3194                 copy {
3195                     from "$webkitOutputDir/$webkitConfig/lib/${library('DumpRenderTreeJava')}"
3196                     into "$buildDir/test/${t.name}"
3197                 }
3198 
3199             }
3200         }
3201 
3202         if (IS_WINDOWS && t.name == "win") {
3203             def webkitProperties = project.rootProject.ext[t.upper].webkit
3204             def rcTask = project.task("rc${t.capital}", type: CompileResourceTask) {
3205                 compiler = webkitProperties.rcCompiler
3206                 source(webkitProperties.rcSource)
3207                 if (webkitProperties.rcFlags) {
3208                     rcParams.addAll(webkitProperties.rcFlags)
3209                 }
3210                 output(file("$webkitOutputDir/$webkitConfig/WebCore/obj"))
3211             }
3212             compileNativeTask.dependsOn rcTask
3213         }
3214 
3215         def copyGeneratedTask = task("copyGenerated${t.capital}", dependsOn: [compileJava, compileNativeTask]) {
3216             enabled =  (IS_COMPILE_WEBKIT)
3217 
3218             outputs.dir "${gensrcDir}"
3219 
3220             doLast{
3221                 copy {
3222                     from "$projectDir/src/main/java-wrappers/com/sun/webkit/dom/EventListenerImpl.java"
3223                     into "${gensrcDir}/com/sun/webkit/dom"
3224                 }
3225                 copy {
3226                     from "$webkitOutputDir/$webkitConfig/DerivedSources/WebCore/nativeJava/java"
3227                     into "${gensrcDir}"
3228                 }
3229             }
3230         }
3231 
3232         def compileGeneratedTask = task("compileGenerated${t.capital}", type: JavaCompile, dependsOn: copyGeneratedTask) {
3233             destinationDir = file("$buildDir/classes/main")
3234             classpath = configurations.compile
3235             source = project.sourceSets.main.java.srcDirs
3236             options.compilerArgs.addAll([
3237                 '-implicit:none',
3238                 '--module-source-path', defaultModuleSourcePath
3239                 ])
3240         }
3241 
3242         compileGenerated.dependsOn compileGeneratedTask
3243 
3244         if (!targetProperties.compileWebnodeNative) {
3245             println("Not compiling native Webkit for ${t.name} per configuration request");
3246             compileNativeTask.enabled = false
3247         }
3248     }
3249 
3250     def drtClasses = "com/sun/javafx/webkit/drt/**"
3251     jar.exclude(drtClasses)
3252     task drtJar(type: Jar, dependsOn: compileJava) {
3253         archiveName = "drt.jar"
3254         destinationDir = file("$buildDir/test")
3255         from "$buildDir/classes/main"
3256         include drtClasses
3257     }
3258 
3259     if (IS_COMPILE_WEBKIT) {
3260         assemble.dependsOn compileGenerated, drtJar
3261     }
3262 }
3263 
3264 // This project is for system tests that need to run with a full SDK.
3265 // Most of them display a stage or do other things that preclude running
3266 // them in a shared JVM or as part of the "smoke test" run (which must
3267 // not pop up any windows or use audio). As such, they are only enabled
3268 // when FULL_TEST is specified, and each test runs in its own JVM
3269 project(":systemTests") {
3270 
3271     project.ext.buildModule = false
3272     project.ext.moduleRuntime = false
3273     project.ext.moduleName = "systemTests"
3274 
3275     dependencies {
3276         testCompile project(":graphics").sourceSets.test.output
3277         testCompile project(":base").sourceSets.test.output
3278         testCompile project(":controls").sourceSets.test.output
3279         testCompile project(":swing").sourceSets.test.output
3280     }
3281 
3282     commonModuleSetup(project, [ 'base', 'graphics', 'controls', 'media', 'web', 'swing', 'fxml' ])
3283 
3284     File patchPolicyFile = new File(project.buildDir, TESTJAVAPOLICYFILE);
3285     File runArgsFile = new File(project.buildDir,RUNARGSFILE);
3286 
3287     def sts = task("systemTestSetup") {
3288         outputs.file(patchPolicyFile)
3289         outputs.file(runArgsFile)
3290 
3291         doLast() {
3292             runArgsFile.delete()
3293             patchPolicyFile.delete()
3294 
3295             logger.info("Creating patchmodule.args file ${runArgsFile}")
3296 
3297             // Create an argfile with the information needed to launch
3298             // the stand alone system unit tests.
3299 
3300             //First add in all of the patch-module args we use for the
3301             //normal unit tests
3302             testPatchModuleArgs.each { str ->
3303                 runArgsFile <<  "${str}\n"
3304             }
3305 
3306             // Now add in the working classpath elements (junit, test classes...)
3307             runArgsFile <<  "-cp \"\\\n"
3308             test.classpath.each() { elem ->
3309                 def e = cygpath("${elem}")
3310                 runArgsFile <<  "  ${e}${File.pathSeparator}\\\n"
3311             }
3312             runArgsFile <<  "\"\n"
3313 
3314             // Now create a policy file with full paths matching the patched modules
3315             // we have provided. This needs to be in sync with testPatchModuleArgs
3316             moduleProjList.each { project ->
3317                 if (project.hasProperty("moduleName") && project.buildModule) {
3318                     File dir;
3319                     if (test && project.sourceSets.hasProperty('shims')) {
3320                        dir = new File(project.sourceSets.shims.output.classesDir, project.ext.moduleName);
3321                     } else {
3322                        dir = new File(project.sourceSets.main.output.classesDir, project.ext.moduleName);
3323                     }
3324 
3325                     String themod = dir.toURI()
3326                     patchPolicyFile <<  "grant codeBase \"${themod}\" {\n" +
3327                     "    permission java.security.AllPermission;\n" +
3328                     "};\n"
3329                 }
3330             }
3331         }
3332     }
3333 
3334     test.dependsOn(sts)
3335     test.dependsOn(createTestArgfiles);
3336 
3337     test {
3338         enabled = IS_FULL_TEST
3339 
3340         // Properties passed to test.util.Util
3341         systemProperties 'worker.debug': IS_WORKER_DEBUG
3342         systemProperties 'worker.patchmodule.file': cygpath(runArgsFile.path)
3343         systemProperties 'worker.patch.policy': cygpath(patchPolicyFile.path)
3344         systemProperties 'worker.java.cmd': JAVA
3345 
3346         if (!IS_USE_ROBOT) {
3347             // Disable all robot-based visual tests
3348             exclude("test/robot/**");
3349         }
3350         if (!IS_AWT_TEST) {
3351             // Disable all AWT-based tests
3352             exclude("**/javafx/embed/swing/*.*");
3353             exclude("**/com/sun/javafx/application/Swing*.*");
3354         }
3355 
3356         forkEvery = 1
3357     }
3358 }
3359 
3360 allprojects {
3361     // The following block is a workaround for the fact that presently Gradle
3362     // can't set the -XDignore.symbol.file flag, because it appears that the
3363     // javac API is lacking support for it. So what we'll do is find any Compile
3364     // task and manually provide the options necessary to fire up the
3365     // compiler with the right settings.


3366     tasks.withType(JavaCompile) { compile ->
3367         if (compile.options.hasProperty("useAnt")) {
3368             compile.options.useAnt = true
3369             compile.options.useDepend = IS_USE_DEPEND
3370         } else if (compile.options.hasProperty("incremental")) {
3371             compile.options.incremental = IS_INCREMENTAL
3372         }
3373         compile.options.debug = true // we always generate debugging info in the class files
3374         compile.options.debugOptions.debugLevel = IS_DEBUG_JAVA ? "source,lines,vars" : "source,lines"
3375         compile.options.fork = true
3376 
3377         compile.options.forkOptions.executable = JAVAC
3378 
3379         compile.options.warnings = IS_LINT
3380 
3381         compile.options.compilerArgs += ["-XDignore.symbol.file", "-encoding", "UTF-8"]
3382 
3383         // If I am a module....
3384         if (project.hasProperty('moduleSourcePath') &&
3385                 (project.hasProperty('buildModule') && project.buildModule)) {
3386             project.compileJava {
3387                 options.compilerArgs.addAll([
3388                     '-implicit:none',
3389                     '--module-source-path', project.moduleSourcePath
3390                     ])
3391             }
3392             // no jars needed for modules
3393             project.jar.enabled = false
3394 
3395             // and redirect the resources into the module
3396             project.processResources.destinationDir = project.moduleDir
3397         }
3398 
3399         // Add in the -Xlint options
3400         if (IS_LINT) {
3401             LINT.split("[, ]").each { s ->
3402                 compile.options.compilerArgs += "-Xlint:$s"
3403             }
3404         }
3405     } // tasks with javaCompile
3406 
3407     if (project.hasProperty('moduleSourcePathShim') &&
3408             project.sourceSets.hasProperty('shims')) {
3409 
3410         // sync up the obvious source directories with the shims
3411         // others (like the shaders in graphics) should be added in there
3412         project.sourceSets.shims.java.srcDirs += project.sourceSets.main.java.srcDirs
3413         project.sourceSets.shims.java.srcDirs += "$buildDir/gensrc/java"
3414 
3415         project.compileShimsJava {
3416             options.compilerArgs.addAll([
3417                 '-implicit:none',
3418                 '--module-source-path', project.moduleSourcePathShim
3419                 ])
3420         }
3421 
3422         compileTestJava.dependsOn(compileShimsJava)
3423     }
3424 
3425     if (project.hasProperty('modulePathArgs')) {
3426         project.compileJava.options.compilerArgs.addAll(modulePathArgs)
3427     }

3428 
3429     if (project.hasProperty('testModulePathArgs')) {
3430         project.compileTestJava.options.compilerArgs.addAll(testModulePathArgs)







3431     }

3432 
3433     if (project.hasProperty('testPatchModuleArgs')) {
3434         project.test.jvmArgs += testPatchModuleArgs




3435     }
3436 
3437     if (project.hasProperty('addExports')) {
3438         project.compileTestJava.options.compilerArgs.addAll(addExports);
3439         project.test.jvmArgs += addExports
3440     }
3441 
3442     if (rootProject.hasProperty("EXTRA_TEST_ARGS") && project.hasProperty('test')) {
3443         EXTRA_TEST_ARGS.split(' ').each() { e ->
3444             project.test.jvmArgs += e
3445         }
3446     }
3447 
3448     if (rootProject.hasProperty("EXTRA_COMPILE_ARGS") && project.hasProperty('compileJava')) {
3449         project.compileJava.options.compilerArgs.addAll(EXTRA_COMPILE_ARGS.split(' '))
3450     }
3451 
3452     if (rootProject.hasProperty("EXTRA_COMPILE_ARGS") && project.hasProperty('compileTestJava')) {
3453         project.compileTestJava.options.compilerArgs.addAll(EXTRA_COMPILE_ARGS.split(' '))
3454     }
3455 
3456 }
3457 
3458 /******************************************************************************
3459  *                                                                            *
3460  *                             Top Level Tasks                                *
3461  *                                                                            *
3462  *  These are the tasks which are defined only for the top level project and  *
3463  *  not for any sub projects. These are generally the entry point that is     *
3464  *  used by Hudson and by the continuous build system.                        *
3465  *                                                                            *
3466  *****************************************************************************/
3467 
3468 task clean() {
3469     group = "Basic"
3470     description = "Deletes the build directory and the build directory of all sub projects"
3471     getSubprojects().each { subProject ->
3472         dependsOn(subProject.getTasksByName("clean", true));
3473     }
3474     doLast {
3475         delete(buildDir);
3476     }
3477 }
3478 
3479 task cleanAll() {
3480     group = "Basic"
3481     description = "Scrubs the repo of build artifacts"
3482     dependsOn(clean)
3483     doLast {
3484         //delete(".gradle"); This causes problems on windows.
3485         delete("buildSrc/build");
3486     }
3487 }
3488 
3489 task createMSPfile() {
3490     group = "Build"
3491     File mspFile = new File(rootProject.buildDir,MODULESOURCEPATH)
3492     outputs.file(mspFile)
3493 
3494     doLast {
3495         mspFile.delete()
3496         mspFile << "--module-source-path\n"
3497         mspFile << defaultModuleSourcePath
3498         mspFile << "\n"
3499     }
3500 }
3501 
3502 task javadoc(type: Javadoc, dependsOn: createMSPfile) {
3503     enabled = IS_BUILD_JAVADOC
3504     group = "Basic"
3505     description = "Generates the JavaDoc for all the public API"
3506     executable = JAVADOC
3507     def projectsToDocument = [
3508             project(":base"), project(":graphics"), project(":controls"), project(":media"),
3509             project(":swing"), /*project(":swt"),*/ project(":fxml"), project(":web")]
3510     source(projectsToDocument.collect({
3511         [it.sourceSets.main.java]
3512     }));
3513     setDestinationDir(new File(buildDir, 'javadoc'));
3514 













3515     exclude("com/**/*", "Compile*", "javafx/builder/**/*", "javafx/scene/accessibility/**/*");
3516     options.windowTitle("${javadocTitle}")
3517     options.header("${javadocHeader}")
3518     options.bottom("${javadocBottom}")
3519     if (BUILD_CLOSED) {
3520         options.linksOffline(JDK_DOCS, JDK_DOCS_CLOSED);
3521     } else {
3522         options.links(JDK_DOCS);
3523     }
3524     options.addBooleanOption("XDignore.symbol.file").setValue(true);
3525     options.addBooleanOption("Xdoclint:none").setValue(!IS_DOC_LINT);
3526     options.addBooleanOption("javafx").setValue(true);
3527     options.addBooleanOption("use").setValue(true);
3528 
3529     options.setOptionFiles([
3530         new File("${rootProject.buildDir}/${COMPILEARGSFILE}"),
3531         new File(rootProject.buildDir,MODULESOURCEPATH)
3532         ]);
3533 
3534     doLast {
3535         projectsToDocument.each { p ->
3536             copy {
3537                 from "$p.projectDir/src/main/docs"
3538                 into "$buildDir/javadoc"
3539             }
3540         }
3541     }
3542 
3543     dependsOn(projectsToDocument.collect { project -> project.getTasksByName("classes", true)});
3544 }
3545 








3546 task sdk() {
3547     if (DO_BUILD_SDK_FOR_TEST) {
3548         rootProject.getTasksByName("test", true).each { t ->
3549             if (t.enabled) t.dependsOn(sdk)
3550         }
3551     }
3552 }
3553 
3554 task appsjar() {
3555     dependsOn(sdk)
3556     // Note: the jar dependencies get added elsewhere see project(":apps")
3557 }
3558 
3559 // these are empty tasks, allowing us to depend on the task, which may have other
3560 // real work items added later.
3561 task copyAppsArtifacts() {
3562     dependsOn(appsjar)
3563 }
3564 
3565 task apps() {


3643 task all() {
3644     dependsOn(sdk,publicExports,apps,perf,zips)
3645 }
3646 
3647 
3648 // Construct list of subprojects that are modules
3649 ext.moduleProjList = []
3650 subprojects {
3651     if (project.hasProperty("buildModule") && project.ext.buildModule) {
3652         rootProject.ext.moduleProjList += project
3653         println "module: $project (buildModule=YES)"
3654     } else {
3655         println "module: $project (buildModule=NO)"
3656     }
3657 }
3658 
3659 
3660 // Create the legacy sdk from the modular-sdk
3661 
3662 compileTargets { t ->
3663     //def targetProperties = project.ext[t.upper]
3664     //def platformPrefix = targetProperties.platformPrefix
3665     //def sdkDirName = "${platformPrefix}sdk"
3666     //def modularSdkDirName = "${platformPrefix}modular-sdk"
3667     //def modularSdkDir = "${rootProject.buildDir}/${modularSdkDirName}"
3668     //def modulesDir = "${modularSdkDir}/modules"
3669     //def modulesCmdsDir = "${modularSdkDir}/modules_cmds"
3670     //def modulesLibsDir = "${modularSdkDir}/modules_libs"



































3671 
3672     // FIXME: This is not the right place to do this, but it is
3673     // basically what we need to do to build this
3674     def javafxSwtTask = task("javafxSwt$t.capital", type: Jar) {
3675         enabled = COMPILE_SWT
3676         group = "Basic"
3677         description = "Creates the javafx-swt.jar for the $t.name target"
3678         archiveName = "${project(":swt").buildDir}/libs/javafx-swt.jar";
3679         includeEmptyDirs = false
3680         from("${project(":swt").buildDir}/classes/main");
3681         include("**/javafx/embed/swt/**")
3682 
3683         dependsOn(subprojects.collect { project -> project.getTasksByName("assemble", true)});
3684     }
3685 
3686     def javafxSwtIndexTask = task("javafxSwtIndex$t.capital") {
3687         //the following is a workaround for the lack of indexing in gradle 1.4 through 1.7
3688         dependsOn(javafxSwtTask)
3689 
3690         doLast() {
3691             ant.jar (update: true, index: true, destfile: javafxSwtTask.archiveName)
3692         }
3693     }

3694 













3695     def sdkTask = task("sdk$t.capital") {
3696         group = "Basic"





















































3697         dependsOn(javafxSwtIndexTask)
3698         dependsOn(javadoc)













3699     }
3700 
3701     sdk.dependsOn(sdkTask)
3702 }
3703 




















3704 project(":apps") {
3705     // The apps build is Ant based, and gradle lets us "import" ant build.xml
3706     // into our configuration.
3707 


3708     compileTargets { t ->
3709         List<String> params = []
3710 
3711         params << "-DtargetBld=$t.name"
3712 
3713         if (!rootProject.ext[t.upper].compileSwing) {
3714             params << "-DJFX_CORE_ONLY=true"
3715         }
3716         params << "-Dplatforms.JDK_1.9.home=${rootProject.ext.JDK_HOME}"
3717         params << "-Dcompile.patch=@${rootProject.buildDir}/${COMPILEARGSFILE}"
3718         params << "-Drun.patch=@${rootProject.buildDir}/${RUNARGSFILE}"
3719 
3720         def appsJar = project.task("appsJar${t.capital}") {
3721             dependsOn(sdk)
3722             doLast() {
3723                 ant(t.name,
3724                       projectDir.path,
3725                       "appsJar",
3726                       params);







3727             }
3728         }
3729         rootProject.appsjar.dependsOn(appsJar)
3730 
3731         def appsClean = project.task("clean${t.capital}") {
3732             doLast() {
3733                 ant(t.name,
3734                       project.projectDir.path,
3735                       "clean",
3736                       params);



3737             }
3738         }
3739         rootProject.clean.dependsOn(appsClean)
3740     }
3741 }
3742 
3743 
3744 /******************************************************************************
3745  *                                                                            *
3746  *                               Modules                                      *
3747  *                                                                            *
3748  *****************************************************************************/
3749 
3750 ext.moduleDependencies = [file("dependencies")]
3751 
3752 task buildModules {
3753 }
3754 
3755 // Combine the classes, lib, and bin for each module
3756 compileTargets { t ->
3757     def targetProperties = project.ext[t.upper]
3758 
3759     def platformPrefix = targetProperties.platformPrefix
3760     def modularSdkDirName = "${platformPrefix}modular-sdk"
3761     def modularSdkDir = "${rootProject.buildDir}/${modularSdkDirName}"
3762     def modulesDir = "${modularSdkDir}/modules"
3763     def modulesCmdsDir = "${modularSdkDir}/modules_cmds"
3764     def modulesLibsDir = "${modularSdkDir}/modules_libs"
3765     def modulesSrcDir = "${modularSdkDir}/modules_src"
3766     def modulesConfDir = "${modularSdkDir}/modules_conf"
3767     def modulesMakeDir = "${modularSdkDir}/make"
3768     final File runArgsFile = file("${rootProject.buildDir}/${RUNARGSFILE}")
3769     final File compileArgsFile = file("${rootProject.buildDir}/${COMPILEARGSFILE}")
3770 
3771     project.files(runArgsFile);
3772 
3773     def zipTask = project.task("buildModuleZip$t.capital", type: Zip, group: "Build") {
3774         enabled = IS_BUILD_MODULE_ZIP
3775 
3776         // FIXME: JIGSAW -- this should be moved to a sub-directory so we can keep the same name
3777         def jfxBundle = "${platformPrefix}javafx-exports.zip"
3778 
3779         doFirst() {
3780             file("${rootProject.buildDir}/${jfxBundle}").delete()
3781         }
3782 
3783         archiveName = jfxBundle
3784         destinationDir = file("${rootProject.buildDir}")
3785         includeEmptyDirs = false
3786         from "${modularSdkDir}"
3787     }
3788     buildModules.dependsOn(zipTask)
3789 
3790     def buildModulesTask = task("buildModules$t.capital", group: "Build") {
3791         doLast {
3792             moduleProjList.each { project ->
3793 
3794                 // Copy classes, bin, and lib directories
3795 
3796                 def moduleName = project.ext.moduleName
3797                 def buildDir = project.buildDir
3798 
3799                 def srcClassesDir = "${buildDir}/${platformPrefix}module-classes"
3800                 def dstClassesDir = "${modulesDir}/${moduleName}"
3801                 copy {
3802                     from srcClassesDir
3803                     into dstClassesDir
3804                     exclude("module-info.class")
3805                 }
3806 
3807                 def srcCmdsDir = "${buildDir}/${platformPrefix}module-bin"
3808                 def dstCmdsDir = "${modulesCmdsDir}/${moduleName}"
3809                 copy {
3810                     from srcCmdsDir
3811                     into dstCmdsDir
3812                 }
3813 
3814                 def srcLibsDir = "${buildDir}/${platformPrefix}module-lib"
3815                 def dstLibsDir = "${modulesLibsDir}/${moduleName}"
3816                 copy {
3817                     from srcLibsDir
3818                     into dstLibsDir
3819                 }
3820 
3821                 // Copy module-info.java
3822                 def srcModuleInfoFile = "${project.projectDir}/src/main/java/module-info.java"
3823                 def dstModuleInfoDir = "${modulesSrcDir}/${moduleName}"
3824                 copy {
3825                     from srcModuleInfoFile
3826                     into dstModuleInfoDir
3827                     if (!IS_COMPILE_JFR && project.name.equals("base")) {
3828                         filter { line-> line.contains("requires jdk.jfr;") ? "" : line }
3829                     }
3830                 }
3831 
3832                 // Copy make/build.properties
3833                 def srcMakeDir = "${project.projectDir}/make"
3834                 def dstMakeDir = "${modulesMakeDir}/${moduleName}"
3835                 copy {
3836                     from srcMakeDir
3837                     into dstMakeDir
3838                 }
3839             }
3840 
3841             // Copy dependencies/*/module-info.java.extra
3842             // merging as needed, removing duplicates
3843             // only lines with 'exports' will be copied
3844             def dependencyRoots = moduleDependencies
3845             if (rootProject.hasProperty("closedModuleDepedencies")) {
3846                 dependencyRoots = [dependencyRoots, closedModuleDepedencies].flatten()
3847             }
3848 
3849             Map extras = [:]
3850 
3851             dependencyRoots.each { root ->
3852                 FileTree ft = fileTree(root).include('**/*.extra')
3853                 ft.each() { e->
3854                     String usename = e.path
3855                     String filePath = e.getAbsolutePath()
3856                     String folderPath = root.getAbsolutePath()
3857                     if (filePath.startsWith(folderPath)) {
3858                         usename = filePath.substring(folderPath.length() + 1);
3859                     }
3860                     if (extras.containsKey(usename)) {
3861                         List<String> lines = extras.get(usename)
3862                         e.eachLine { line ->
3863                             line = line.trim()
3864                             if (line.contains("exports")) {
3865                                 lines << line
3866                             }
3867                         }
3868 
3869                     } else {
3870                         List<String> lines = []
3871                         e.eachLine { line ->
3872                             if (line.contains("exports")) {
3873                                 lines << line.trim()
3874                             }
3875                         }
3876                         extras.put(usename,lines)
3877                     }
3878                 }
3879             }
3880             extras.keySet().each() { e->
3881                 File f = new File(modulesSrcDir, e)
3882                 f.getParentFile().mkdirs()
3883                 f.delete()
3884 
3885                 extras.get(e).unique().each() { l->
3886                     f << l
3887                     f << "\n"
3888                 }

3889             }
3890 
3891             // concatecate java.policy files into a single file
3892             //
3893             def outputPolicyDir = "${modulesConfDir}/java.base/security"
3894             def outputPolicyFile = file("${outputPolicyDir}/java.policy.extra")
3895             mkdir outputPolicyDir
3896             outputPolicyFile.delete()
3897             moduleProjList.each { project ->
3898                 def policyDir = "${project.projectDir}/src/main/conf/security"
3899                 def policyFile = file("${policyDir}/java.policy")
3900                 if (policyFile.exists()) outputPolicyFile << policyFile.text
3901             }
3902         }
3903     }
3904     zipTask.dependsOn(buildModulesTask);
3905     buildModules.dependsOn(buildModulesTask)
3906 
3907     def buildRunArgsTask = task("buildRunArgs$t.capital",
3908             group: "Build", dependsOn: buildModulesTask) {
3909         outputs.file(runArgsFile);
3910         doLast() {
3911             List<String>libpath = []
3912             List<String>modpath = []


3913 

3914             moduleProjList.each { project ->
3915                 def moduleName = project.ext.moduleName
3916                 def dstModuleDir = cygpath("${modulesDir}/${moduleName}")
3917                 modpath <<  "${moduleName}=${dstModuleDir}"
3918             }
3919 
3920             writeRunArgsFile(runArgsFile, computeLibraryPath(true), modpath)
3921         }
3922     }
3923     buildModules.dependsOn(buildRunArgsTask)
3924 
3925     def buildCompileArgsTask = task("buildCompileArgs$t.capital",
3926             group: "Build", dependsOn: buildModulesTask) {
3927         outputs.file(compileArgsFile);
3928         doLast() {
3929             List<String> modlist = []
3930             moduleProjList.each { project ->
3931                 def moduleName = project.ext.moduleName
3932                 def dstModuleDir = "${modulesDir}/${moduleName}"
3933                 modlist << dstModuleDir
3934             }
3935             writeCompileArgsFile(compileArgsFile, modlist);
3936         }
3937     }
3938     buildModules.dependsOn(buildCompileArgsTask)
3939 
3940     def isWindows = IS_WINDOWS && t.name == "win";
3941     def isMac = IS_MAC && t.name == "mac";
3942 
3943     // Create layout for modular classes
3944     moduleProjList.each { project ->
3945         def buildModuleClassesTask = project.task("buildModule$t.capital", group: "Build") {
3946             dependsOn(project.assemble)
3947             def buildDir = project.buildDir
3948             def sourceBuildDirs = [
3949                 "${buildDir}/classes/main/${project.moduleName}",

3950             ]
3951             doLast {
3952                 def moduleClassesDir = "$buildDir/${platformPrefix}module-classes"
3953                 copy {
3954                     includeEmptyDirs = false
3955                     sourceBuildDirs.each { d ->
3956                         from d
3957                     }
3958                     into moduleClassesDir
3959 
3960                     // Exclude obsolete, experimental, or non-shipping code
3961                     exclude("version.rc")
3962                     exclude("com/sun/glass/ui/swt")
3963                     exclude("com/sun/javafx/tools/ant")
3964                     exclude("com/javafx/main")
3965                     if (!IS_INCLUDE_NULL3D) {
3966                         exclude ("com/sun/prism/null3d")
3967                     }
3968                     if (!IS_INCLUDE_ES2) {
3969                            exclude("com/sun/prism/es2",


4142             // javafx.media native libraries
4143 
4144             copy {
4145                 into "${mediaProject.buildDir}/${moduleNativeDirName}"
4146 
4147                 def mediaBuildType = project(":media").ext.buildType
4148                 if (IS_COMPILE_MEDIA) {
4149                     [ "fxplugins", "gstreamer-lite", "jfxmedia" ].each { name ->
4150                         from ("${mediaProject.buildDir}/native/${t.name}/${mediaBuildType}/${library(name)}") }
4151 
4152                     if (t.name == "mac") {
4153                         // OSX media natives
4154                         [ "jfxmedia_qtkit", "jfxmedia_avf", "glib-lite" ].each { name ->
4155                             from ("${mediaProject.buildDir}/native/${t.name}/${mediaBuildType}/${library(name)}") }
4156                     } else if (t.name == "linux") {
4157                         from("${mediaProject.buildDir}/native/${t.name}/${mediaBuildType}") { include "libavplugin*.so" }
4158                     } else from ("${mediaProject.buildDir}/native/${t.name}/${mediaBuildType}/${library("glib-lite")}")
4159                 } else {
4160                     if (t.name != "android"  && t.name != "dalvik" ) {
4161                         [ "fxplugins", "gstreamer-lite", "jfxmedia" ].each { name ->
4162                             from ("$MEDIA_STUB/${library(name)}") }
4163                     }
4164 
4165                     if (t.name == "mac") {
4166                         // copy libjfxmedia_{avf,qtkit}.dylib if they exist
4167                         [ "jfxmedia_qtkit", "jfxmedia_avf", "glib-lite" ].each { name ->
4168                             from ("$MEDIA_STUB/${library(name)}") }
4169                     } else if (t.name == "linux") {
4170                         from(MEDIA_STUB) { include "libavplugin*.so" }
4171                     }
4172                     else if (t.name != "android"  && t.name != "dalvik" ) {
4173                         from ("$MEDIA_STUB/${library("glib-lite")}")
4174                     }
4175                 }
4176             }
4177 
4178 
4179             // javafx.web native libraries
4180 
4181             copy {
4182                 into "${webProject.buildDir}/${moduleNativeDirName}"
4183 
4184                 if (IS_COMPILE_WEBKIT) {
4185                     from ("${webProject.buildDir}/libs/${t.name}/${library('jfxwebkit')}")
4186                 } else {
4187                     if (t.name != "android" && t.name != "ios" && t.name != "dalvik") {
4188                         from ("$WEB_STUB/${library('jfxwebkit')}")
4189                     }
4190                 }
4191             }
4192 
4193             // FIXME: the following is a hack to workaround the fact that there
4194             // is no way to deliver javafx-swt.jar other than in one of the
4195             // existing runtime modules.
4196             if (COMPILE_SWT) {
4197                 // Copy javafx-swt.jar to the javafx-graphics module lib dir
4198                 copy {
4199                     from "${swtProject.buildDir}/libs/javafx-swt.jar"
4200                     into "${graphicsProject.buildDir}/${platformPrefix}module-lib"
4201                 }
4202             }
4203 
4204             // javafx.packager libraries and executable
4205 
4206             // Copy over the javapackager libs
4207             copy {
4208                 from "${packagerProject.buildDir}/libs"
4209                 into "${packagerProject.buildDir}/${platformPrefix}module-lib"
4210             }
4211 
4212             // Copy over the javapackager executable
4213             if (t.name == "win" || t.name == "linux" || t.name == "mac") {
4214                 copy {
4215                     from "${packagerProject.buildDir}/javapackager"
4216                     into "${packagerProject.buildDir}/${platformPrefix}module-bin"
4217                 }
4218             }
4219 
4220         }
4221     }
4222     buildModulesTask.dependsOn(buildModuleLibsTask)
4223 
4224     Task testArgFiles = task("createTestArgfiles${t.capital}") {



















4225 
4226         File testRunArgsFile = new File(rootProject.buildDir, TESTRUNARGSFILE)
4227         //test (shimed) version
4228         File testCompileArgsFile = new File(rootProject.buildDir, TESTCOMPILEARGSFILE)
4229         // And a test java.policy file
4230         File testJavaPolicyFile = new File(rootProject.buildDir, TESTJAVAPOLICYFILE)
4231 
4232         outputs.file(testRunArgsFile)
4233         outputs.file(testCompileArgsFile)
4234         outputs.file(testJavaPolicyFile)
4235 
4236         doLast() {
4237             rootProject.buildDir.mkdir()

4238 
4239             List<String> projNames = []
4240             moduleProjList.each { project ->
4241                 projNames << project.name




4242             }
4243 
4244             // And the test (shimed) variation...
4245 
4246             testRunArgsFile.delete()



4247 
4248             logger.info("Creating argfile ${testRunArgsFile.path}")
4249 
4250             computePatchModuleArgs(projNames, true).each() { a->
4251                 testRunArgsFile << a
4252                 testRunArgsFile << "\n"










4253             }
4254 
4255             testJavaPolicyFile.delete()

4256 
4257             List<String> modpath = []
4258 
4259             moduleProjList.each { project ->
4260                 if (project.hasProperty("moduleName") && project.buildModule) {
4261                     File dir;
4262                     if (project.sourceSets.hasProperty('shims')) {
4263                        dir = new File(project.sourceSets.shims.output.classesDir, project.ext.moduleName);



















4264                     } else {
4265                        dir = new File(project.sourceSets.main.output.classesDir, project.ext.moduleName);
4266                     }


















4267 
4268                     modpath << dir.path



4269 
4270                     String themod = dir.toURI()
4271                     testJavaPolicyFile <<  "grant codeBase \"${themod}\" {\n" +


4272                     "    permission java.security.AllPermission;\n" +
4273                     "};\n"



















































4274                 }







4275             }












4276 
4277             writeCompileArgsFile(testCompileArgsFile, modpath)



4278         }

4279     }
4280     sdk.dependsOn(testArgFiles)
4281     createTestArgfiles.dependsOn(testArgFiles)
4282 
4283     def sdkTask = tasks.getByName("sdk${t.capital}");
4284     sdkTask.dependsOn(buildModulesTask)
4285 }
4286 sdk.dependsOn(buildModules)
4287 
4288 task checkrepo() {
4289     doLast {
4290         logger.info("checking for whitespace (open)");
4291         exec {
4292             if (IS_WINDOWS) {
4293                 commandLine  'bash', 'tools/scripts/checkWhiteSpace'
4294             } else {
4295                 commandLine  'bash', 'tools/scripts/checkWhiteSpace', '-x'
4296             }
4297         }
4298     }
4299 }
4300 
4301 task checkrepoall() {
4302     doLast {
4303         logger.info("checking for all whitespace (open)");
4304         exec {
4305             if (IS_WINDOWS) {
4306                 commandLine  'bash', 'tools/scripts/checkWhiteSpace', '-a'


4325 if (BUILD_CLOSED) {
4326     apply from: supplementalBuildFile
4327 }
4328 
4329 task showFlags {
4330 }
4331 
4332 compileTargets { t ->
4333     // Every platform must define these variables
4334     def props = project.ext[t.upper];
4335     showFlags.dependsOn(
4336         project.task("showFlags$t.upper") {
4337             doLast() {
4338                 println "Properties set for $t.upper"
4339                 props.each { println it }
4340             }
4341         }
4342     )
4343 
4344 }

< prev index next >