brunoborges / javafx-jlink-starter-gradle

A JavaFX starter project with Gradle and jlink support
Apache License 2.0
76 stars 14 forks source link

Creating jLink bundle fails with cannot retrieve module name from module-info.java #2

Closed BlueGoliath closed 5 years ago

BlueGoliath commented 5 years ago

Attempting to run the "jLink" task fails with ``` Execution failed for task ':prepareModulesDir'. Cannot retrieve module name from module-info.java


Besides having to manually delete /build/jlinkbase/tmpmerged every build, the project "runs" from netbeans just fine(via green button). 

The project currently utilizes other local Java 9 modules which are placed in a root/lib folder as seen in the gradle build file:

plugins {
    id 'java'
    id 'application'
    id 'org.openjfx.javafxplugin'      version '0.0.7'
    id 'org.beryx.jlink'               version '2.6.4'
    id 'com.github.ben-manes.versions' version '0.20.0'
}

// Application Configuration
ext {
    appName = "Goliath Envious FX"
    appLauncher = "goliathenviousfx"
    appPackaging = "goliathenviousfx"
    appModuleName = "goliathenviousfx"
    appMainClass = "goliathenviousfx.GoliathENVIOUSFX"
}

mainClassName = "${ext.appModuleName}/${ext.appMainClass}"

repositories {
    mavenCentral()
}

javafx {
    modules = ['javafx.controls']
}

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

dependencies {
    compile files('lib/goliath.envious.jar')
    compile files('lib/goliath.nvsettings.jar')
    compile files('lib/goliath.nvsmi.jar')
    compile files('lib/goliath.nvxconfig.jar')
    compile files('lib/goliath.nvserver.jar')
    compile files('lib/goliath.envious.reactive.jar')
    compile files('lib/goliath.io.jar')
    compile files('lib/goliath.css.jar')
 }

task dist {
    dependsOn clean, jlinkZip
    description "Calls clean and then jlinkZip [default]"
}

defaultTasks 'dist'

I have no experience with Gradle and had just been using Ant via Netbeans previously so maybe it's something i'm doing wrong here.
brunoborges commented 5 years ago

Paste here your version of src/main/java/module-info.java

brunoborges commented 5 years ago

You should've made changes to that as well.

BlueGoliath commented 5 years ago

Here it is:

`module goliathenviousfx { requires javafx.base; requires javafx.controls; requires goliath.envious; requires goliath.nvsettings; requires goliath.nvsmi; requires goliath.nvxconfig; requires goliath.css;

exports goliathenviousfx;

}`

siordache commented 5 years ago

This is a badass-jlink issue, which is fixed in release 2.6.5. You need to put:

id 'org.beryx.jlink' version '2.6.5'

in your build.gradle.

brunoborges commented 5 years ago

Hopefully 17aa25b has this addressed. Thanks @siordache

BlueGoliath commented 5 years ago

Thanks. That fixed that issue, but now i'm getting:

Error: Module goliath.nvsettings not found, required by goliathenviousfx

goliath.nvsettings is a local modular jar. I can't seem to find much information about how to include local modular jars in Gradle. Is it even possible to do?

brunoborges commented 5 years ago

Hoping @aalmiray can help.

aalmiray commented 5 years ago

I've tested with the following setup:

  1. clone this repository.
  2. add ikonli-javafx and an icon pack as dependencies.
  3. modify module-info.java to require ikonli modules.
  4. invoke the dist target.
  5. run the generated image.

It works as expected. This makes me think that either the goliath modular JARs are not setup correctly (they may not be true modular JARs) or the dependencies are set wrongly. Try using a flatDir repository, like this

repositories {
    mavenCentral()
    flatDir { dir 'lib' }
}

dependencies {
    compile ':goliath.envious:'
    compile ':goliath.nvsettings:'
    compile ':goliath.nvsmi:'
    compile ':goliath.nvxconfig:'
    compile ':goliath.nvserver:'
    compile ':goliath.envious.reactive:'
    compile ':goliath.io:'
    compile ':goliath.css:'
}
BlueGoliath commented 5 years ago

Yes, that works perfectly! Thanks all!