shemnon avatar shemnon committed bbe9d6e

Play hide and go seek with the jfxrt.jar, in prepreation for JDK8 changes

Comments (0)

Files changed (2)

gradle-javafx-plugin/build.gradle

     compile 'org.jclarion:image4j:0.7'
     compile gradleApi()
     compile files("${System.properties['java.home']}/../lib/ant-javafx.jar")
-    compile files("${System.properties['java.home']}/lib/jfxrt.jar")
+    compile fileTree(dir: "${System.properties['java.home']}", include: '**/jfxrt.jar')
 }
 
 uploadArchives {
             }
             dependency {
                 groupId 'net.java.openjdk'
+                artifactId 'jfxrt'
+                version '8b75'
+                scope 'system'
+                systemPath '${java.home}/lib/ext/jfxrt.jar'
+            }
+            dependency {
+                groupId 'net.java.openjdk'
                 artifactId 'ant-javafx'
                 version '8b72'
                 scope 'system'

gradle-javafx-plugin/src/main/groovy/org/bitbucket/shemnon/javafxplugin/JavaFXPlugin.groovy

  */
 package org.bitbucket.shemnon.javafxplugin
 
+import org.gradle.api.GradleException
 import org.gradle.api.Project
 import org.gradle.api.Plugin
 import org.bitbucket.shemnon.javafxplugin.tasks.JavaFXDeployTask
     public static final String PROVIDED_COMPILE_CONFIGURATION_NAME = "providedCompile";
     public static final String PROVIDED_RUNTIME_CONFIGURATION_NAME = "providedRuntime";
 
+    private Project project
+
     @Override
     void apply(Project project) {
+        this.project = project
+
         project.getPlugins().apply(JavaPlugin)
         project.extensions.create('javafx', JavaFXPluginExtension)
 
     }
 
     public File findJFXJar() {
-        def javafxHome = System.env['JFXRT_HOME']
-        File jfxrtHome
-        if (javafxHome) {
-            jfxrtHome = "${javafxHome}" as File
-        } else {
-            final javaHome = System.env['JAVA_HOME']
-            if (javaHome)
-                jfxrtHome = "${javaHome}/jre/lib"  as File
-            else
-                jfxrtHome = "${System.properties['java.home']}/lib" as File
+        File jfxrtJar
+        def jfxrtHome = System.env['JFXRT_HOME']
+        if (jfxrtHome) {
+            try {
+                jfxrtJar = project.fileTree(dir: jfxrtHome, include: "**/jfxrt.jar").singleFile
+            } catch (IllegalStateException ignore) {
+                // no file or two files
+            }
         }
 
-        File jfxrtJar = new File((File) jfxrtHome, "jfxrt.jar")
-        if (!jfxrtJar.exists()) {
-            println ("""    Please set the environment variable JFXRT_HOME
-    to the directory that contains jfxrt.jar, or set JAVA_HOME.""")
 
+        if (!jfxrtJar?.file) {
+            String javaHome = System.env['JAVA_HOME']
+            if (!javaHome) {
+                javaHome = System.properties['java.home']
+            }
+            try {
+                jfxrtJar = project.fileTree(dir: javaHome, include: "**/jfxrt.jar").singleFile
+            } catch (IllegalStateException ignore) {
+                // no file or two files
+            }
+        }
+
+        if (!jfxrtJar?.file) {
+            println("""    Please set the environment variable JFXRT_HOME
+    to the directory that contains jfxrt.jar, or set JAVA_HOME.""")
+            throw new GradleException("jfxrt.jar file not found");
         }
         println "JavaFX runtime jar: ${jfxrtJar}"
         return jfxrtJar
     }
 
     public File findAntJavaFXJar() {
-        def javafxHome = System.env['JFXRT_HOME']
-        File jfxrtHome
-        if (javafxHome) {
-            jfxrtHome = "${javafxHome}" as File
-        } else {
-            final javaHome = System.env['JAVA_HOME']
-            if (javaHome)
-                jfxrtHome = "${javaHome}/lib"  as File
-            else
-                jfxrtHome = "${System.properties['java.home']}/../lib" as File
+        File antjfxjar
+        def jfxrtHome = System.env['JFXRT_HOME']
+        if (jfxrtHome) {
+            try {
+                if (jfxrtHome.endsWith('jre')) {
+                    jfxrtHome += "/..";
+                }
+                antjfxjar = project.fileTree(dir: "$jfxrtHome", include: "lib/ant-javafx.jar").singleFile
+            } catch (IllegalStateException ignore) {
+                // no file or two files
+            }
         }
 
-        File antjfxjar = new File((File)jfxrtHome, "ant-javafx.jar")
-        if (!antjfxjar.exists()) {
+        if (!antjfxjar?.file) {
+            String javaHome = System.env['JAVA_HOME']
+            if (!javaHome) {
+                javaHome = System.properties['java.home']
+            }
+            if (javaHome.endsWith('jre')) {
+                javaHome += "/..";
+            }
+            try {
+                antjfxjar = project.fileTree(dir: "$javaHome", include: "lib/ant-javafx.jar").singleFile
+            } catch (IllegalStateException ignore) {
+                // no file or two files
+            }
+        }
+
+        if (!antjfxjar?.file) {
             println("""    Please set the environment variable JFXRT_HOME
     to the directory that contains jfxrt.jar, or set JAVA_HOME.""")
-
+            throw new GradleException("ant-javafx.jar file not found");
         }
         println "JavaFX ant jar: ${antjfxjar}"
         return antjfxjar
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.