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 134 forks source link

Failed to execute goal io.github.fvarrui:javapackager:1.7.0-SNAPSHOT:package (linux) on project example: Could not remove folder #264

Closed vukca closed 2 years ago

vukca commented 2 years ago

Hello! I'm submitting a Mojo bug for the 1.7.0-SNAPSHOT version. I am unable to package my application due to strange behavior of the plugin.

[ERROR] Failed to execute goal io.github.fvarrui:javapackager:1.7.0-SNAPSHOT:package (linux) on project lavagui: Could not remove folder /home/vuk/Documents/git/sample-app/target/sample-app/jre/legal: Unable to delete directory /home/vuk/Documents/git/sample-app/target/sample-app/jre/legal. -> [Help 1]

Pom.xml

<plugin>
        <groupId>io.github.fvarrui</groupId>
        <artifactId>javapackager</artifactId>
        <version>1.7.0-SNAPSHOT</version>
        <configuration>
          <mainClass>${exec.mainClass}</mainClass>
          <bundleJre>true</bundleJre>
          <jrePath>${java.home}</jrePath>
          <generateInstaller>true</generateInstaller>
          <administratorRequired>true</administratorRequired>
          <copyDependencies>true</copyDependencies>
        </configuration>
        <executions>
          <execution>
            <id>linux</id>
            <phase>package</phase>
            <goals>
              <goal>package</goal>
            </goals>
            <configuration>
              <platform>auto</platform>
              <additionalResources>
                <additionalResource>${project.basedir}/lib/scripts</additionalResource>
              </additionalResources>
              <createZipball>true</createZipball>
              <createTarball>true</createTarball>
              <linuxConfig>
                <pngFile>${project.basedir}/src/main/resources/img/icon.png</pngFile>
                <generateAppImage>true</generateAppImage>
                <generateDeb>true</generateDeb>
                <generateRpm>true</generateRpm>
                <wrapJar>true</wrapJar>
                <categories>
                  <category>Utility</category>
                </categories>
              </linuxConfig>
            </configuration>
          </execution>
        </executions>
      </plugin>

P.S. Many thanks for creating this great plugin! :)

fvarrui commented 2 years ago

Hi @vukca!

I've seen that you are bundling a full JDK with your app:

<jrePath>${java.home}</jrePath>

This is not a good idea, as it will add an unnecessary size to your app.

Why don't you let JavaPackager to generate a customized JRE for your app? Just omit jrePath and JavaPackager will do all the magic for you. If you have problems due to missing modules when generating a customized JRE, try also with customizedJRE=false.

I am trying to figure out what could be causing such a trivial error, running the sudo mvn package on the other hand produces the following error:

Plugin io.github.fvarrui:javapackager:1.7.0-SNAPSHOT or one of its dependencies could not be resolved: Could not find artifact io.github.fvarrui:javapackager:jar:1.7.0-SNAPSHOT

This could be caused due to JavaPackager 1.7.0-SNAPSHOT doesn't exist in root's .m2 folder, as it has to be installed manually because this version is not released to Maven Central. Not a good idea either! 😅

P.S. Many thanks for creating this great plugin! :)

Thanks to you for using JavaPackager!

fvarrui commented 2 years ago

Hi @vukca! Did you manage to fix this?

vukca commented 2 years ago

Hi @vukca! Did you manage to fix this?

Hi, sorry for not responding for a longer time period. I did indeed manage to create the artifacts. Anyways I was including the full JDK since I wrote the GUI application with Java 18 and had to run .jars that are confirmed to work with older versions of JRE, well that was the original idea anyway. The root of my problem was pretty silly of me and took me some time to figure out and that was the fact that I was not referencing to my local .m2 repository in which I built the 1.7.0-SNAPSHOT with Gradle but instead let the IntelliJ handle the Maven binary through the built-in one. Either way everything is solved! Thanks for help!

fvarrui commented 2 years ago

Great!!