使用launch4j和maven包装java命令行应用程序
我想使用maven和launch4j将一个基于java的命令行应用程序及其所有依赖项封装到一个*.exe文件中 现在我已经阅读了所有类似的问题,但我不能让它工作 任何人都可以提供一个简单的pom.xml代码段,如何通过所有需要的依赖项实现这一点。 顺便问一下,在Eclipse运行配置中,我应该运行什么maven构建目标 以下是我从SO复制的内容:使用launch4j和maven包装java命令行应用程序,java,maven,launch4j,Java,Maven,Launch4j,我想使用maven和launch4j将一个基于java的命令行应用程序及其所有依赖项封装到一个*.exe文件中 现在我已经阅读了所有类似的问题,但我不能让它工作 任何人都可以提供一个简单的pom.xml代码段,如何通过所有需要的依赖项实现这一点。 顺便问一下,在Eclipse运行配置中,我应该运行什么maven构建目标 以下是我从SO复制的内容: <!-- Launch4j --> <plugin> <groupId>o
<!-- Launch4j -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached> <!-- Make the shaded artifact not the main one -->
<shadedClassifierName>shaded</shadedClassifierName> <!-- set the suffix to the shaded jar -->
</configuration>
</plugin>
<plugin>
<groupId>org.bluestemsoftware.open.maven.plugin</groupId>
<artifactId>launch4j-plugin</artifactId>
<version>1.5.0.0</version>
<executions>
<!-- Command-line exe -->
<execution>
<id>l4j-cli</id>
<phase>package</phase>
<goals>
<goal>launch4j</goal>
</goals>
<configuration>
<headerType>console</headerType>
<outfile>target/importer.exe</outfile>
<jar>target/${artifactId}-${version}-shaded.jar</jar> <!-- 'shaded' is the value set on shadedClassifierName above -->
<errTitle>App Err</errTitle>
<classPath>
<mainClass>${mainClass}</mainClass>
</classPath>
<jre>
<minVersion>1.5.0</minVersion>
<maxVersion>1.6.0</maxVersion>
<initialHeapSize>128</initialHeapSize>
<maxHeapSize>1024</maxHeapSize>
</jre>
</configuration>
</execution>
</executions>
</plugin>
org.apache.maven.plugins
maven阴影插件
1.4
包裹
阴凉处
真的
遮住的
org.bluestemsoftware.open.maven.plugin
启动4J插件
1.5.0.0
l4j cli
包裹
发射4J
安慰
target/importer.exe
target/${artifactId}-${version}-shaded.jar
应用程序错误
${mainClass}
1.5.0
1.6.0
128
1024
当我在Eclipse中运行launch4j:launch4j目标时(如果这是正确的?),我得到:
未能执行目标
plugin:launch4j plugin:1.5.0.0:launch4j
(默认cli)在项目导入器上:参数'headerType','jre'
为了目标
plugin:launch4j plugin:1.5.0.0:launch4j
缺少或无效->[帮助1]
也许我只是发射了一个错误的目标…Drejc
我可以生成一个配置与您非常相似的.exe文件。遵循我的整个pom:
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>test</artifactId>
<packaging>jar</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>test</name>
<properties>
<mainClass>foo.App</mainClass>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached> <!-- Make the shaded artifact not the main one -->
<shadedClassifierName>shaded</shadedClassifierName> <!-- set the suffix to the shaded jar -->
</configuration>
</plugin>
<plugin>
<groupId>com.akathist.maven.plugins.launch4j</groupId>
<artifactId>launch4j-maven-plugin</artifactId>
<executions>
<!-- Command-line exe -->
<execution>
<id>l4j-cli</id>
<phase>package</phase>
<goals>
<goal>launch4j</goal>
</goals>
<configuration>
<headerType>console</headerType>
<outfile>target/importer.exe</outfile>
<jar>target/${artifactId}-${version}-shaded.jar</jar> <!-- 'shaded' is the value set on shadedClassifierName above -->
<classPath>
<mainClass>${mainClass}</mainClass>
</classPath>
<jre>
<minVersion>1.5.0</minVersion>
<initialHeapSize>128</initialHeapSize>
<maxHeapSize>1024</maxHeapSize>
</jre>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>LATEST</version>
</dependency>
</dependencies>
</project>
4.0.0
测试
测试
罐子
0.0.1-快照
测试
foo.App
org.apache.maven.plugins
maven阴影插件
1.4
包裹
阴凉处
真的
遮住的
com.akatist.maven.plugins.launch4j
启动4J maven插件
l4j cli
包裹
发射4J
安慰
target/importer.exe
target/${artifactId}-${version}-shaded.jar
${mainClass}
1.5.0
128
1024
公用记录
公用记录
最新的
我将插件的groupId和artifactId改为vorburger的,但是alakai的版本也应该可以工作。确保:
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>test</artifactId>
<packaging>jar</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>test</name>
<properties>
<mainClass>foo.App</mainClass>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached> <!-- Make the shaded artifact not the main one -->
<shadedClassifierName>shaded</shadedClassifierName> <!-- set the suffix to the shaded jar -->
</configuration>
</plugin>
<plugin>
<groupId>com.akathist.maven.plugins.launch4j</groupId>
<artifactId>launch4j-maven-plugin</artifactId>
<executions>
<!-- Command-line exe -->
<execution>
<id>l4j-cli</id>
<phase>package</phase>
<goals>
<goal>launch4j</goal>
</goals>
<configuration>
<headerType>console</headerType>
<outfile>target/importer.exe</outfile>
<jar>target/${artifactId}-${version}-shaded.jar</jar> <!-- 'shaded' is the value set on shadedClassifierName above -->
<classPath>
<mainClass>${mainClass}</mainClass>
</classPath>
<jre>
<minVersion>1.5.0</minVersion>
<initialHeapSize>128</initialHeapSize>
<maxHeapSize>1024</maxHeapSize>
</jre>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>LATEST</version>
</dependency>
</dependencies>
</project>
4.0.0
测试
测试
罐子
0.0.1-快照
测试
foo.App
org.apache.maven.plugins
maven阴影插件
1.4
包裹
阴凉处
真的
遮住的
com.akatist.maven.plugins.launch4j
启动4J maven插件
l4j cli
包裹
发射4J
安慰
target/importer.exe
target/${artifactId}-${version}-shaded.jar
${mainClass}
1.5.0
128
1024