gpt4 book ai didi

java - 尝试使用 Alakai 插件将 Launch4j 集成到 Maven 项目中

转载 作者:搜寻专家 更新时间:2023-10-30 19:52:29 28 4
gpt4 key购买 nike

我正在尝试将安装程序的生成集成为 Maven 编译过程的一部分。

我找到了 Alakai's plugin对于 Launch4j .我已经使用 Maven 创建了一个简单的 Hello World 应用程序。我尝试使用 Alakai 提供的配置示例,但是当我编译我的项目时,我得到:

Failed to execute goal org.bluestemsoftware.open.maven.plugin:launch4j-plugin:1.5.0.0:launch4j (launch4j) on project Launch4j: Failed to build the executable; please verify your configuration. Application jar doesnt exist. -> [Help 1]

不幸的是,Alakai 的文档有限,我用谷歌搜索找不到太多。

  • 有谁知道应该在哪里设置 Launch4j config.xml?是在项目内吗?它在单独的目录中吗?
  • 我需要使用程序集插件吗?
  • 我已经在我的 PC 上安装了 Launch4j。我需要在我的 pom.xml 中指定安装目录吗?如果是,如何?
  • 是否有人可以分享可操作的 pom.xml 样本/示例?

谢谢。

最佳答案

  1. 没有 config.xml,您需要在 pom.xml 文件中配置 launch4j。
  2. 您可以使用 maven-assembly-plugin,但我建议您使用 maven-shade-plugin。
  3. 无需指定 launch4j 安装,此插件 100% 支持 maven。
  4. 当然可以。遵循我使用的 shade 和 launch4j 配置,生成两个 exe,一个控制台和一个 gui,使用不同的主类:

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

<!-- GUI exe -->
<execution>
<id>l4j-gui</id>
<phase>package</phase>
<goals>
<goal>launch4j</goal>
</goals>
<configuration>
<headerType>gui</headerType>
<outfile>target/app-gui.exe</outfile>
<jar>target/${artifactId}-${version}-shaded.jar</jar> <!-- 'shaded' is the value set on shadedClassifierName above -->
<errTitle>App Err</errTitle>
<classPath>
<mainClass>package.AppGUI</mainClass>
</classPath>
<icon>src/main/resources/icons/exeIcon.ico</icon>
<jre>
<minVersion>1.5.0</minVersion>
<maxVersion>1.6.0</maxVersion>
<initialHeapSize>128</initialHeapSize>
<maxHeapSize>1024</maxHeapSize>
</jre>
<versionInfo>
<fileVersion>1.0.0.0</fileVersion>
<txtFileVersion>1.0.0.0</txtFileVersion>
<fileDescription>Desc</fileDescription>
<copyright>C</copyright>
<productVersion>1.0.0.0</productVersion>
<txtProductVersion>1.0.0.0</txtProductVersion>
<productName>Product</productName>
<internalName>Product</internalName>
<originalFilename>App.exe</originalFilename>
</versionInfo>
</configuration>
</execution>

<!-- Command-line exe -->
<execution>
<id>l4j-cli</id>
<phase>package</phase>
<goals>
<goal>launch4j</goal>
</goals>
<configuration>
<headerType>console</headerType>
<outfile>target/app-cli.exe</outfile>
<jar>target/${artifactId}-${version}-shaded.jar</jar> <!-- 'shaded' is the value set on shadedClassifierName above -->
<errTitle>App Err</errTitle>
<classPath>
<mainClass>package.AppCLI</mainClass>
</classPath>
<icon>src/main/resources/icons/exeIcon.ico</icon>
<jre>
<minVersion>1.5.0</minVersion>
<maxVersion>1.6.0</maxVersion>
<initialHeapSize>128</initialHeapSize>
<maxHeapSize>1024</maxHeapSize>
</jre>
</configuration>
</execution>
</executions>
</plugin>

或者,您可以省略 launch4j-plugin 上的“jar”标签并删除 shade-plugin 的额外配置,但请注意,这将用 shaded jar 替换流程的主要 jar(没有嵌入式依赖项) (具有嵌入式依赖项),这个将安装在您的本地存储库中,或者在需要时在 react 器中使用。

关于java - 尝试使用 Alakai 插件将 Launch4j 集成到 Maven 项目中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6060560/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com