我也找不到任何 Maven 插件。
maven Central 中有 1.2 版的 packr,但请记住,这现在是一个相当旧的版本(https://github.com/libgdx/packr/issues/58)。
您可以使用标准 exec-maven-plugin 来利用 packr 1.2 依赖项,然后运行它(请参阅http://www.mojohaus.org/exec-maven-plugin/examples/example-exec-using-plugin-dependencies .html)。
pom.xml 构建文件中的相关片段可能类似于:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.5.0</version>
<dependencies>
<!-- https://mvnrepository.com/artifact/com.badlogicgames.packr/packr -->
<dependency>
<groupId>com.badlogicgames.packr</groupId>
<artifactId>packr</artifactId>
<version>1.2</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>package-native-windows</id>
<phase>package</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<includeProjectDependencies>false</includeProjectDependencies>
<includePluginDependencies>true</includePluginDependencies>
<executableDependency>
<groupId>com.badlogicgames.packr</groupId>
<artifactId>packr</artifactId>
</executableDependency>
<mainClass>com.badlogicgames.packr.Packr</mainClass>
<arguments>
<argument>packr-windows-config.json</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
如果您的 pom.xml 中已经有一个<build>
and<plugins>
部分,那么只需<plugin>
将其放入其中。
json 配置文件可能类似于:
{
"platform": "windows",
"jdk": "jre-8u102-windows-x64.zip",
"executable": "MyApp",
"appjar": "target/MyApp-jar-with-dependencies.jar",
"classpath": [ "MyApp-jar-with-dependencies.jar" ],
"mainclass": "com.foo.MyAppMain",
"outdir": "target/native-windows"
}
需要注意的一件事是,packr 1.2 似乎删除了“outdir”目录,所以要小心使用“target”目录以外的东西。
如果有帮助,我个人最终使用带有launch4j-maven-plugin 的launch4j 为windows 打包,并通过javafx-maven-plugin 使用Oracle 的标准javapackager 工具为linux/mac 打包。我会链接到这两个,但 StackOverflow 告诉我我没有足够的代表来包含两个以上的链接。