目前在Mac上分发应用程序的最佳方法是什么?
我想要的是build.xml,当构建(在NetBeans中)时,会将.exe(windows)和.app(mac)输出到dist文件夹中。
我目前有一个build.xml,可以将程序压缩成.zip文件进行分发,但是想为mac和windows添加.app和.exe。
这是我当前的build.xml输出到zip文件。
<?xml version="1.0" encoding="UTF-8"?>
<project name="name" default="default" basedir=".">
<description></description>
<import file="nbproject/build-impl.xml"/>
<property file="version.properties"/>
<property name="version" value="${version.major}.${version.minor}.${version.patch}" />
<property name="executable.name" value="company-${version.product.name}-${version}" />
<target name="-post-jar" description="Generates a versioned name for the JAR file">
<mkdir dir="LOGS" />
<move file="dist/${ant.project.name}.jar" tofile="dist/${executable.name}.jar" />
<antcall target="generate-run-scripts" />
<antcall target="deliverable-osx" />
<antcall target="deliverable-windows" />
</target>
<target name="generate-run-scripts" description="Generate batch files to run the application">
<echo file="dist/run.bat">
java -cp ${executable.name}.jar -Djava.util.logging.config.file=logging.properties -Xmx2048m -Dcom.sun.management.jmxremote classname
</echo>
<echo file="dist/run.sh">#!/bin/sh
java -cp ${executable.name}.jar -Djava.util.logging.config.file=logging.properties -Xmx2048m -Dcom.sun.management.jmxremote classname
</echo>
</target>
<target name="deliverable-windows" description="Deployment files for Windows runtime">
<property name="zip.name" value="Project-${version}-windows" />
<zip destfile="dist/${zip.name}.zip">
<zipfileset file="dist/${executable.name}.jar" />
<zipfileset file="logging.properties"/>
<zipfileset dir="dist/lib" includes="*.jar" prefix="lib" />
<zipfileset file="dist/run.bat"/>
<zipfileset dir="LOGS" excludes="*" />
<zipfileset dir="files" excludes="*" />
<zipfileset file="changelog.txt"/>
</zip>
</target>
<target name="deliverable-osx" description="Deployment files for Apple OS-X runtime">
<property name="zip.name" value="Project-${version}-OSX" />
<zip destfile="dist/${zip.name}.zip">
<zipfileset file="dist/${executable.name}.jar" />
<zipfileset file="logging.properties"/>
<zipfileset dir="dist/lib" includes="*.jar" prefix="lib" />
<zipfileset file="dist/run.sh" filemode="755" />
<zipfileset dir="LOGS" excludes="*" />
<zipfileset dir="files" excludes="*" />
<zipfileset file="changelog.txt"/>
</zip>
</target>
</project>
这是我尝试输出.app文件。它输出.app文件,但每次我尝试运行它时都会显示一条错误消息。 (虽然再次运行后它甚至没有输出.app文件)。
我使用Packaging a Java App来创建build.xml。
<?xml version="1.0" encoding="UTF-8"?>
<project name="name" default="default" basedir=".">
<description></description>
<import file="nbproject/build-impl.xml"/>
<property file="version.properties"/>
<property name="version" value="${version.major}.${version.minor}.${version.patch}" />
<property name="executable.name" value="company-${version.product.name}-${version}" />
<property environment="env" />
<taskdef name="bundleapp"
classname="com.oracle.appbundler.AppBundlerTask"
classpath="lib/appbundler-1.0.jar" />
<target name="ai_debug">
<bundleapp outputdirectory="dist"
name="Project"
displayname="Project-${version}"
identifier="classname"
mainclassname="classname">
<runtime dir="${java.home}" />
<classpath file="dist/Project.jar"/>
</bundleapp>
</target>
</project>