net.sourceforge.jarbundler
Class JarBundler

java.lang.Object
  extended by MatchingTask
      extended by net.sourceforge.jarbundler.JarBundler

public class JarBundler
extends MatchingTask

An ant task which creates a Mac OS X Application Bundle for a Java application.

dir
The directory into which to put the new application bundle.
name
The name of the application bundle. Note that the maximum length of this name is 16 characters, and it will be silently cropped if it is longer than this.
mainclass
The main Java class to call when running the application.

One of the following three MUST be used:

  1. jars Space or comma-separated list of JAR files to include.; OR
  2. One or more nested <jarfileset>s. These are normal ANT FileSets; OR
  3. One or more nested <jarfilelist>s. These are standard ANT FileLists.

Optional attributes:

The following attributes are not required, but you can use them to override default behavior.

verbose
If true, show more verbose output while running the task
version
Version information about your application (e.g., "1.0")
infostring
String to show in the "Get Info" dialog
These attributes control the fine-tuning of the "Mac OS X" look and feel.
arguments
Command line arguments. (no default)
smalltabs
Use small tabs. (default "false") Deprecated under JVM 1.4.1
antialiasedgraphics
Use anti-aliased graphics (default "false")
antialiasedtext
Use anti-aliased text (default "false")
bundleid
Unique identifier for this bundle, in the form of a Java package. No default.
buildnumber
Unique identifier for this build
developmentregion
Development Region. Default "English".
execs
Files to be copied into "Resources/MacOS" and made executable
liveresize
Use "Live resizing" (default "false") Deprecated under JVM 1.4.1
growbox
Show growbox (default "true")
growboxintrudes
Intruding growbox (default "false") Deprecated under JVM 1.4.1
screenmenu
Put swing menu into Mac OS X menu bar.
type
Bundle type (default "APPL")
signature
Bundle Signature (default "????")
stubfile
The Java Application Stub file to copy for your application (default MacOS system stub file)

Rarely used optional attributes.

chmod
Full path to the chmod command. This almost certainly does NOT need to be set.

The task also supports nested <execfileset> and/or <execfilelist> elements, and <resourcefileset> and/or <resourcefilelist> elements, which are standard Ant FileSet and FileList elements. In the first case, the referenced files are copied to the Contents/MacOS directory and made executable, and in the second they are copied to the Contents/Resources directory and not made executable. If you winrces, note that in fact the files are installed in locations which have the same relation to the Contents/Resources directory as the files in the FileSet or FileList have to the 'dir' attribute. Thus in the case:

   <resourcefileset dir="builddir/architectures"
                       includes="ppc/*.jnilib"/>
 

the *.jnilib files will be installed in Contents/Resources/ppc.

The task supports a nested <javaproperty> element, which allows you to specify further properties which are set for the JVM when the application is launched. This takes a required key attribute, giving the property key, plus an attribute giving the property value, which may be one of value, giving the string value of the property, file, setting the value of the property to be the absolute path of the given file, or path, which sets the value to the given path. If you are setting paths here, recall that, within the bundle, $APP_PACKAGE is set to the root directory of the bundle (ie, the path to the foo.app directory), and $JAVAROOT to the directory Contents/Resources/Java.

Minimum example:

  
    <jarbundler dir="release" name="Bar Project" mainclass="org.bar.Main"
        jars="bin/Bar.jar" />
 

Using Filesets

    <jarbundler dir="release" name="Bar Project" mainclass="org.bar.Main">
      <jarfileset dir="bin">
        <include name="*.jar" />
        <exclude name="test.jar" />
      </jarfileset>
      <execfileset dir="execs">
        <include name="**" />
      </execfileset>
    </jarbundler>
 

Much Longer example:

    <jarbundler dir="release"
                name="Foo Project"
                mainclass="org.bar.Main"
                version="1.0 b 1"
                infostring="Foo Project (c) 2002" 
                type="APPL"
                jars="bin/foo.jar bin/bar.jar"
                execs="exec/foobar"
                signature="????"
                workingdirectory="temp"
                icon="resources/foo.icns"
                jvmversion="1.4.1+"
                vmoptions="-Xmx256m"/>
 
http://developer.apple.com/documentation/MacOSX/Conceptual/BPRuntimeConfig/


Constructor Summary
JarBundler()
           
 
Method Summary
 void addConfiguredDocumentType(DocumentType documentType)
           
 void addConfiguredHelpBook(HelpBook helpBook)
           
 void addConfiguredJavaProperty(JavaProperty javaProperty)
          Nested tasks - new tasks with custom attributes
 void addConfiguredService(Service service)
           
 void addExecfilelist(FileList fl)
           
 void addExecfileset(FileSet fs)
           
 void addExtraclasspathfilelist(FileList fl)
           
 void addExtraclasspathfileset(FileSet fs)
           
 void addJarfilelist(FileList fl)
           
 void addJarfileset(FileSet fs)
          Nested tasks - derived from FileList and FileSet
 void addJavafilelist(FileList fl)
           
 void addJavafileset(FileSet fs)
           
 void addResourcefilelist(FileList fl)
           
 void addResourcefileset(FileSet fs)
           
 void execute()
          The method executing the task
 void setAboutmenuname(java.lang.String s)
          Setter for the "aboutmenuname" attribute (optional)
 void setAntialiasedgraphics(boolean b)
          Setter for the "antialiasedgraphics" attribute (optional)
 void setAntialiasedtext(boolean b)
          Setter for the "antialiasedtext" attribute (optional)
 void setArguments(java.lang.String s)
          Arguments to the
 void setBuild(java.lang.String s)
          Setter for the "buildnumber" attribute (optional) This key specifies the exact build version of the bundle.
 void setBundleid(java.lang.String s)
          Setter for the "bundleid" attribute (optional) This key specifies a unique identifier string for the bundle.
 void setChmod(java.lang.String s)
          Set the 'chmod' executable.
 void setDevelopmentregion(java.lang.String s)
          Setter for the "developmentregion" attribute(optional) Default "English".
 void setDir(java.io.File f)
          Setter for the "dir" attribute (required)
 void setExecs(java.lang.String s)
          Setter for the "execs" attribute (optional)
 void setExtraclasspath(java.lang.String s)
          Setter for the "extraclasspath" attribute (optional)
 void setGrowbox(boolean b)
          Setter for the "growbox" attribute (optional)
 void setGrowboxintrudes(boolean b)
          Setter for the "growboxintrudes" attribute (optional)
 void setHelpBookFolder(java.lang.String s)
           
 void setHelpBookName(java.lang.String s)
           
 void setIcon(java.io.File f)
          Setter for the "icon" attribute (optional)
 void setInfoString(java.lang.String s)
          Setter for the "infostring" attribute (optional) This key identifies a human-readable plain text string displaying the copyright information for the bundle.
 void setJar(java.io.File s)
          Setter for the "jar" attribute (required if no "jarfileset" is present)
 void setJars(java.lang.String s)
          Setter for the "jars" attribute (required if no "jarfileset" is present)
 void setJvmArchs(java.lang.String s)
          Setter for the "JVMArchs" attribute (optional)
 void setJvmversion(java.lang.String s)
          Setter for the "jvmversion" attribute (optional)
 void setLiveresize(boolean b)
          Setter for the "liveresize" attribute (optional)
 void setLSArchitecturePriority(java.lang.String s)
          Setter for the "LSArchitecturePriority" attribute (optional)
 void setMainClass(java.lang.String s)
          Setter for the "mainclass" attribute (required)
 void setName(java.lang.String s)
          Setter for the "name" attribute (required) This attribute names the output application bundle and asks as the CFBundleName if 'bundlename' is not specified
 void setScreenmenu(boolean b)
          Setter for the "screenmenu" attribute (optional)
 void setShortInfoString(java.lang.String s)
          Setter for the "shortinfostring" attribute (optional) This key identifies the marketing version of the bundle.
 void setShortName(java.lang.String s)
          Setter for the "shortname" attribute (optional) This key identifies the short name of the bundle.
 void setShowPlist(boolean showPlist)
           
 void setSignature(java.lang.String s)
          Setter for the "signature" attribute (optional)
 void setSmallTabs(boolean b)
          Setter for the "smalltabs" attribute (optional)
 void setSplashFile(java.lang.String s)
          Setter for the "splashfile" attribute (optional).
 void setStartonmainthread(boolean b)
          Setter for the "startonmainthread" attribute (optional)
 void setStubFile(java.io.File file)
          Override the stub file path to build on non-MacOS platforms
 void setType(java.lang.String s)
          Setter for the "type" attribute (optional)
 void setVerbose(boolean verbose)
          Setter for the "verbose" attribute (optional)
 void setVersion(java.lang.String s)
          Setter for the version attribute (optional).
 void setVmoptions(java.lang.String s)
          Setter for the "vmoptions" attribute (optional)
 void setWorkingDirectory(java.lang.String s)
          Setter for the "WorkingDirectory" attribute (optional)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JarBundler

public JarBundler()
Method Detail

setArguments

public void setArguments(java.lang.String s)
Arguments to the

Parameters:
s - The arguments to pass to the application being launched.

setStubFile

public void setStubFile(java.io.File file)
Override the stub file path to build on non-MacOS platforms

Parameters:
file - the path to the stub file

setDir

public void setDir(java.io.File f)
Setter for the "dir" attribute (required)


setName

public void setName(java.lang.String s)
Setter for the "name" attribute (required) This attribute names the output application bundle and asks as the CFBundleName if 'bundlename' is not specified


setShortName

public void setShortName(java.lang.String s)
Setter for the "shortname" attribute (optional) This key identifies the short name of the bundle. This name should be less than 16 characters long and be suitable for displaying in the menu and the About box. The name is (silently) cropped to this if necessary.


setMainClass

public void setMainClass(java.lang.String s)
Setter for the "mainclass" attribute (required)


setWorkingDirectory

public void setWorkingDirectory(java.lang.String s)
Setter for the "WorkingDirectory" attribute (optional)


setIcon

public void setIcon(java.io.File f)
Setter for the "icon" attribute (optional)


setSplashFile

public void setSplashFile(java.lang.String s)
Setter for the "splashfile" attribute (optional). If it is somewhere in a jar file, which contains a Splash-Screen manifest entry, use "$JAVAROOT/myjar.jar"


setBundleid

public void setBundleid(java.lang.String s)
Setter for the "bundleid" attribute (optional) This key specifies a unique identifier string for the bundle. This identifier should be in the form of a Java-style package name, for example com.mycompany.myapp. The bundle identifier can be used to locate the bundle at runtime. The preferences system uses this string to identify applications uniquely. No default.


setDevelopmentregion

public void setDevelopmentregion(java.lang.String s)
Setter for the "developmentregion" attribute(optional) Default "English".


setAboutmenuname

public void setAboutmenuname(java.lang.String s)
Setter for the "aboutmenuname" attribute (optional)


setSmallTabs

public void setSmallTabs(boolean b)
Setter for the "smalltabs" attribute (optional)


setVmoptions

public void setVmoptions(java.lang.String s)
Setter for the "vmoptions" attribute (optional)


setAntialiasedgraphics

public void setAntialiasedgraphics(boolean b)
Setter for the "antialiasedgraphics" attribute (optional)


setAntialiasedtext

public void setAntialiasedtext(boolean b)
Setter for the "antialiasedtext" attribute (optional)


setScreenmenu

public void setScreenmenu(boolean b)
Setter for the "screenmenu" attribute (optional)


setGrowbox

public void setGrowbox(boolean b)
Setter for the "growbox" attribute (optional)


setGrowboxintrudes

public void setGrowboxintrudes(boolean b)
Setter for the "growboxintrudes" attribute (optional)


setLiveresize

public void setLiveresize(boolean b)
Setter for the "liveresize" attribute (optional)


setType

public void setType(java.lang.String s)
Setter for the "type" attribute (optional)


setSignature

public void setSignature(java.lang.String s)
Setter for the "signature" attribute (optional)


setJvmversion

public void setJvmversion(java.lang.String s)
Setter for the "jvmversion" attribute (optional)


setJvmArchs

public void setJvmArchs(java.lang.String s)
Setter for the "JVMArchs" attribute (optional)


setLSArchitecturePriority

public void setLSArchitecturePriority(java.lang.String s)
Setter for the "LSArchitecturePriority" attribute (optional)


setStartonmainthread

public void setStartonmainthread(boolean b)
Setter for the "startonmainthread" attribute (optional)


setInfoString

public void setInfoString(java.lang.String s)
Setter for the "infostring" attribute (optional) This key identifies a human-readable plain text string displaying the copyright information for the bundle. The Finder displays this information in the Info window of the bundle. (This string was also known as the long version string in Mac OS 9). The format of the key should be of the following format: "© Great Software, Inc, 1999". You can localize this string by including it in the InfoPlist.strings file of the appropriate .lproj directory.


setShortInfoString

public void setShortInfoString(java.lang.String s)
Setter for the "shortinfostring" attribute (optional) This key identifies the marketing version of the bundle. The marketing version is a string that usually displays the major and minor version of the bundle. This string is usually of the form n.n.n where n is a number. The first number is the major version number of the bundle. The second and third numbers are minor revision numbers. You may omit minor revision numbers as appropriate. The value of this key is displayed in the default About box for Cocoa applications. The value for this key differs from the value for "CFBundleVersion", which identifies a specific build number. The CFBundleShortVersionString value represents a more formal version that does not change with every build.


setVerbose

public void setVerbose(boolean verbose)
Setter for the "verbose" attribute (optional)


setShowPlist

public void setShowPlist(boolean showPlist)

setBuild

public void setBuild(java.lang.String s)
Setter for the "buildnumber" attribute (optional) This key specifies the exact build version of the bundle. This string is usually of the form nn.n.nxnnn where n is a digit and x is a character from the set [abdf]. The first number is the major version number of the bundle and can contain one or two digits to represent a number in the range 0-99. The second and third numbers are minor revision numbers and must be a single numeric digit. The fourth set of digits is the specific build number for the release. You may omit minor revision and build number information as appropriate. You may also omit major and minor revision information and specify only a build number. For example, valid version numbers include: 1.0.1, 1.2.1b10, 1.2d200, d125, 101, and 1.0. The value of this key typically changes between builds and is displayed in the Cocoa About panel in parenthesis. To specify the version information of a released bundle, use the CFBundleShortVersionString key.


setVersion

public void setVersion(java.lang.String s)
Setter for the version attribute (optional). It is this property, not CFBundleVersion, which should receive the `short' version string. See for example


setHelpBookFolder

public void setHelpBookFolder(java.lang.String s)

setHelpBookName

public void setHelpBookName(java.lang.String s)

setJars

public void setJars(java.lang.String s)
Setter for the "jars" attribute (required if no "jarfileset" is present)


setJar

public void setJar(java.io.File s)
Setter for the "jar" attribute (required if no "jarfileset" is present)


setExecs

public void setExecs(java.lang.String s)
Setter for the "execs" attribute (optional)


setExtraclasspath

public void setExtraclasspath(java.lang.String s)
Setter for the "extraclasspath" attribute (optional)


setChmod

public void setChmod(java.lang.String s)
Set the 'chmod' executable.


addJarfileset

public void addJarfileset(FileSet fs)
Nested tasks - derived from FileList and FileSet


addJarfilelist

public void addJarfilelist(FileList fl)

addExecfileset

public void addExecfileset(FileSet fs)

addExecfilelist

public void addExecfilelist(FileList fl)

addResourcefileset

public void addResourcefileset(FileSet fs)

addResourcefilelist

public void addResourcefilelist(FileList fl)

addJavafileset

public void addJavafileset(FileSet fs)

addJavafilelist

public void addJavafilelist(FileList fl)

addExtraclasspathfileset

public void addExtraclasspathfileset(FileSet fs)

addExtraclasspathfilelist

public void addExtraclasspathfilelist(FileList fl)

addConfiguredJavaProperty

public void addConfiguredJavaProperty(JavaProperty javaProperty)
                               throws BuildException
Nested tasks - new tasks with custom attributes

Throws:
BuildException

addConfiguredDocumentType

public void addConfiguredDocumentType(DocumentType documentType)
                               throws BuildException
Throws:
BuildException

addConfiguredService

public void addConfiguredService(Service service)

addConfiguredHelpBook

public void addConfiguredHelpBook(HelpBook helpBook)

execute

public void execute()
             throws BuildException
The method executing the task

Throws:
BuildException