尝试使用Alakai插件将Launch4j集成到Maven项目中 [英] Trying to integrate Launch4j in a Maven project using Alakai plugin

查看:132
本文介绍了尝试使用Alakai插件将Launch4j集成到Maven项目中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to integrate the generation of an installer as part of a maven compilation process.

我找到了 Launch4j 的org / reference / plugins / launch4j-plugin-usage.html> Alakai的插件。我使用Maven创建了一个简单的Hello World应用程序。我试图使用Alakai提供的配置示例,但是当我编译项目时,我得到:

I have found Alakai's plugin for Launch4j. I have create a simple Hello World application using Maven. I have tried to use configuration examples provided by Alakai, but when I compile my project, I get:


执行目标失败
org.bluestemsoftware.open.maven.plugin:launch4j-plugin:1.5.0.0:launch4j
(launch4j)项目Launch4j:
构建可执行文件失败;请验证
您的配置。应用程序jar
不存在。 - > [帮助1]

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的文档是有限的,我用谷歌搜索找不到多少。

Unfortunately, Alakai's documentation is limited and I could not find much with Googling.


  • 有谁知道应该在哪里设置Launch4j config.xml?它在项目内吗?它是在一个单独的目录中吗?

  • 我是否需要使用程序集插件?

  • 我在我的电脑上安装了Launch4j。我是否需要在pom.xml中指定安装目录?如果是的话怎么样?

  • 是否有人有一个可操作的pom.xml示例/示例要共享?

  • Does anyone know where the Launch4j config.xml should be set? Is it within the project? Is it in a separate directory?
  • Do I need to use the assembly plugin?
  • I have installed Launch4j on my PC. Do I need to specify the installation directory in my pom.xml? If yes how?
  • Does anyone have an operational pom.xml sample/example to share?

谢谢。

推荐答案


  1. 没有config.xml,你需要在你的pom.xml文件中配置launch4j。

  2. 你可以使用maven-assembly-plugin,但我建议你使用maven-shade-plugin。

  3. 不需要指定launch4j安装,这个插件工作100%maven。

  4. 当然。按照我使用的阴影和launch4j配置,生成两个exes,一个控制台和一个gui,使用不同的主类:

  1. There's no config.xml, you need to configure launch4j inside your pom.xml file.
  2. You could use maven-assembly-plugin, but I recommend you to use maven-shade-plugin.
  3. Don't need to specify launch4j installation, this plugin works 100% maven.
  4. Sure. Follows the shade and launch4j configs I use, that generates two exes, one console and one gui, using different main classes:

<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的额外配置,但请注意,这将替换阴影jar(具有嵌入式依赖项)的流的主jar(没有嵌入的依赖项),并且这个将安装在您的本地仓库,或在需要时在反应堆中使用。

Alternatively, You can omit the 'jar' tag on launch4j-plugin and remove the extra configs of the shade-plugin, but be aware that this will replace the main jar of the flow (without embedded dependencies) by the shaded jar (with embedded dependencies), and this one will be installed on your local repo, or used in the reactor if needed.

这篇关于尝试使用Alakai插件将Launch4j集成到Maven项目中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆