fvarrui / JavaPackager

:package: Gradle/Maven plugin to package Java applications as native Windows, MacOS, or Linux executables and create installers for them.
GNU General Public License v3.0
1.07k stars 133 forks source link

JavaPackager fails when I update javafx-gradle-plugin from 0.0.10 to 0.0.13 #291

Closed Borewit closed 1 year ago

Borewit commented 1 year ago

I'm not sure what I am submitting, maybe just a question...

Short description of the issue/suggestion:

When I javafx-gradle-plugin 0.0.10 to 0.0.13 I can not longer pack the Windows installer.

I get the following exception:

Caused by: java.lang.UnsupportedOperationException
    at io.github.fvarrui.javapackager.packagers.BundleJre.getRequiredModules(BundleJre.java:258)
    at io.github.fvarrui.javapackager.packagers.BundleJre.doApply(BundleJre.java:114)
    at io.github.fvarrui.javapackager.packagers.ArtifactGenerator.apply(ArtifactGenerator.java:44)
    at io.github.fvarrui.javapackager.packagers.Packager.createApp(Packager.java:411)
    at io.github.fvarrui.javapackager.gradle.AbstractPackageTask.doPackage(AbstractPackageTask.java:45)

Which is thrown here: https://github.com/fvarrui/JavaPackager/blob/a462e537004a2f685c3df67bc7e0c59fc8e41c94/src/main/java/io/github/fvarrui/javapackager/packagers/BundleJre.java#L258

Do you have outputs, screenshots, demos or samples which demonstrate the problem or enhancement? Please see the PR isolating the issue

To Reproduce

gradlew :packageMyApp

Please tell us about your environment:

fvarrui commented 1 year ago

I've tried to package your app using the next environment:

------------------------------------------------------------
Gradle 7.3.3
------------------------------------------------------------

Build time:   2021-12-22 12:37:54 UTC
Revision:     6f556c80f945dc54b50e0be633da6c62dbe8dc71

Kotlin:       1.5.31
Groovy:       3.0.9
Ant:          Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM:          17.0.5 (Eclipse Adoptium 17.0.5+8)
OS:           Windows 11 10.0 amd64

and managed to reproduce your error.

Then, tried to downgrade javafx-gradle-plugin to 0.0.10 and 0.0.8

    // https://github.com/openjfx/javafx-gradle-plugin
    id 'org.openjfx.javafxplugin' version '0.0.10'

but the error persists 😞

Caused by: java.lang.UnsupportedOperationException
        at io.github.fvarrui.javapackager.packagers.BundleJre.getRequiredModules(BundleJre.java:258)
        at io.github.fvarrui.javapackager.packagers.BundleJre.doApply(BundleJre.java:114)
        at io.github.fvarrui.javapackager.packagers.ArtifactGenerator.apply(ArtifactGenerator.java:44)
        at io.github.fvarrui.javapackager.packagers.Packager.createApp(Packager.java:411)
        at io.github.fvarrui.javapackager.gradle.AbstractPackageTask.doPackage(AbstractPackageTask.java:45)
fvarrui commented 1 year ago

Later, after doing some research, I realized that the problem is because of the additional modules:

additionalModules = ['jdk.incubator.foreign', 'jdk.incubator.jpackage']

but ... why? Because I made the mistake of trying to add those additional modules to a fixed-size list returned by Arrays.asList(...):

modulesList = Arrays.asList(...);
[...]
modulesList.addAll(additionalModules);

If you try to remove those additional modules you will see that it's packaged successfully.

Another example: as you can see

public static void main(String[] args) {
    List<Integer> number = Arrays.asList(1, 2, 3);
    number.add(4);              
}

this code throws an UnsupportedOperationException:

Exception in thread "main" java.lang.UnsupportedOperationException
    at java.base/java.util.AbstractList.add(AbstractList.java:153)
    at java.base/java.util.AbstractList.add(AbstractList.java:111)
    at dad.game.demo.Main.main(Main.java:14)

Sorry for the inconveniences 😢 ... I'm going to fix it right now, and then you can package your app using 1.7.0-SNAPSHOT.

fvarrui commented 1 year ago

I've just fixed this issue.

You have to build and install 1.7.0-SNAPSHOT to your local Maven repo:

git clone https://github.com/fvarrui/JavaPackager --branch devel
cd JavaPackager
gradlew publishToMavenLocal

Then update your build.gradle:

And finally gradlew :packageMyApp

Please, try it and give some feedback please.

fvarrui commented 1 year ago

JavaPackager 1.7.0 released to Maven Central

Borewit commented 1 year ago

Looks like io.github.fvarrui:javapackager 1.7.0 is working just fine, muchas gracias señor!

fvarrui commented 1 year ago

Great news!! De nada 😅

Borewit commented 1 year ago

Don't forget to push your v1.7.0 tag!