简体   繁体   English

使用app bundler将Mac转换为Mac OSX App Bundle

[英]Jar to Mac OSX App Bundle with app bundler

I'm trying to bundle my .jar to a MacOSX app bundle, using app bundler . 我正在尝试使用app bundler将我的.jar捆绑到MacOSX应用包中。 I'm following this tutorial. 我正在学习本教程。

It says to add a lib folder to the high-level project directory, but I don't know what that means. 它说要将lib文件夹添加到高级项目目录中,但我不知道这意味着什么。 I've been looking everywhere for it, and I cannot find out what it is. 我一直在寻找它,我无法找到它是什么。 That's my only problem I have, anyone know? 这是我唯一的问题,有人知道吗?

EDIT: 编辑:

Here is my build.xml file: 这是我的build.xml文件:

<project name="Rage Mage" basedir=".">
<taskdef name="ragemage"
         classname="com.oracle.appbundler.AppBundlerTask"   
         classpath="lib/appbundler-1.0.jar" />

<target name="bundle-RageMage">
    <delete dir="appBundle" failonerror="false"/>
    <mkdir dir="appBundle"/>
    <bundleapp outputdirectory="bundle"
        name="Rage Mage"
        displayname="Rage Mage"
        icon="res/icon.icns"
        identifier="ragemage.src.Window"
        mainclassname="ragemage.src.Window">
        <classpath file="dist/ragemage_1.1.1.jar" />
    </bundleapp>
</target>

Thanks! 谢谢!

Okay, so, after having a little play around, this is what I understand... 好吧,所以,在玩了一下之后,这就是我所理解的......

The ant script should be based on the following skeleton... 蚂蚁脚本应该基于以下骨架......

<project name="ButtonDemo" default="bundle-buttonDemo" basedir=".">        
    <taskdef name="bundleapp"
             classname="com.oracle.appbundler.AppBundlerTask"   
             classpath="lib/appbundler-1.0.jar" />
    <!-- See the lib reference here, this is why you need to use the lib directory! -->

    <target name="bundle-buttonDemo">
        <delete dir="appBundle" failonerror="false"/>
        <mkdir dir="appBundle"/>
        <bundleapp outputdirectory="appBundle"
            name="ButtonDemo"
            displayname="Button Demo"
            identifier="components.ButtonDemo"
            mainclassname="components.ButtonDemo">
            <!-- The following is important and should point to your build -->
            <classpath file="dist/ButtonDemo.jar" />
            <!-- You can have multiple instance of classpath if you 3rd party or
                 dependent jars in different locations -->
        </bundleapp>
    </target>
</project>
  • Build your project 建立你的项目
  • Run the ant script, using (something like) ant -f {You App Bundler script} 运行ant脚本,使用(例如) ant -f {You App Bundler script}

The app bundle, in this case ButtonDemo.app will be created in appBundle directory. 应用程序包,在这种情况下, ButtonDemo.app将在appBundle目录中创建。 If you can, browse the contents of the ButtonDemo.app/Contents/Java and make sure all your required Jar files are there... 如果可以,浏览ButtonDemo.app/Contents/Java的内容并确保所有必需的Jar文件都在那里......

Happy bundling! 快乐捆绑!

Updated based on updated build.xml file 基于更新的build.xml文件进行了更新

1- There is no default target specified by the project tag. 1- project标签没有指定default目标。 Think of this like your "main class" or "main" method, without, ant has no idea what you want to run... 想想这就像你的“主类”或“主要”方法,没有,蚂蚁不知道你想要运行什么...

<project name="Rage Mage" basedir="." default="bundle-RageMage">

2- The name of the taskdef is significant and you use it in the any script to identify what ant should do when it hits your tag reference... 2- taskdefname很重要,您可以在任何脚本中使用它来识别当ant到达您的标记引用时应该做什么...

So based on your example, you either need to change the name of the taskdef from ragemage to bundleapp or change the bundleapp tag to ragemage ... 因此,根据您的示例,您需要将taskdef的名称从ragemage更改为bundleapp或将bundleapp标记更改为ragemage ...

Either change this... 要么改变这个......

<taskdef name="bundleapp"
     classname="com.oracle.appbundler.AppBundlerTask"   
     classpath="lib/appbundler-1.0.jar" />

or this (in target bundle-RageMage ) 或者这个(在目标bundle-RageMage

<ragemage outputdirectory="bundle"
    name="Rage Mage"
    displayname="Rage Mage"
    icon="res/icon.icns"
    identifier="ragemage.src.Window"
    mainclassname="ragemage.src.Window">
    <classpath file="dist/ragemage_1.1.1.jar" />
</ragemage>

Personally, I'd leave it as bundleapp , but that's me... 就个人而言,我会把它bundleapp ,但那就是我......

3- The delete , mkdir and outputdirectory attribute of bundleapp are related... 3- deletemkdiroutputdirectory的属性bundleapp相关...

<delete dir="appBundle" failonerror="false"/>
<mkdir dir="appBundle"/>
<bundleapp outputdirectory="bundle"...

Either, make them all appBundle or bundle , what every you want... 或者,将它们全部appBundlebundle ,你想要的每一个......

4- You main class is unlikely to be ragemage.src.Window and is probably going to be Window 4-你的主类不太可能是ragemage.src.Window ,可能是Window

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM