Issue
I'm trying to build an exe
file using Launch4j but it actually seems like Maven doesn't detect I have the plugin bound to the package
phase.
This is my pom.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.project1616</groupId>
<artifactId>Project16x16</artifactId>
<version>1.0.0</version>
<name>Project16x16</name>
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<repositories>
<repository>
<id>repo</id>
<releases>
<enabled>true</enabled>
<checksumPolicy>ignore</checksumPolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<url>file://${project.basedir}/repo</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>local</groupId>
<artifactId>core</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>local</groupId>
<artifactId>DM</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>local</groupId>
<artifactId>gicentreUtils</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>local</groupId>
<artifactId>javafx-swt</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>local</groupId>
<artifactId>javafx.base</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>local</groupId>
<artifactId>javafx.controls</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>local</groupId>
<artifactId>javafx.fxml</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>local</groupId>
<artifactId>javafx.graphics</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>local</groupId>
<artifactId>javafx.media</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>local</groupId>
<artifactId>javafx.swing</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>local</groupId>
<artifactId>javafx.web</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx</artifactId>
<version>13</version>
<type>pom</type>
</dependency>
</dependencies>
<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<phase>none</phase>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
<executions>
<execution>
<phase>none</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<executions>
<execution>
<phase>none</phase>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
<executions>
<execution>
<phase>none</phase>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<executions>
<execution>
<phase>none</phase>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
<executions>
<execution>
<phase>none</phase>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<executions>
<execution>
<phase>none</phase>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
<executions>
<execution>
<phase>none</phase>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<phase>none</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
<executions>
<execution>
<phase>none</phase>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>org.project16x16.sidescroller.SideScroller</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
<plugin>
<groupId>com.akathist.maven.plugins.launch4j</groupId>
<artifactId>launch4j-maven-plugin</artifactId>
<version>1.7.25</version>
<executions>
<execution>
<id>l4j-clui</id>
<phase>package</phase>
<goals>
<goal>launch4j</goal>
</goals>
<configuration>
<headerType>gui</headerType>
<jar>${project.build.directory}/Project16x16-1.0.0-jar-with-dependencies.jar</jar>
<outfile>${project.build.directory}/${project.artifactId}.exe</outfile>
<downloadUrl>http://java.com/download</downloadUrl>
<pluginArtifacts>${plugin.artifacts}</pluginArtifacts>
<jre>
<path>C:\Program Files\Java\jdk-12.0.2</path>
<bundledJre64Bit>false</bundledJre64Bit>
<bundledJreAsFallback>false</bundledJreAsFallback>
<minVersion></minVersion>
<maxVersion></maxVersion>
<jdkPreference>preferJre</jdkPreference>
<runtimeBits>64/32</runtimeBits>
</jre>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
This is the log I get when I run the command mvn package
:
[INFO]
[INFO] --------------------< org.project1616:Project16x16 >--------------------
[INFO] Building Project16x16 1.0.0
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) @ Project16x16 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 57 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ Project16x16 ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:testResources (default-testResources) @ Project16x16 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\myDir\Project16x16\source\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ Project16x16 ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to C:\myDir\Project16x16\source\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.22.1:test (default-test) @ Project16x16 ---
[INFO]
[INFO] --- maven-jar-plugin:3.0.2:jar (default-jar) @ Project16x16 ---
[INFO] Building jar: C:\myDir\Project16x16\source\target\Project16x16-1.0.0.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.193 s
[INFO] Finished at: 2019-10-08T20:46:06+02:00
[INFO] ------------------------------------------------------------------------
As you can see, the plugin was never executed. In my pom.xml
I've alredy unbound all the phases but it seems to do nothing.
Any help is appreciated! Thanks
Solution
All the plugins declared under pluginManagement
are just configuration, intended to be used by current or child projects. They don't get executed unless you declare them inside plugins
tag.
Saying that, you still need to declare plugin inside plugins
tag like the following.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
...
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>com.akathist.maven.plugins.launch4j</groupId>
<artifactId>launch4j-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Notice that no version for launch4j-maven-plugin
is defined as it will be inherited from pluginManagement
.
Answered By - pmverma