1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.ninjasoft.macpackager;
18
19 import java.io.*;
20 import java.util.*;
21 import org.apache.tools.ant.*;
22 import org.apache.tools.ant.types.FileSet;
23
24 /***
25 * Ant task that will create a Mac OS X application bundle.
26 * This task expects a nested fileset of *.jar files
27 *
28 * Requires: jar files (in nested fileset)
29 * BundleName - Name of application
30 * Version - Application version
31 * InfoString - Name, version, copyright information
32 * Icon file - *.icns file containing application icon(s)
33 * VM Options - Optional things to pass to the VM (name in app menu, shiny metal look, etc)
34 * mainclass - main class
35 *
36 * Derives: BundleIdentifier: from mainclass + version
37 *
38 * @author Brian Enigma
39 */
40 public AntMacPackager extends Task {/package-summary.html">class AntMacPackager extends Task {
41 private MacPackager macPackager = new MacPackager()/package-summary.html">ong> MacPackager macPackager = new MacPackager();
42 protected Vector filesets = new Vector();
43
44 private void loadNestedFileSets() {
45 for (Iterator i = this.filesets.iterator(); i.hasNext(); ) {
46 FileSet fileset = (FileSet) i.next();
47 DirectoryScanner scanner = null;
48 scanner = fileset.getDirectoryScanner(getProject());
49 File fromDir = fileset.getDir(getProject());
50 String[] srcFiles = scanner.getIncludedFiles();
51 for (int j=0; j<srcFiles.length; j++)
52 macPackager.addJar(fromDir + "/" + srcFiles[j]);
53 }
54 }
55
56 public void execute() throws BuildException {
57
58 loadNestedFileSets();
59 try{
60 macPackager.buildApplication();
61 }catch(PackageException e){/package-summary.html">rong>(PackageException e){
62 throw new BuildException(e);
63 }
64 }
65
66
67
68 public void addFileset(FileSet fileset) {
69 this.filesets.add(fileset);
70 }
71
72 public void setIcon(String icon) {
73 macPackager.setIcon(icon);
74 }
75 public void setInfoString(String infoString) {
76 macPackager.setInfoString(infoString);
77 }
78 public void setMainClass(String mainClass) {
79 macPackager.setMainClass(mainClass);
80 }
81 public void setVersion(String version) {
82 macPackager.setVersion(version);
83 }
84 public void setVmOptions(String vmOptions) {
85 macPackager.setVmOptions(vmOptions);
86 }
87 public void setAppName(String appName) {
88 macPackager.setAppName(appName);
89 }
90 }