Maven:使用 Inno Setup 脚本构建 javaFX 应用程序的本机安装程序

Piy*_*ush 5 java javafx inno-setup maven

最近我完成了一个 JavaFX 项目,现在我想为 Windows 创建本机安装程序。我用来exec-maven-plugin创建一个安装程序,它工作正常,并使用 inno 安装脚本的默认设置生成 exe 文件。

我创建了一个名为 [project-name].iss 的 inno 安装脚本,并将其放置在app\src\main\deploy\package\windows\[project-name].iss.

我的 Maven 插件代码看起来像

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <executions>
        <execution>
            <id>package-jar</id>
            <phase>package</phase>
            <goals>
                <goal>exec</goal>
            </goals>
            <configuration>
                <executable>
                    ${env.JAVA_HOME}/bin/javapackager
                </executable>
                <arguments>
                    <argument>-createjar</argument>
                    <argument>-appclass</argument>
                    <argument>${app.main.class}</argument>
                    <argument>-srcdir</argument>
                    <argument>
                        ${project.build.directory}/classes
                    </argument>
                    <argument>-outdir</argument>
                    <argument>./target</argument>
                    <argument>-outfile</argument>
                    <argument>
                        ${project.artifactId}-app
                    </argument>
                    <argument>-v</argument>
                </arguments>
            </configuration>
        </execution>
        <execution>
            <id>package-jar2</id>
            <phase>package</phase>
            <goals>
                <goal>exec</goal>
            </goals>
            <configuration>
                <executable>
                    ${env.JAVA_HOME}/bin/javapackager
                </executable>

                <arguments>
                    <argument>-deploy</argument>
                    <argument>-native</argument>
                    <argument>installer</argument>
                    <argument>-appclass</argument>
                    <argument>${app.main.class}</argument>
                    <argument>-srcfiles</argument>
                    <argument>
                        ${project.build.directory}/${artifactId}-app.jar
                    </argument>
                    <argument>-outdir</argument>
                    <argument>./target</argument>
                    <argument>-outfile</argument>
                    <argument>
                        ${project.artifactId}-app
                    </argument>
                    <argument>-v</argument>
                </arguments>
            </configuration>
        </execution>

    </executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)

[项目名称].iss 文件看起来像

[Setup]
AppName=Project Name
AppId=ProjectName
AppVersion=0.1.0
AppPublisher=Project Name
AppPublisherURL=http://www.todo.com/
AppSupportURL=http://www.todo.com/
AppUpdatesURL=http://www.todo.com/
MinVersion=5.1
DefaultDirName={pf}\Project Name
DefaultGroupName=Project Name
AllowNoIcons=yes
Compression=lzma2/ultra
InternalCompressLevel=ultra
SolidCompression=yes
SetupIconFile=icon.ico
AllowCancelDuringInstall=false
Run Code Online (Sandbox Code Playgroud)

但是在 maven 包之后,我得到了可执行文件,该文件没有上面 inno setup 脚本中的任何属性。(我还将 icon.ico 文件放置在app\src\main\deploy\package\windows\icon.ico

打包应用程序时输出日志(默认不使用 [project-name].iss 脚本配置) 在此输入图像描述

那么你能帮我解决我在 Maven 插件或其他任何东西中缺少的配置吗?

谢谢。

Fib*_*FoX 1

(即使这是一个老问题,其他一些人可能会搜索这个)

您需要注意正确的文件名,所使用的 appName 负责 javapackager 正在搜索的文件名。

由于您没有提供某些-name- 参数,因此 appName 是从提供的主类( - 参数)中收集的,甚至会打印在使用的appclass命令日志中。Main.ico所以你需要添加这个:

<argument>-name</argument>
<argument>${project.artifactId}</argument>
Run Code Online (Sandbox Code Playgroud)

这意味着.ico-file 的文件名必须位于${project.artifactId}.icoapp/src/main/deploy/windows-folder 之下。