Estoy intentando crear un archivo exe usando Launch4j, pero en realidad parece que Maven no detecta que tengo el complemento vinculado a la fase package.

Este es mi 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>

Este es el registro que obtengo cuando ejecuto el comando 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] ------------------------------------------------------------------------

Como puede ver, el complemento nunca se ejecutó. En mi pom.xml ya he desatado todas las fases pero parece que no hace nada.

¡Se agradece cualquier ayuda! Gracias

0
Z. Alessandro 8 oct. 2019 a las 21:51

1 respuesta

La mejor respuesta

Todos los complementos declarados en pluginManagement son solo configuración, destinados a ser utilizados por proyectos actuales o secundarios. No se ejecutan a menos que los declare dentro de la etiqueta plugins.

Dicho esto, aún necesita declarar el complemento dentro de la etiqueta plugins como se muestra a continuación.

<?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>

Tenga en cuenta que no se define ninguna versión para launch4j-maven-plugin ya que se heredará de pluginManagement.

1
Ravindra Gullapalli 8 abr. 2021 a las 21:14