Skip to content

Commit 68f500f

Browse files
author
gk_brown
committed
git-svn-id: https://svn.java.net/svn/appbundler~svn@12 07572b26-92e5-4d45-f66a-c18421440a21
1 parent 1ba240e commit 68f500f

File tree

4 files changed

+81
-54
lines changed

4 files changed

+81
-54
lines changed

appbundler/.classpath

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="src"/>
4+
<classpathentry kind="src" path="test"/>
5+
<classpathentry kind="lib" path="bin/appbundler-1.0ea.jar"/>
6+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
7+
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/Ant"/>
8+
<classpathentry kind="output" path="bin/classes"/>
9+
</classpath>

appbundler/.project

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>appbundler</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.jdt.core.javanature</nature>
16+
</natures>
17+
</projectDescription>

appbundler/doc/appbundler.html

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -93,47 +93,34 @@ <h3>Parameters</h3>
9393
file.</td>
9494
<td align="center" valign="top">No</td>
9595
</tr>
96-
<tr>
97-
<td valign="top">runtime</td>
98-
<td valign="top">The Java runtime to embed in the bundle.
99-
Corresponds to the <code>JVMRuntime</code> key in the <tt>Info.plist</tt> file.
100-
If specified, the contents of this directory will be copied to the <tt>Contents/PlugIns/</tt>
101-
folder of the generated bundle. If unspecified, the target system must have a shared JRE
102-
installed in <tt>/Library/Internet Plug-Ins/JavaAppletPlugin.plugin</tt>.</td>
103-
<td align="center" valign="top">No</tt></td>
104-
</tr>
10596
<tr>
10697
<td valign="top">mainclassname</td>
10798
<td valign="top">The name of the bundled application's main class.
10899
Corresponds to the <code>JVMMainClassName</code> key in the <tt>Info.plist</tt>
109100
file.</td>
110101
<td align="center" valign="top">Yes</td>
111102
</tr>
112-
<tr>
113-
<td valign="top">classpath</td>
114-
<td valign="top">The class path of the bundled application.
115-
Corresponds to the <tt>java.class.path</tt> system property.
116-
If an entry refers to a directory, it will be recursively copied to the
117-
<tt>Contents/Java/Classes/</tt> folder of the generated bundle. Otherwise, the entry will be
118-
copied to the <tt>Contents/Java/</tt> folder of the generated bundle.</td>
119-
<td align="center" valign="top">Yes, unless nested <code>&lt;classpath&gt;</code> elements are
120-
present</td>
121-
</tr>
122-
<tr>
123-
<td valign="top">librarypath</td>
124-
<td valign="top">The library path of the bundled application.
125-
Corresponds to the <tt>java.library.path</tt> system property.
126-
Entries will be copied to the <tt>Contents/MacOS/</tt> folder of the generated bundle.</td>
127-
<td align="center" valign="top">No</td>
128-
</tr>
129103
</table>
130104

131105
<h3>Parameters specified as nested elements</h3>
106+
<h4>runtime</h4>
107+
<p>A <a href="http://ant.apache.org/manual/Types/fileset.html">fileset</a> representing the Java
108+
runtime to embed in the bundle. Corresponds to the <code>JVMRuntime</code> key in the
109+
<tt>Info.plist</tt> file. If specified, the contents of this directory will be copied to the
110+
<tt>Contents/PlugIns/</tt> folder of the generated bundle. If unspecified, the target system must
111+
have a shared JRE installed in <tt>/Library/Internet Plug-Ins/JavaAppletPlugin.plugin</tt>.</p>
112+
132113
<h4>classpath</h4>
133-
<p>The <code>classpath</code> and <code>librarypath</code> attributes are
134-
<a href="http://ant.apache.org/manual/using.html#path">path-like structures</a> that can also be
135-
set via nested <code>&lt;classpath&gt;</code> and <code>&lt;librarypath&gt;</code> elements,
136-
respectively.</p>
114+
<p>A <a href="http://ant.apache.org/manual/Types/fileset.html">fileset</a> representing the class
115+
path of the bundled application. Corresponds to the <tt>java.class.path</tt> system property. If
116+
an entry refers to a directory, it will be recursively copied to the <tt>Contents/Java/Classes/</tt>
117+
folder of the generated bundle. Otherwise, the entry will be copied to the <tt>Contents/Java/</tt>
118+
folder of the generated bundle.</p>
119+
120+
<h4>librarypath</h4>
121+
<p>A <a href="http://ant.apache.org/manual/Types/fileset.html">fileset</a> representing the library
122+
path of the bundled application. Corresponds to the <tt>java.library.path</tt> system property.
123+
Entries will be copied to the <tt>Contents/MacOS/</tt> folder of the generated bundle.</p>
137124

138125
<h4>option</h4>
139126
<p>Specifies a command-line option to be passed to the JVM at startup.</p>
@@ -182,8 +169,8 @@ <h3>Examples</h3>
182169
displayname="SwingSet 2"
183170
identifier="com.oracle.javax.swing.SwingSet2"
184171
shortversion="1.0"
185-
runtime="${env.JAVA_HOME}/../.."
186172
mainclassname="SwingSet2"&gt;
173+
&lt;runtime dir="${env.JAVA_HOME}/../.."/&gt;
187174
&lt;classpath file="/Library/Java/Demos/JFC/SwingSet2/SwingSet2.jar"/&gt;
188175
&lt;option value="-Dapple.laf.useScreenMenuBar=true"/&gt;
189176
&lt;/bundleapp&gt;

appbundler/src/com/oracle/appbundler/AppBundlerTask.java

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ public class AppBundlerTask extends Task {
6666
private String copyright = "";
6767

6868
// JVM info properties
69-
private File runtime = null;
7069
private String mainClassName = null;
70+
private FileSet runtime = null;
7171
private ArrayList<File> classPath = new ArrayList<>();
7272
private ArrayList<File> libraryPath = new ArrayList<>();
7373
private ArrayList<String> options = new ArrayList<>();
@@ -85,8 +85,6 @@ public class AppBundlerTask extends Task {
8585
private static final String ARRAY_TAG = "array";
8686
private static final String STRING_TAG = "string";
8787

88-
private static final int BUFFER_SIZE = 1024;
89-
9088
public void setOutputDirectory(File outputDirectory) {
9189
this.outputDirectory = outputDirectory;
9290
}
@@ -119,16 +117,16 @@ public void setCopyright(String copyright) {
119117
this.copyright = copyright;
120118
}
121119

122-
public File getRuntime() {
123-
return runtime;
120+
public void setMainClassName(String mainClassName) {
121+
this.mainClassName = mainClassName;
124122
}
125123

126-
public void setRuntime(File runtime) {
127-
this.runtime = runtime;
128-
}
124+
public void addConfiguredRuntime(FileSet runtime) throws BuildException {
125+
if (this.runtime != null) {
126+
throw new BuildException("Runtime already specified.");
127+
}
129128

130-
public void setMainClassName(String mainClassName) {
131-
this.mainClassName = mainClassName;
129+
this.runtime = runtime;
132130
}
133131

134132
public void addConfiguredClassPath(FileSet classPath) {
@@ -142,7 +140,7 @@ public void addConfiguredClassPath(FileSet classPath) {
142140
}
143141
}
144142

145-
public void addConfiguredLibraryPath(FileSet libraryPath) throws BuildException {
143+
public void addConfiguredLibraryPath(FileSet libraryPath) {
146144
File parent = libraryPath.getDir();
147145

148146
DirectoryScanner directoryScanner = libraryPath.getDirectoryScanner(getProject());
@@ -226,16 +224,6 @@ public void execute() throws BuildException {
226224
throw new IllegalStateException("Copyright is required.");
227225
}
228226

229-
if (runtime != null) {
230-
if (!runtime.exists()) {
231-
throw new IllegalStateException("Runtime does not exist.");
232-
}
233-
234-
if (!runtime.isDirectory()) {
235-
throw new IllegalStateException("Invalid runtime.");
236-
}
237-
}
238-
239227
if (mainClassName == null) {
240228
throw new IllegalStateException("Main class name is required.");
241229
}
@@ -288,7 +276,31 @@ public void execute() throws BuildException {
288276

289277
// Copy runtime to PlugIns folder (if specified)
290278
if (runtime != null) {
291-
copy(runtime, new File(plugInsDirectory, runtime.getName()));
279+
// Create root directory
280+
File runtimeDirectory = runtime.getDir();
281+
File pluginDirectory = new File(plugInsDirectory, runtimeDirectory.getName());
282+
pluginDirectory.mkdir();
283+
284+
// Create Contents directory
285+
File runtimeContentsDirectory = new File(runtimeDirectory, "Contents");
286+
File pluginContentsDirectory = new File(pluginDirectory, runtimeContentsDirectory.getName());
287+
pluginContentsDirectory.mkdir();
288+
289+
// Copy MacOS directory
290+
File runtimeMacOSDirectory = new File(runtimeContentsDirectory, "MacOS");
291+
copy(runtimeMacOSDirectory, new File(pluginContentsDirectory, runtimeMacOSDirectory.getName()));
292+
293+
// Copy Info.plist file
294+
File runtimeInfoPlistFile = new File(runtimeContentsDirectory, "Info.plist");
295+
copy(runtimeInfoPlistFile, new File(pluginContentsDirectory, runtimeInfoPlistFile.getName()));
296+
297+
// Copy included contents of Home directory
298+
DirectoryScanner directoryScanner = runtime.getDirectoryScanner(getProject());
299+
String[] includedFiles = directoryScanner.getIncludedFiles();
300+
301+
for (int i = 0; i < includedFiles.length; i++) {
302+
copy(new File(runtimeDirectory, includedFiles[i]), new File(pluginDirectory, includedFiles[i]));
303+
}
292304
}
293305

294306
// Copy class path entries to Java folder
@@ -357,7 +369,7 @@ private void writeInfoPlist(File file) throws IOException {
357369

358370
// Write runtime
359371
if (runtime != null) {
360-
writeProperty(xout, "JVMRuntime", runtime.getName());
372+
writeProperty(xout, "JVMRuntime", runtime.getDir().getName());
361373
}
362374

363375
// Write main class name
@@ -465,6 +477,8 @@ private static void copy(File source, File destination) throws IOException {
465477
Path sourcePath = source.toPath();
466478
Path destinationPath = destination.toPath();
467479

480+
destination.getParentFile().mkdirs();
481+
468482
Files.copy(sourcePath, destinationPath, StandardCopyOption.REPLACE_EXISTING, LinkOption.NOFOLLOW_LINKS);
469483

470484
if (Files.isDirectory(sourcePath, LinkOption.NOFOLLOW_LINKS)) {

0 commit comments

Comments
 (0)