我想使用maven和launch4j將基於java的命令行應用程序及其所有依賴項包裝到單個* .exe文件中。使用launch4j和maven包裝java命令行應用程序
現在我已閱讀所有類似的問題,例如this one和this,但我無法使其工作。
任何人都可以提供一個簡單的pom.xml片段,如何實現這一點與所有需要的依賴關係。 順便說一下,我應該在Eclipses運行配置中運行哪些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>
當我運行launch4j:(?如果這是正確的)launch4j目標在Eclipse中,我得到:
未能執行目標 org.bluestemsoftware.open.maven.plugin:launch4j-插件:1.5.0.0:launch4j (默認CLI)項目進口商:參數 'headerType', 'JRE' 爲目標 org.bluestemsoftware.open.maven.plugin:launch4j-插件:1.5.0.0:launch4j 缺失或無效的 - > [求助1]
也許我只是發動假目標...
Drejc!
如何嘗試[this](https://github.com/vorburger/launch4j-maven-plugin)插件,這似乎是更新的? – Raghuram 2012-03-22 13:07:55
vorburger插件看起來很有希望,但是應該執行哪個目標? – Drejc 2012-03-22 13:53:28
執行mvn install我得到:缺少必需的類:com.akathist.maven.plugins.launch4j.Launch4jMojo失敗。這在vorburger演示應用程序中。 – Drejc 2012-03-22 14:21:13