javafx-gradle-plugin
javafx-gradle-plugin copied to clipboard
Duplicate modules with JavaFX
I am not sure if this is the same as the other issues that mention duplicate modules so I will raise another issue and let the issue handlers decide.... I also have a workaround - but it is not ideal.
I have an application divided into maven poms on a maven server. Lets call this 'my-application' The application is written in Kotlin as is the gradle build script. The application uses JavaFx and the plugin, and is packaged using jpackage (org.beryx plugin). This all works fine.
I have split out a maven pom that itself depends upon JavFX and uses the javafx plugin. Lets call this 'my-library'.
When I compile and publish my-library on MacOS and compile and build my-application on MacOS it all works wonderfully. When I compile and build my-application on windows I get an error 'duplicate modules found' while packaging. I have two copies of each of my javafx modules, one for windows (-win) and one for Mac (-mac).
My work-around is to build two (three actually if counting linux) libraries. my-library-mac built on Mac, my-library-win built on win etc. The application then chooses the appropriate library when building.
This works but implies extra builds and devops plumbing.
Am I doing something wrong? Is there an easier solution?
I got similar "duplicate modules found" in Windows for a simpler JavaFX application. And the cause of it was that a dependent library (FXyz) that the app uses is also dependent on JavaFX. The solution is to exclude those javafx-* modules from the FXyz library in the app's build.gradle, i.e.
implementation('org.fxyz3d:fxyz3d-importers:0.5.4') {
exclude group: 'org.openjfx', module: '*'
}
I guess in the POM for your 'my-application' which has a dependency on 'my-library', that dependency should exclude all modules from 'org.openjfx' to avoid this "duplicate modules" problem:
<dependency>
<groupId>my.group.id</groupId>
<artifactId>my-library</artifactId>
<version>${my.version}</version>
<exclusions>
<exclusion>
<groupId>org.openjfx</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
Like you the problem only happens in Windows for me. No idea why/what is so special about Windows for the javafx plugin.
Thanks chirontt - I will look into that solution next time that I am modifying the build code.