![](/img/trans.png)
[英]Write to console from a native javafx app created with Inno Setup and maven
[英]Maven : Build native installer of javaFX application with Inno Setup script
最近我完成了一个 JavaFX 项目,现在我想为 Windows 创建本机安装程序。 我正在使用exec-maven-plugin
创建一个安装程序,它工作正常并使用 inno setup 脚本的默认设置生成 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>
而 [project-name].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
但是在 maven 包之后,我得到了没有任何属性的可执行文件来自 inno 安装脚本。(我还在app\\src\\main\\deploy\\package\\windows\\icon.ico
放置了 icon.ico 文件)
打包应用程序时输出日志(默认不使用 [project-name].iss 脚本配置)
那么你能帮我在 Maven 插件或其他任何东西中缺少的任何配置吗?
谢谢。
(即使这是一个老问题,其他一些人也可能会搜索这个)
您需要注意正确的文件名,使用的 appName 负责 javapackager 正在搜索的文件名。
由于您没有提供一些-name
-parameter,appName 是从提供的主类( appclass
-parameter)中收集的,这甚至打印在该命令日志中, Main.ico
被使用。 所以你需要添加这个:
<argument>-name</argument>
<argument>${project.artifactId}</argument>
这意味着.ico
文件的文件名必须是该app/src/main/deploy/windows
夹下的${project.artifactId}.ico
。
你可以试试JavaPackager Maven Plugin 。 它不依赖于javapackager
工具。
您的 POM 只需要包含如下内容:
<plugin>
<groupId>io.github.fvarrui</groupId>
<artifactId>javapackager</artifactId>
<version>0.9.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>package</goal>
</goals>
<configuration>
<name>ProjectName</name>
<version>0.1.0</version>
<url>http://www.todo.com/</url>
<mainClass>${app.main.class}</mainClass>
<bundleJre>true</bundleJre>
<iconFile>src/main/deploy/package/windows/icon.ico</iconFile>
</configuration>
</execution>
</executions>
</plugin>
该插件将为您的应用程序生成一个安装程序,其中包含一个捆绑和自定义的 JRE。 它会为您完成所有工作,因此您不必担心任何 ISS 文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.