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

Incorrect module-path during Linux build? #195

Closed EasyG0ing1 closed 2 years ago

EasyG0ing1 commented 2 years ago

During an attempt to build for Linux, I received this error (I added the line breaks to make it easer to see):

Failed to execute goal io.github.fvarrui:javapackager:1.6.5:package (linux) on project GistFX: Command execution failed:
/home/michael/Java/jdk-18.0.1.1/bin/jlink 
    --module-path /home/michael/Java/jdk-18.0.1.1/jmods 
    [Ljava.lang.String;@634aa81e --add-modules ALL-MODULE-PATH 
    --output /home/michael/IdeaProjects/GistFX/target/GistFX/jre 
    --no-header-files 
    --no-man-pages
    --strip-debug 
    --compress=2 
-> [Help 1]

Here is the same output unedited

Failed to execute goal io.github.fvarrui:javapackager:1.6.5:package (linux) on project GistFX: Command execution failed: /home/michael/Java/jdk-18.0.1.1/bin/jlink --module-path /home/michael/Java/jdk-18.0.1.1/jmods [Ljava.lang.String;@71b26880 --add-modules ALL-MODULE-PATH --output /home/michael/IdeaProjects/GistFX/target/GistFX/jre --no-header-files --no-man-pages --strip-debug --compress=2 -> [Help 1]

Where I believe the problem exists, is here:

--module-path /home/michael/Java/jdk-18.0.1.1/jmods

I'm not sure where it's getting this path from but clearly my module path doesn't exist within the JDK folder tree...

Here is my POM config:

<plugin>
    <groupId>io.github.fvarrui</groupId>
    <artifactId>javapackager</artifactId>
    <version>1.6.5</version>
    <configuration>
        <mainClass>${exec.mainClass}</mainClass>
        <bundleJre>true</bundleJre>
        <customizedJre>false</customizedJre>
        <generateInstaller>true</generateInstaller>
        <administratorRequired>false</administratorRequired>
        <copyDependencies>true</copyDependencies>
        <createZipball>false</createZipball>
        <createTarball>true</createTarball>
        <assetsDir>/home/michael/IdeaProjects/GistFX/assets</assetsDir>
        <jdkPath>/home/michael/Java/jdk-18.0.1.1</jdkPath>
        <packagingJdk>/home/michael/Java/jdk-18.0.1.1</packagingJdk>
        <platform>auto</platform>
        <url>https://github.com/RedmondSims/GistFX</url>
        <version>${project.version}</version>
        <vmArgs>
            <vmArg>--enable-preview</vmArg>
        </vmArgs>
    </configuration>
    <executions>
        <execution>
            <id>linux</id>
            <phase>package</phase>
            <goals>
                <goal>package</goal>
            </goals>
            <configuration>
                <linuxConfig>
                    <pngFile>/home/michael/IdeaProjects/GistFX/assets/linux/GistFX.png</pngFile>
                    <generateRpm>true</generateRpm>
                    <generateDeb>true</generateDeb>
                    <wrapJar>true</wrapJar>
                </linuxConfig>
            </configuration>
        </execution>
    </executions>
</plugin>
fvarrui commented 2 years ago

Hi @EasyG0ing1! I'm sorry for my late reply. I've been out for working.

Are you running the packaging process on Linux or Mac OS?

fvarrui commented 2 years ago

This path:

/home/michael/Java/jdk-18.0.1.1/jmods

comes from: jdkPath + /jmods

EasyG0ing1 commented 2 years ago

@fvarrui - I'm running the packaging process on Ubuntu Linux ... latest version.

When I do a mvn clean package -X I get this in the output ...

[INFO]     Runnable jar created in /home/michael/IdeaProjects/GistFX/target/GistFX-3.4.60-runnable.jar!
[INFO]     
[INFO]     Bundling JRE ... with /home/michael/Java/jdk-18.0.1.1
[INFO]         Creating customized JRE ...
[INFO]         Getting required modules ... 
[INFO]             Executing command: /bin/sh -c cd '/home/michael/IdeaProjects/GistFX/.' && '/home/michael/Java/jdk-18.0.1.1/bin/jdeps' -q --multi-release 18 --ignore-missing-deps --print-module-deps /home/michael/IdeaProjects/GistFX/target/GistFX/libs/*.jar /home/michael/IdeaProjects/GistFX/target/GistFX-3.4.60-runnable.jar
[INFO]             java.base,java.management,java.naming,java.net.http,java.prefs,java.security.sasl,java.sql,jdk.jfr,jdk.jsobject,jdk.unsupported,jdk.unsupported.desktop,jdk.xml.dom
[INFO]         Required modules found: [java.base, java.management, java.naming, java.net.http, java.prefs, java.security.sasl, java.sql, jdk.jfr, jdk.jsobject, jdk.unsupported, jdk.unsupported.desktop, jdk.xml.dom]
[INFO]         
[INFO]         Creating JRE with next modules included: java.base,java.management,java.naming,java.net.http,java.prefs,java.security.sasl,java.sql,jdk.jfr,jdk.jsobject,jdk.unsupported,jdk.unsupported.desktop,jdk.xml.dom
[INFO]         Using /home/michael/Java/jdk-18.0.1.1/jmods modules directory
[INFO]         Executing command: /bin/sh -c cd '/home/michael/IdeaProjects/GistFX/.' && '/home/michael/Java/jdk-18.0.1.1/bin/jlink' --module-path /home/michael/Java/jdk-18.0.1.1/jmods --add-modules java.base,java.management,java.naming,java.net.http,java.prefs,java.security.sasl,java.sql,jdk.jfr,jdk.jsobject,jdk.unsupported,jdk.unsupported.desktop,jdk.xml.dom --output /home/michael/IdeaProjects/GistFX/target/GistFX/jre --no-header-files --no-man-pages --strip-debug --compress=2
[INFO]         Error: java.io.IOException: Cannot run program "objcopy": error=2, No such file or directory
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  18.449 s
[INFO] Finished at: 2022-05-27T16:50:03-07:00
[INFO] ------------------------------------------------------------------------

Seems to be an issue with objcopy not being found - whatever that is ... I did a find for any file with that name and nothing came back so I don't know what it's looking for, nor why it's looking for that file.

EasyG0ing1 commented 2 years ago

@fvarrui - OK, nevermind, I figured it out ... apparently objcopy is part of something called binutils ... so I installed that and everything completed successfully ... I have install artifacts ... now to go test them :-)

fvarrui commented 2 years ago

Hi @EasyG0ing1! Great ... sorry for my lack of help. Despite of this problem has already been reported before, I didn't realize that this could be the same case. I think I'm going to add a comment in the docs.

fvarrui commented 2 years ago

And there's an error when printing the executed commands (and possibly this causes confusion):

/home/michael/Java/jdk-18.0.1.1/bin/jlink 
    --module-path /home/michael/Java/jdk-18.0.1.1/jmods 
    [Ljava.lang.String;@634aa81e --add-modules ALL-MODULE-PATH 
    --output /home/michael/IdeaProjects/GistFX/target/GistFX/jre 
    --no-header-files 
    --no-man-pages
    --strip-debug 
    --compress=2 

In the third line you can see this: [Ljava.lang.String;@634aa81e .... it's only a problem when printing arrays. It doesn't affect to the command execution, but I have to fix it.

EasyG0ing1 commented 2 years ago

@fvarrui - Yeah, I noticed that. I just deleted it before running the command independently, which was helpful in finding the source of the problem, ultimately.