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

Possible launch4j dependency version issue? #339

Closed valimaties closed 1 year ago

valimaties commented 1 year ago

I'm submitting a…

Short description of the issue/suggestion: In build.gradle file you have implementation for launch4j as:

implementation 'io.github.fvarrui:launch4j:2.5.2'

However, in CreateWindowsExeLaunch4j.java class from maven folder you have this code for invoking the plugin:

                                 executeMojo(
                    plugin(
                            groupId("com.akathist.maven.plugins.launch4j"), 
                            artifactId("launch4j-maven-plugin"),
                            version("2.1.1")
                    ),
                    goal("launch4j"),
                    configuration(pluginConfig.toArray(new Element[pluginConfig.size()])),
                    Context.getMavenContext().getEnv()
                );

Is this correct? Because when I package my maven project I get an warning saying that

The POM for io.github.fvarrui:launch4j:jar:2.5.2 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details

I searched for the 2.5.2 version of this plugin for maven, but the latest one is 2.4.1 on MavenCentral.

https://mvnrepository.com/artifact/com.akathist.maven.plugins.launch4j/launch4j-maven-plugin

Steps to reproduce the issue/enhancement:

  1. [First Step]
  2. [Second Step]
  3. [Other Steps...]

What is the expected behavior?

What is the current behavior?

Do you have outputs, screenshots, demos or samples which demonstrate the problem or enhancement?

What is the motivation / use case for changing the behavior?

Please tell us about your environment:

Other information (e.g. related issues, suggestions how to fix, links for us to have context)

fvarrui commented 1 year ago

Hi @valimaties!

JavaPackager combines several existing plugins, instead of creating everything from scratch, and avoid reinventing the wheel. In some cases, libraries independent of the building tool are used, such as to generate DEB and RPM files.

Besides this, JavaPackager is a hybrid plugin, which means that the same plugin works with Gradle and Maven.

When generating EXE files on Windows using Launch4j, what it had were plugins, one for Maven (launch4j-maven-plugin) and another for Gradle (gradle-launch4j). It's not possible to reuse them because they are coupled to their context (one is coupled to Maven and the other one is coupled to Gradle).

In the case of Maven (plugins are composed of MOJOs), JP uses mojo-executor (org.twdata.maven:mojo-executor:2.3.0), which allows JP to run Maven plugins, just as you pointed:

https://github.com/fvarrui/JavaPackager/blob/fa1ca46f66cb341b89c5a17808bb7e239e3269e7/src/main/java/io/github/fvarrui/javapackager/maven/CreateWindowsExeLaunch4j.java#L107-L116

So, when the developer uses Maven+Launch4j, JP runs com.akathist.maven.plugins.launch4j:launch4j-maven-plugin:2.1.1.

But, in the case of Gradle, JP runs the plugin's tasks directly (plugins are composed of Tasks):

https://github.com/fvarrui/JavaPackager/blob/fa1ca46f66cb341b89c5a17808bb7e239e3269e7/src/main/java/io/github/fvarrui/javapackager/gradle/CreateWindowsExeLaunch4j.java#L51-L78

So, when the developer uses Gradle+Launch4j, JP uses io.github.fvarrui:launch4j:2.5.2.

Different building tools, different plugins, but "same" result.

valimaties commented 1 year ago

Its ok, maybe the "bug" is to much say, but I wanted to know that is no problem that IDE display that warning message about POM file. Thanks!

fvarrui commented 1 year ago

I also have to say that io.github.fvarrui:launch4j:2.5.2 is a fork of edu.sc.seis.launch4j:launch4j:3.0.3. I had to do this to publish gradle-launch4j plugin to Maven Central, as the latest versions are only found on the Gradle Plugin Portal, so using JP with Maven caused a missing dependency issue. I have solved this problem recently, thanks to someone helping to improve the build.gradle. So no need to use my own version of gradle-launch4j anymore, just the original one, which makes it easier to update this dependency.

fvarrui commented 1 year ago
The POM for io.github.fvarrui:launch4j:jar:2.5.2 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details

This is just a warning you don't have to worry about, as it has been recently fixed!

fvarrui commented 1 year ago

Thanks!! I hope I have explained myself 😄