beryx / badass-jlink-plugin

Create a custom runtime image of your modular application
https://badass-jlink-plugin.beryx.org
Apache License 2.0
379 stars 25 forks source link

JpackageImage fails because of "[1.0-SNAPSHOT] contains invalid component [0-SNAPSHOT]" issue #204

Closed youssefidraiss closed 1 year ago

youssefidraiss commented 2 years ago

I try to package my app using JPackage task of Jlink-badass plugin (I'm using Gradle as a builder tool), but I keep getting the following error during the JPackageImage phase (even with a simple hello world javafx application):

` Task :jpackageImage java.lang.IllegalArgumentException: "Version [1.0-SNAPSHOT] contains invalid component [0-SNAPSHOT]"

Task :jpackageImage FAILED

Execution failed for task ':jpackageImage'. Process 'command 'C:\Users\youss\Desktop\openjdk-17_windows-x64_bin\jdk-17/bin/jpackage.exe'' finished with non-zero exit value 1

My Gradle.Build

plugins { id 'java' id 'application' id 'org.openjfx.javafxplugin' version '0.0.10' id 'org.beryx.jlink' version '2.24.4' }

group 'com.example' version '1.0-SNAPSHOT'

repositories { mavenCentral() }

ext { junitVersion = '5.7.1' }

sourceCompatibility = '17' targetCompatibility = '17'

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

application { mainModule = 'com.example.demo4' mainClass = 'com.example.demo4.Runner' }

javafx { version = '17.0.1' modules = ['javafx.controls', 'javafx.fxml'] }

dependencies {

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

}

test { useJUnitPlatform() }

jlink {

options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']
launcher {
    name = 'Karrty'
}

}

More details

-I'm using JDK 17.

What I have tried

-I tried using different JDKs like 16 but still the same error.

not sure if this is a bug or something is it something that I doing is wrong

Oliver-Loeffler commented 2 years ago

The problem is the version number as defined (version '1.0-SNAPSHOT'). Packaging will work only, if the given version number matches the target platform requirements. To get your image working, you'd have to change your version number into version '1.0'.

Unfortunately, this is the way to go, also, the issue is not JDKs specific, its bound to platform specific tools. E.g. when running on Windows, WIX toolset will complain versions such as 20220117.1 and force you to go with max. 254.254.254 or so. Unfortunately, these version number constraints are only poorly documented.

Yes, the plugin could adjust this detail on the fly, well but its kind of a mess when you have to override all this manually.

Alternatively, you could modify jlink plugin config so that the -SNAPSHOT suffix is removed from appVersion.

link {
    jpackage {
        appVersion = "1.0"
    }
}

Source: https://badass-jlink-plugin.beryx.org/releases/latest/#_jpackage