Open madmas opened 5 years ago
I am also seeing this problem on Linux. Dependencies for both Linux and Mac are fetched with Gradle.
javafx-controls.11.0.2.jar javafx-controls-linux.11.0.2.jar javafx-controls-mac.11.0.2.jar
I have been running on JavaFX 11 for a while now, and this has not had any adverse affect.
While it shouldn't have adverse effects, it shouldn't happen in the first place. The main reason to find artifacts from wrong platforms is having dependencies of third party libraries that have transitive dependencies on JavaFX and published their artifacts without removing the platform classifier.
It is easy to avoid using implementation (....) { exclude group:org.openjfx }
.
But it should be better if the library removed the classifiers from the pom. See for instance the publishing task of this library.
I just found out that the library eu.hansolo:Medusa:11.1
is the cause in my case for fetching the Mac dependencies for JavaFX. I happened with a test project of mine without the gradle javafxplugin.
I just run into the same issue (on Windows also Mac and Linux versions are present). In fact, this leads to problems if you want to compile using Intellj as the binaries from the wrong OS are loaded into the module path, leading to problems that certain OS-specific implementation (e.g. platform loader) are not present.
Is there a work-around (except to manually remove the corresponding dependencies)?
I think this might actually be not a problem with the plugin. In fact, adding
compile group: 'org.openjfx', name: 'javafx-base', version: '14', classifier: 'mac'
manually in the gradle file, still loads the linux version as a dependency too. Could it be a problem with the pom? (I found it strange that each module declares itself as dependency)
There should be no JavaFX dependencies added manually. They should only be described in the javafx
section like:
javafx {
version = '14'
modules = [ 'javafx.controls', 'javafx.fxml' ]
}
You will will see 2 sets of dependencies:
As you see, transitive dependencies are added automatically too.
Thanks @eugener. The problem is that your code also loads the jar files from other OS for me. I guess this issue only occurs if you don't have the sdk installed since the plugin then loads these local files by default. https://github.com/openjfx/javafx-gradle-plugin/blob/c1e816ebbae56c30232a7bff043113c868c66103/src/main/java/org/openjfx/gradle/JavaFXOptions.java#L120-L127 I think there is nothing wrong with this code since manually adding these dependencies had the same effect that the os classifier was ignored
The same problem. On Linux I have platform-specific and independent jars. But on Windows linux-specific dependencies are present too.
For me this caused jlink to fail:
Error: Two versions of module javafx.base found in C:\Users\tareh\code\cleopetra\build\jlinkbase\jlinkjars (javafx-base-11.0.2-win.jar and javafx-base-11.0.2-linux.jar)
I had controlsfx as one of my dependencies and it seems that was the culprit. I changed it to this (taking a cue from jperedadnr):
dependencies {
implementation('org.controlsfx:controlsfx:11.0.3') {
exclude group: 'org.openjfx'
}
}
which got me past the problem. Thanks José!
I've also came into this problem, and I am both a library user and writer, and I've solved this from either perspective.
Since this issue is not closed yet, so I write my solution here for future reference:
Try to add this too each dependency until compilation passes (then you can find out which library is to blame):
implementation('...') {
exclude group: 'org.openjfx'
}
Add this to root at build.gradle
tasks.withType(GenerateModuleMetadata) {
enabled = false
}
This prevents the generation of module.json
or xxx.module
, which will be used by gradle to retrieve the dependencies regardless of the pom.xml
.
Add this inside publishing.publications.maven(MavenPublication)
(same level as the pom {}
block)
pom.withXml {
def pomNode = asNode()
pomNode.dependencies.'*'.findAll() {
it.groupId.text() == 'org.openjfx'
}.each {
it.parent().remove(it)
// you may also use: it.remove(it.classifier)
}
}
This removes the jfx dependencies from pom.xml
(or you may only remove the classifiers).
Hi, the documentation says: " The plugin only includes binaries for the platform running the build. "
But when importing the project into IntelliJ on Mac, Gradle provides the dependencies for both win and mac:
This leads to the error that 'javafx.base' is provided twice:
What can I do to only have the platform-specific dependencies on my classpath?