Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate modules with JavaFX #116

Open
dr-phill opened this issue Dec 8, 2021 · 2 comments
Open

Duplicate modules with JavaFX #116

dr-phill opened this issue Dec 8, 2021 · 2 comments

Comments

@dr-phill
Copy link

dr-phill commented Dec 8, 2021

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?

@chirontt
Copy link

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.

@drphill
Copy link

drphill commented Feb 15, 2022

Thanks chirontt - I will look into that solution next time that I am modifying the build code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants