Skip to content

Commit 1ba240e

Browse files
author
gk_brown
committed
Ensure that native libraries are properly copied to the generated bundle.
git-svn-id: https://svn.java.net/svn/appbundler~svn@11 07572b26-92e5-4d45-f66a-c18421440a21
1 parent ac012af commit 1ba240e

File tree

2 files changed

+41
-40
lines changed

2 files changed

+41
-40
lines changed

appbundler/doc/appbundler.html

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ <h3>Parameters</h3>
9898
<td valign="top">The Java runtime to embed in the bundle.
9999
Corresponds to the <code>JVMRuntime</code> key in the <tt>Info.plist</tt> file.
100100
If specified, the contents of this directory will be copied to the <tt>Contents/PlugIns/</tt>
101-
folder of the generated bundle.</td>
102-
<td align="center" valign="top">No; if unspecified, the target system must have a shared JRE
101+
folder of the generated bundle. If unspecified, the target system must have a shared JRE
103102
installed in <tt>/Library/Internet Plug-Ins/JavaAppletPlugin.plugin</tt>.</td>
103+
<td align="center" valign="top">No</tt></td>
104104
</tr>
105105
<tr>
106106
<td valign="top">mainclassname</td>
@@ -111,27 +111,28 @@ <h3>Parameters</h3>
111111
</tr>
112112
<tr>
113113
<td valign="top">classpath</td>
114-
<td valign="top">The classpath of the bundled application. If an entry refers to a directory,
115-
it will be recursively copied to the <tt>Contents/Java/Classes/</tt> folder of the generated
116-
bundle. Otherwise, the entryt will be copied to the <tt>Contents/Java/</tt> folder of the
117-
generated bundle.</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>
118119
<td align="center" valign="top">Yes, unless nested <code>&lt;classpath&gt;</code> elements are
119-
present.</td>
120+
present</td>
120121
</tr>
121122
<tr>
122-
<td valign="top">nativelibraries</td>
123-
<td valign="top">Any native libraries required by the bundled application. Entries will be
124-
copied to the <tt>Contents/Java/</tt> folder of the generated bundle.</td>
125-
<td align="center" valign="top">Yes, unless nested <code>&lt;nativelibraries&gt;</code> elements are
126-
present.</td>
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>
127128
</tr>
128129
</table>
129130

130131
<h3>Parameters specified as nested elements</h3>
131132
<h4>classpath</h4>
132-
<p>The <code>classpath</code> and <code>nativelibraries</code> attributes are
133+
<p>The <code>classpath</code> and <code>librarypath</code> attributes are
133134
<a href="http://ant.apache.org/manual/using.html#path">path-like structures</a> that can also be
134-
set via nested <code>&lt;classpath&gt;</code> and <code>&lt;nativelibraries&gt;</code> elements,
135+
set via nested <code>&lt;classpath&gt;</code> and <code>&lt;librarypath&gt;</code> elements,
135136
respectively.</p>
136137

137138
<h4>option</h4>

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

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -69,24 +69,23 @@ public class AppBundlerTask extends Task {
6969
private File runtime = null;
7070
private String mainClassName = null;
7171
private ArrayList<File> classPath = new ArrayList<>();
72-
private ArrayList<File> nativeLibraries = new ArrayList<>();
72+
private ArrayList<File> libraryPath = new ArrayList<>();
7373
private ArrayList<String> options = new ArrayList<>();
7474
private ArrayList<String> arguments = new ArrayList<>();
7575

76-
public static final String EXECUTABLE_NAME = "JavaAppLauncher";
77-
public static final String DEFAULT_ICON_NAME = "GenericApp.icns";
78-
public static final String OS_TYPE_CODE = "APPL";
79-
public static final String CLASS_EXTENSION = ".class";
76+
private static final String EXECUTABLE_NAME = "JavaAppLauncher";
77+
private static final String DEFAULT_ICON_NAME = "GenericApp.icns";
78+
private static final String OS_TYPE_CODE = "APPL";
8079

81-
public static final String PLIST_DTD = "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">";
82-
public static final String PLIST_TAG = "plist";
83-
public static final String PLIST_VERSION_ATTRIBUTE = "version";
84-
public static final String DICT_TAG = "dict";
85-
public static final String KEY_TAG = "key";
86-
public static final String ARRAY_TAG = "array";
87-
public static final String STRING_TAG = "string";
80+
private static final String PLIST_DTD = "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">";
81+
private static final String PLIST_TAG = "plist";
82+
private static final String PLIST_VERSION_ATTRIBUTE = "version";
83+
private static final String DICT_TAG = "dict";
84+
private static final String KEY_TAG = "key";
85+
private static final String ARRAY_TAG = "array";
86+
private static final String STRING_TAG = "string";
8887

89-
public static final int BUFFER_SIZE = 1024;
88+
private static final int BUFFER_SIZE = 1024;
9089

9190
public void setOutputDirectory(File outputDirectory) {
9291
this.outputDirectory = outputDirectory;
@@ -143,12 +142,15 @@ public void addConfiguredClassPath(FileSet classPath) {
143142
}
144143
}
145144

146-
public void addNativeLibrary(File nativeLibrary) throws BuildException {
147-
if (nativeLibrary.isDirectory()) {
148-
throw new BuildException("Native library cannot be a directory.");
149-
}
145+
public void addConfiguredLibraryPath(FileSet libraryPath) throws BuildException {
146+
File parent = libraryPath.getDir();
147+
148+
DirectoryScanner directoryScanner = libraryPath.getDirectoryScanner(getProject());
149+
String[] includedFiles = directoryScanner.getIncludedFiles();
150150

151-
nativeLibraries.add(nativeLibrary);
151+
for (int i = 0; i < includedFiles.length; i++) {
152+
this.libraryPath.add(new File(parent, includedFiles[i]));
153+
}
152154
}
153155

154156
public void addConfiguredOption(Option option) throws BuildException {
@@ -291,18 +293,16 @@ public void execute() throws BuildException {
291293

292294
// Copy class path entries to Java folder
293295
for (File entry : classPath) {
294-
String name = entry.getName();
295-
296-
if (entry.isDirectory() || name.endsWith(CLASS_EXTENSION)) {
297-
copy(entry, new File(classesDirectory, name));
296+
if (entry.isDirectory()) {
297+
copy(entry, new File(classesDirectory, entry.getName()));
298298
} else {
299-
copy(entry, new File(javaDirectory, name));
299+
copy(entry, new File(javaDirectory, entry.getName()));
300300
}
301301
}
302302

303-
// Copy native libraries to Java folder
304-
for (File nativeLibrary : nativeLibraries) {
305-
copy(nativeLibrary, new File(macOSDirectory, nativeLibrary.getName()));
303+
// Copy native libraries to MacOS folder
304+
for (File entry : libraryPath) {
305+
copy(entry, new File(macOSDirectory, entry.getName()));
306306
}
307307

308308
// Copy icon to Resources folder

0 commit comments

Comments
 (0)