javafx-gradle-plugin icon indicating copy to clipboard operation
javafx-gradle-plugin copied to clipboard

Support using JavaFX jars from gradle classpath or defined directory

Open AstralStorm opened this issue 6 years ago • 5 comments

Currently the plugin always attempts to find the jars on its own.

Modifying it to actually first check gradle classpath if it contains the required classes would allow including OpenJFX in the same build as a dependency.

Alternatively, some way of defining where it attempts to pull the JavaFX jars from would be required.

AstralStorm avatar Sep 20 '17 10:09 AstralStorm

What do you mean with "gradle classpath", normally dependencies are not inside some classpath? Can you add some build-script?

FibreFoX avatar Sep 20 '17 19:09 FibreFoX

ping @AstralStorm

FibreFoX avatar Jan 21 '18 21:01 FibreFoX

To build the project, you have to include JavaFX plugin in it in buildscript classpath. Unfortunately the plugin checks for existence of JavaFX in a very roundabout way and does not verify if JavaFX classes are already in Gradle classpath which will be used to build the application.

E.g. if I include it like this:

buildscript {
    repositories {
        maven {
            url "https://plugins.gradle.org/m2/"
        }
    }
    dependencies {
        classpath 'de.dynamicfiles.projects.gradle.plugins:javafx-gradle-plugin:8.8.2'
    }
}

It checks for existence of JavaFX when included from system Java directories and not from gradle build script classpath and not when the task is running, so I cannot do:

dependencies {
  classpath project(':openjfx')
}

nor

buildscript {
  dependencies {
    classpath 'my.openjfx:1.8.0'
  }
}

and are forced to patch JDK install in Android Studio which is highly inconvenient.

The bug is in: https://github.com/FibreFoX/javafx-gradle-plugin/blob/master/src/main/java/de/dynamicfiles/projects/gradle/plugins/javafx/JavaFXGradlePlugin.java#L99

Which should check if JavaFX is already in classpath(s) before attempting to add a potentially nonexistent jar file. (And potentially also if ant-javafx is in classpath.)

AstralStorm avatar Jan 22 '18 09:01 AstralStorm

As the JDK 9+ are not having the related classes anymore sitting in that JAR-file, I'm supposed to rework the whole thing, adding some additional flag for disabling this on JDK 8. First I was tempted to decline such idea, but as I'm forced to rework some parts I'm now fine with this idea ;) thanks for reporting and using this plugin.

Only one drawback: I'm not able to custom-patch the class-files anymore for JDK 8 (but it's not possible for JDK 9+ anyway 😿 )

FibreFoX avatar Feb 16 '18 11:02 FibreFoX

I'm adding some flag to disable adding ant-javafx.jar, mostly because it might get dropped in some JDK versions, will provide some SNAPSHOT-version very soon.

FibreFoX avatar Mar 21 '18 09:03 FibreFoX