openjfx / javafx-gradle-plugin

Gradle plugin that makes it easy to work with JavaFX 11+
https://openjfx.io/
BSD 3-Clause "New" or "Revised" License
359 stars 62 forks source link

Plugin not working, starting with Gradle 7.5 #140

Open FlorianKirmaier opened 1 year ago

FlorianKirmaier commented 1 year ago

According to my test (in 1 project), the dependencies are no longer added with version 7.5 or 7.6. It does work with 7.4.

There is no error, just the dependencies are not added.

Edit: Yesterday I was able to reproduce/not reproduce it, by switching the versions. For some reason that doesn't work today. So I don't know exactly whats happening, maybe some sort of caching? Guess I will watch out for it. As far as I've checked, they did quite some changes to the dependency resolution in 7.5.

raoulsson commented 1 year ago

I really need this so I patched together a temporary fix here: https://github.com/raoulsson/javafx-gradle-plugin. If it works, make sure to switch back to the original, once the next working release is out.

NotStirred commented 1 year ago

As far as I can tell there are no relevant code changes here @raoulsson could you point me to it?

It seems like gradle's changes to dependency resolution in 7.5 have broken something with adding dependencies to a project within a plugin. Latest (currently 8.0.2) also has the same issue.

Either the API has changed without any warning or there's a bug somewhere

NotStirred commented 1 year ago

After a lot of reading - the fix is to put modules at the bottom of the extension block: Before:

javafx {
    version = '11.0.2'
    modules = ['javafx.base', 'javafx.controls', 'javafx.fxml']
    configuration = 'implementation'
}

After:

javafx {
    version = '11.0.2'
    configuration = 'implementation'
    modules = ['javafx.base', 'javafx.controls', 'javafx.fxml']
}

This is because any change to the extension calls updateJavaFXDependencies, which immediately calls clearJavaFXDependencies removing the previously added modules.