HanSolo / medusa

A JavaFX library for Gauges
Apache License 2.0
692 stars 131 forks source link

jlink and openjfx gradle plugins + medusa 11 -> module duplication error occurs #171

Closed Levvy055 closed 5 years ago

Levvy055 commented 5 years ago

When using jlink plugin in gradle with openjfx plugin and medusa 8.0.3 everything is fine, but when updated medusa to 11 there is following error:

> Task :createMergedModule
error: duplicate module on application module path
  module in javafx.base
error: duplicate module on application module path
  module in javafx.controls
error: duplicate module on application module path
  module in javafx.graphics
3 errors

> Task :createMergedModule FAILED

Do not know if that is problem with Medusa or one of beforementioned plugins. Having followed simplified gradle additional config:

plugins {
    id 'java'
    id 'eclipse'
    id 'application'
    id 'org.openjfx.javafxplugin' version '0.0.7'
    id 'org.beryx.jlink' version '2.10.4'
}
javafx {
    modules = [ 'javafx.controls',
        'javafx.fxml',
        'javafx.graphics',
        'javafx.swing',
        'javafx.web',
        'javafx.media' ]
}
jlink {
    options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']
    launcher {
        name = 'myApp'
        jvmArgs = ['-Dcom.sun.management.jmxremote', '-Dprism.verbose=true']

    }
    addExtraDependencies("javafx")
    imageName = 'myApp-SNAPSHOT'
}

When removed javafx section there is error: module not found: javafx.base and so on.

HanSolo commented 5 years ago

I have a little demo app that runs on JDK11 with Medusa and that works just fine. Because the module javafx.controls depends on javafx.graphics and javafx.base I only import javafx.controls and that does the trick. Can you test if it also works for you? Cheers, Gerrit

Levvy055 commented 5 years ago

Have you tried running task gradle jlink ?

Levvy055 commented 5 years ago

ok. Found a fix. Need to add exclude option to dependencies

implementation group: 'eu.hansolo', name: 'Medusa', version: '11.1', { 
  exclude group: 'org.openjfx'
}
HanSolo commented 5 years ago

Sorry for the late reply but I’m on travel at the moment, great you figured it out on your own 👍🏻😁

ahmedmashaikhi commented 1 year ago

Dear I did the fix and I am still having issue jlink+jpackage. The exported jar show error "Fail to launch vm". However, once I removed the eu.hansolo.medusa from the dependencies, everything going smoothly and I am able to export a runnable jar. Here my gradle script: plugins { id 'java' id 'application' id 'org.javamodularity.moduleplugin' version '1.8.12' id 'org.openjfx.javafxplugin' version '0.0.13' id 'org.beryx.jlink' version '2.25.0' }

group 'com.example'

repositories { mavenCentral() }

ext { junitVersion = '5.9.2' }

sourceCompatibility = '17' targetCompatibility = '17'

tasks.withType(JavaCompile) { options.encoding = 'UTF-8' }

application { mainModule = 'com.example.demoa' mainClass = 'com.example.demoa.HelloApplication' }

javafx { version = '20.0.1' modules = ['javafx.controls', 'javafx.fxml','javafx.swing','javafx.web'] }

dependencies {

implementation ('eu.hansolo:toolbox:17.0.43'){
    exclude(group: 'org.openjfx')
}
implementation ('eu.hansolo:toolboxfx:17.0.33'){
    exclude(group: 'org.openjfx')
}
implementation ('eu.hansolo:medusa:17.1.5'){
    exclude (group: 'org.openjfx')
}

testImplementation("org.junit.jupiter:junit-jupiter-api:${junitVersion}")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${junitVersion}")

}

test { useJUnitPlatform() }

jlink { imageZip = project.file("${buildDir}/distributions/app-${javafx.platform.classifier}.zip") options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages'] launcher { name = 'ahmedapp' }

jpackage {
    if (javafx.getPlatform().name() == "OSX") {
        installerType = "dmg"
        jpackageHome = "C:\\Users\\TechBeam\\.jdks\\azul-17.0.7"
    } else if (javafx.getPlatform().name() == "WINDOWS") {
        installerType = "msi"
        jpackageHome = "C:\\Users\\TechBeam\\.jdks\\azul-17.0.7"
        installerOptions = ['--win-menu', '--win-shortcut',
                            '--win-dir-chooser']
    } else if (javafx.getPlatform().name() == "LINUX") {
        installerType = "deb"
        jpackageHome = "C:\\Users\\TechBeam\\.jdks\\azul-17.0.7"
    }
}

}

jlinkZip { group = 'distribution' } and here my module-info : module com.example.demoa { requires javafx.controls; requires javafx.fxml; requires javafx.base; requires javafx.graphics; requires javafx.swing;

requires eu.hansolo.medusa;

opens com.example.demoa to javafx.fxml;
exports com.example.demoa;

} please any clue I am struggling with for 2 weeks without any hope.