Skip to content

Commit 0202b7e

Browse files
author
gk_brown
committed
Simplify runtime specification by pointing runtime fileset at Contents/Home instead of runtime root; may also help facilitate cross-platform support since Windows runtimes don't have a Contents/Home folder.
git-svn-id: https://svn.java.net/svn/appbundler~svn@17 07572b26-92e5-4d45-f66a-c18421440a21
1 parent 405abc4 commit 0202b7e

File tree

3 files changed

+37
-35
lines changed

3 files changed

+37
-35
lines changed

appbundler/doc/appbundler.html

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -95,34 +95,34 @@ <h3>Parameters</h3>
9595
</tr>
9696
<tr>
9797
<td valign="top">mainclassname</td>
98-
<td valign="top">The name of the bundled application's main class.
99-
Corresponds to the <code>JVMMainClassName</code> key in the <tt>Info.plist</tt>
100-
file.</td>
98+
<td valign="top">The name of the bundled application's main class.</td>
10199
<td align="center" valign="top">Yes</td>
102100
</tr>
103101
</table>
104102

105103
<h3>Parameters specified as nested elements</h3>
106104
<h4>runtime</h4>
107105
<p>A <a href="http://ant.apache.org/manual/Types/fileset.html">fileset</a> representing the Java
108-
runtime to embed in the application. Corresponds to the <code>JVMRuntime</code> key in the
109-
<tt>Info.plist</tt> file.</p>
106+
runtime environment to embed in the application.</p>
110107

111-
<p>This element is optional. If specified, the runtime will be copied to the
112-
<tt>Contents/PlugIns/</tt> folder of the generated bundle. If omitted, the target system must
113-
have a shared JRE installed in <tt>/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/</tt>
114-
in order to run the application.</p>
108+
<p>This element is optional. If specified, the base directory of the fileset must point to the
109+
root directory of a valid Java runtime environment. The contents of the runtime will be copied to
110+
the <tt>Contents/PlugIns/</tt> folder of the generated application bundle. By default, the
111+
following content will be excluded from the bundled runtime:</p>
115112

116-
<p>By default, the following runtime content will be excluded from the generated bundle:<p>
117113
<ul>
118-
<li><tt>Contents/Home/bin/</tt></li>
119-
<li><tt>Contents/Home/jre/bin/</tt></li>
120-
<li><tt>Contents/Home/man/</tt></li>
121-
<li><tt>Contents/Home/src.zip</tt></li>
114+
<li><tt>bin/</tt></li>
115+
<li><tt>jre/bin/</tt></li>
116+
<li><tt>man/</tt></li>
117+
<li><tt>src.zip</tt></li>
122118
</ul>
123119

124120
<p>Additional content can be excluded using nested <code>&lt;excludes/&gt;</code> elements.</p>
125121

122+
<p>If this element is omitted, a Java runtime environment will not be copied into the generated
123+
bundle, and target systems must have a shared JRE installed in
124+
<tt>/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/</tt> in order to run the application.</p>
125+
126126
<h4>classpath</h4>
127127
<p>A <a href="http://ant.apache.org/manual/Types/fileset.html">fileset</a> representing the class
128128
path of the bundled application. Corresponds to the <tt>java.class.path</tt> system property.
@@ -166,8 +166,8 @@ <h4>argument</h4>
166166
<h3>Examples</h3>
167167
<p>Generate a launcher for the "Swing Set" demo, bundling the JRE defined by the <tt>JAVA_HOME</tt>
168168
environment variable with the resulting executable. In addition to the default excludes, the
169-
contents of the <tt>Contents/Home/db/</tt> and <tt>Contents/Home/lib/</tt> folders will also be
170-
excluded from the bundled runtime:</p>
169+
contents of the <tt>db/</tt> and <tt>lib/</tt> folders will also be excluded from the bundled
170+
runtime:</p>
171171
<pre>
172172
&lt;-- Import environment variables --&gt;
173173
&lt;property environment="env"/&gt;
@@ -183,9 +183,9 @@ <h3>Examples</h3>
183183
identifier="com.oracle.javax.swing.SwingSet2"
184184
shortversion="1.0"
185185
mainclassname="SwingSet2"&gt;
186-
&lt;runtime dir="${env.JAVA_HOME}/../.."/&gt;
187-
&lt;exclude name="Contents/Home/db/"/&gt;
188-
&lt;exclude name="Contents/Home/lib/"/&gt;
186+
&lt;runtime dir="${env.JAVA_HOME}"/&gt;
187+
&lt;exclude name="db/"/&gt;
188+
&lt;exclude name="lib/"/&gt;
189189
&lt;/runtime&gt;
190190
&lt;classpath file="/Library/Java/Demos/JFC/SwingSet2/SwingSet2.jar"/&gt;
191191
&lt;option value="-Dapple.laf.useScreenMenuBar=true"/&gt;

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

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,10 @@ public void addConfiguredRuntime(FileSet runtime) throws BuildException {
129129
this.runtime = runtime;
130130

131131
runtime.appendExcludes(new String[] {
132-
"Contents/MacOS/",
133-
"Contents/Info.plist",
134-
"Contents/Home/bin/",
135-
"Contents/Home/jre/bin/",
136-
"Contents/Home/man/",
137-
"Contents/Home/src.zip"
132+
"bin/",
133+
"jre/bin/",
134+
"man/",
135+
"src.zip"
138136
});
139137
}
140138

@@ -281,13 +279,15 @@ public void execute() throws BuildException {
281279

282280
private void copyRuntime(File plugInsDirectory) throws IOException {
283281
if (runtime != null) {
284-
// Create root directory
285-
File runtimeDirectory = runtime.getDir();
282+
File runtimeHomeDirectory = runtime.getDir();
283+
File runtimeContentsDirectory = runtimeHomeDirectory.getParentFile();
284+
File runtimeDirectory = runtimeContentsDirectory.getParentFile();
285+
286+
// Create root plug-in directory
286287
File pluginDirectory = new File(plugInsDirectory, runtimeDirectory.getName());
287288
pluginDirectory.mkdir();
288289

289290
// Create Contents directory
290-
File runtimeContentsDirectory = new File(runtimeDirectory, "Contents");
291291
File pluginContentsDirectory = new File(pluginDirectory, runtimeContentsDirectory.getName());
292292
pluginContentsDirectory.mkdir();
293293

@@ -300,13 +300,15 @@ private void copyRuntime(File plugInsDirectory) throws IOException {
300300
copy(runtimeInfoPlistFile, new File(pluginContentsDirectory, runtimeInfoPlistFile.getName()));
301301

302302
// Copy included contents of Home directory
303+
File pluginHomeDirectory = new File(pluginContentsDirectory, runtimeHomeDirectory.getName());
304+
303305
DirectoryScanner directoryScanner = runtime.getDirectoryScanner(getProject());
304306
String[] includedFiles = directoryScanner.getIncludedFiles();
305307

306308
for (int i = 0; i < includedFiles.length; i++) {
307309
String includedFile = includedFiles[i];
308-
File source = new File(runtimeDirectory, includedFile);
309-
File destination = new File(pluginDirectory, includedFile);
310+
File source = new File(runtimeHomeDirectory, includedFile);
311+
File destination = new File(pluginHomeDirectory, includedFile);
310312
copy(source, destination);
311313
}
312314
}
@@ -390,7 +392,7 @@ private void writeInfoPlist(File file) throws IOException {
390392

391393
// Write runtime
392394
if (runtime != null) {
393-
writeProperty(xout, "JVMRuntime", runtime.getDir().getName());
395+
writeProperty(xout, "JVMRuntime", runtime.getDir().getParentFile().getParentFile().getName());
394396
}
395397

396398
// Write main class name

build.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ questions.
124124
identifier="com.oracle.appbundler.Test"
125125
shortversion="1.0"
126126
mainclassname="Test">
127-
<runtime dir="${env.JAVA_HOME}/../.."/>
127+
<runtime dir="${env.JAVA_HOME}"/>
128128
<classpath dir="${ant.project.name}/${folder.classes}" includes="Test.class"/>
129129
<option value="-Xms32M"/>
130130
<option value="-Xmx256M"/>
@@ -142,9 +142,9 @@ questions.
142142
identifier="com.oracle.javax.swing.SwingSet2"
143143
shortversion="1.0"
144144
mainclassname="SwingSet2">
145-
<runtime dir="${env.JAVA_HOME}/../..">
146-
<exclude name="Contents/Home/db/"/>
147-
<exclude name="Contents/Home/lib/"/>
145+
<runtime dir="${env.JAVA_HOME}">
146+
<exclude name="db/"/>
147+
<exclude name="lib/"/>
148148
</runtime>
149149
<classpath file="/Library/Java/Demos/JFC/SwingSet2/SwingSet2.jar"/>
150150
<option value="-Dapple.laf.useScreenMenuBar=true"/>

0 commit comments

Comments
 (0)