【发布时间】:2012-04-06 19:18:05
【问题描述】:
我想使用 maven 和 launch4j 将基于 java 的命令行应用程序及其所有依赖项包装到单个 *.exe 文件中。
现在我已经阅读了关于 SO 的所有类似问题,例如 this one 和 this,但我无法让它发挥作用。
任何人都可以提供一个简单的 pom.xml sn-p,如何通过所有需要的依赖项来实现这一点。 顺便说一句,我应该在 Eclipse 运行配置中运行什么 maven 构建目标?
这是我从 SO 中复制的内容:
<!-- 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>
当我在 Eclipse 中运行 launch4j:launch4j 目标时(如果这是正确的?)我得到:
未能执行目标 org.bluestemsoftware.open.maven.plugin:launch4j-plugin:1.5.0.0:launch4j 项目导入器上的(默认-cli):参数“headerType”,“jre” 为目标 org.bluestemsoftware.open.maven.plugin:launch4j-plugin:1.5.0.0:launch4j 丢失或无效 -> [帮助 1]
也许我只是在启动错误的目标......
【问题讨论】:
-
试试this插件怎么样,好像比较新?
-
vorburger 插件看起来很有希望,但应该执行哪个目标?
-
执行 mvn install 我得到:缺少所需的类:com.akathist.maven.plugins.launch4j.Launch4jMojo 失败。这在 vorburger 演示应用程序中。