java - Sådan distribueres en app på Mac?

Indlæg af Hanne Mølgaard Plasc

Problem



Hvad er den bedste måde at distribuere et program på en Mac på?


Hvad jeg gerne vil, er en build.xml, der, når den er bygget (i NetBeans), vil udstille en .exe (windows) og .app (mac) i dist mappen.


Jeg har for tiden en build.xml, der komprimerer programmet til en .zip-fil til distribution, men vil gerne tilføje en .app og .exe til mac og windows.


Her er min nuværende build.xml, der output til en zip-fil.


<?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>


Her er mit forsøg på at udlade en .app-fil. Den udsender en .app-fil, men viser en fejlmeddelelse hver gang jeg forsøger at køre den. (Selvom du har kørt det igen, udsender det ikke en .app-fil).


Jeg brugte Packaging a Java App til at oprette build.xml. [3]


<?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>


Indtast billedbeskrivelse her [4]

Bedste reference