我正在使用maven os x应用程序包插件,以便我可以创建java启动器的mac-executable版本。作为两个步骤的一部分,我必须这样做,不给我的用户Gatekeeper麻烦...
我必须配置一个自定义plist来正确设置java工作目录(单击jar时代码运行正常,单击.app时退出代码为1崩溃)
该插件允许您制作自己的plist并指出它在pom中的位置:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>osxappbundle-maven-plugin</artifactId>
<version>1.0-alpha-1</version>
<configuration>
<mainClass>com.helion3.Launcher</mainClass>
<dictionaryFile>${basedir}/src/main/resources/Info.plist</dictionaryFile>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>bundle</goal>
</goals>
</execution>
</executions>
</plugin>
该文件存在于该位置。当我运行mvn package
时,它现在失败了:
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:osxappbundle-maven-plugin:1.0-alpha-1:bundle (default) on project liftoff: Could not find resource for template /Users/myacct/Documents/workspace/MyProgram/src/main/resources/Info.plist
当我运行vi /Users/myacct/Documents/workspace/MyProgram/src/main/resources/Info.plist
时,文件会正常打开。
我的plist本身应该是有效的,因为我复制了最初生成的那个,添加了一个workingDirectory键,并用插件的占位符替换了一些值。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
<plist version="0.9">
<dict>
<key>CFBundleName</key>
<string>${bundleName}</string>
<key>CFBundleVersion</key>
<string>${describe}</string>
<key>CFBundleAllowMixedLocalizations</key>
<string>true</string>
<key>CFBundleExecutable</key>
<string>JavaApplicationStub</string>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleIconFile</key>
<string>GenericJavaApp.icns</string>
<key>Java</key>
<dict>
<key>WorkingDirectory</key>
<string>$APP_PACKAGE/Contents/Resources</string>
<key>MainClass</key>
<string>${mainClass}</string>
<key>JVMVersion</key>
<string>1.4+</string>
<key>ClassPath</key>
${classpath}
</dict>
</dict>
</plist>
答案 0 :(得分:2)
如果有人会从搜索引擎来到这里,这是我的解决方案。
切换到最新版本的插件:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>osxappbundle-maven-plugin</artifactId>
<version>1.0-alpha-2</version>
....
</plugin>
我使用了alpha-1并且遇到了同样的错误。