Java 尝试使用Alakai插件在Maven项目中集成Launch4j

Java 尝试使用Alakai插件在Maven项目中集成Launch4j,java,maven,integration,launch4j,Java,Maven,Integration,Launch4j,我试图将安装程序的生成作为maven编译过程的一部分进行集成 我找到了我的工作。我已经使用Maven创建了一个简单的Hello World应用程序。我曾尝试使用Alakai提供的配置示例,但当我编译我的项目时,我得到: 未能执行目标 plugin:launch4j plugin:1.5.0.0:launch4j 项目启动4j上的(启动4j):失败 构建可执行文件;请核实 您的配置。应用程序jar 不存在。->[帮助1] 不幸的是,Alakai的文档是有限的,我在Google上找不到太多 有人知

我试图将安装程序的生成作为maven编译过程的一部分进行集成

我找到了我的工作。我已经使用Maven创建了一个简单的Hello World应用程序。我曾尝试使用Alakai提供的配置示例,但当我编译我的项目时,我得到:

未能执行目标 plugin:launch4j plugin:1.5.0.0:launch4j 项目启动4j上的(启动4j):失败 构建可执行文件;请核实 您的配置。应用程序jar 不存在。->[帮助1]

不幸的是,Alakai的文档是有限的,我在Google上找不到太多

  • 有人知道Launch4j config.xml应该设置在哪里吗?是否在项目范围内?它在一个单独的目录中吗
  • 我需要使用汇编插件吗
  • 我已在电脑上安装了Launch4j。是否需要在pom.xml中指定安装目录?如果是,怎么做
  • 有没有人可以分享一个可操作的pom.xml示例/示例
谢谢

  • 没有config.xml,您需要在pom.xml文件中配置launch4j
  • 您可以使用maven assembly插件,但我建议您使用maven shade插件
  • 不需要指定launch4j安装,这个插件100%在maven中工作
  • 当然。遵循我使用的shade和launch4j配置,它使用不同的主类生成两个EXE,一个控制台和一个gui:
  • 
    org.apache.maven.plugins
    maven阴影插件
    1.4
    包裹
    阴凉处
    真的
    遮住的
    org.bluestemsoftware.open.maven.plugin
    启动4J插件
    1.5.0.0
    l4j图形用户界面
    包裹
    发射4J
    桂
    目标/app-gui.exe
    target/${artifactId}-${version}-shaded.jar
    应用程序错误
    package.AppGUI
    src/main/resources/icons/exeIcon.ico
    1.5.0
    1.6.0
    128
    1024
    1.0.0.0
    1.0.0.0
    描述
    C
    1.0.0.0
    1.0.0.0
    产品
    产品
    App.exe
    l4j cli
    包裹
    发射4J
    安慰
    目标/app-cli.exe
    target/${artifactId}-${version}-shaded.jar
    应用程序错误
    package.AppCLI
    src/main/resources/icons/exeIcon.ico
    1.5.0
    1.6.0
    128
    1024
    


    或者,您可以省略launch4j插件上的“jar”标记并删除shade插件的额外配置,但请注意,这将用shade jar(带有嵌入式依赖项)替换流的主jar(没有嵌入式依赖项),并且此jar将安装在本地repo上,如果需要,也可以在反应器中使用。

    有关如何定义shade插件的主类,请参阅。

    非常好,它可以工作。但是,我在你的例子中发现了一个小转折。maven shade插件似乎没有在清单中保留主类名。因此,当我双击exe时,我得到一个找不到的类。我改用了汇编插件(我知道这是个魔鬼)。好了,我们不需要清单上的主类来让它工作。你检查过完全限定的类名吗?我刚从一个已经在生产的项目中取了它,只是更改了名称。如果你想给我发你的pom,我可以帮你,我的电子邮件是我的昵称,在gmail。不管怎样,你能解决你的问题真是太好了!谢谢你的提议。我可以在汇编插件中设置主类。现在一切都干净了。这里有一个更新更好的插件版本:有人能提供一个关于如何使用汇编插件的示例(snip)吗?只是一个相关信息:这个问题的答案也适用于9 St.Mary路launch4j插件,它是原始插件(AFAIK)。如果您使用的是这个旧版本,我建议您迁移到Alakai的上一个版本。@Damian修复了不鼓励使用链接的问题,请至少添加一个如何操作的摘要。
    <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>