Skip to content

Commit 9c660ba

Browse files
author
gk_brown
committed
Add support for the LSApplicationCategoryType key; set the initial working directory to the value of NSHomeDirectory() instead of the bundle root.
git-svn-id: https://svn.java.net/svn/appbundler~svn@21 07572b26-92e5-4d45-f66a-c18421440a21
1 parent 084f119 commit 9c660ba

File tree

4 files changed

+22
-5
lines changed

4 files changed

+22
-5
lines changed

appbundler/doc/appbundler.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,13 @@ <h3>Parameters</h3>
9393
file.</td>
9494
<td align="center" valign="top">No</td>
9595
</tr>
96+
<tr>
97+
<td valign="top">applicationCategory</td>
98+
<td valign="top">The application category.
99+
Corresponds to the <code>LSApplicationCategoryType</code> key in the <tt>Info.plist</tt>
100+
file.</td>
101+
<td align="center" valign="top">No</td>
102+
</tr>
96103
<tr>
97104
<td valign="top">mainclassname</td>
98105
<td valign="top">The name of the bundled application's main class.</td>

appbundler/native/main.m

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,8 @@ int launch(char *commandName) {
7272
// Get the main bundle
7373
NSBundle *mainBundle = [NSBundle mainBundle];
7474

75-
// Set the working directory to the main bundle root
76-
NSString *mainBundlePath = [mainBundle bundlePath];
77-
if (chdir([mainBundlePath UTF8String]) == -1) {
78-
[NSException raise:@JAVA_LAUNCH_ERROR format:@"Could not set initial working directory."];
79-
}
75+
// Set the working directory to the user's home directory
76+
chdir([NSHomeDirectory() UTF8String]);
8077

8178
// Get the main bundle's info dictionary
8279
NSDictionary *infoDictionary = [mainBundle infoDictionary];
@@ -114,6 +111,7 @@ int launch(char *commandName) {
114111
}
115112

116113
// Set the class path
114+
NSString *mainBundlePath = [mainBundle bundlePath];
117115
NSString *javaPath = [mainBundlePath stringByAppendingString:@"/Contents/Java"];
118116
NSMutableString *classPath = [NSMutableString stringWithFormat:@"-Djava.class.path=%@/Classes", javaPath];
119117

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ public class AppBundlerTask extends Task {
6565
private String signature = "????";
6666
private String copyright = "";
6767

68+
private String applicationCategory = null;
69+
6870
// JVM info properties
6971
private String mainClassName = null;
7072
private FileSet runtime = null;
@@ -117,6 +119,10 @@ public void setCopyright(String copyright) {
117119
this.copyright = copyright;
118120
}
119121

122+
public void setApplicationCategory(String applicationCategory) {
123+
this.applicationCategory = applicationCategory;
124+
}
125+
120126
public void setMainClassName(String mainClassName) {
121127
this.mainClassName = mainClassName;
122128
}
@@ -390,6 +396,10 @@ private void writeInfoPlist(File file) throws IOException {
390396
writeProperty(xout, "CFBundleVersion", "1");
391397
writeProperty(xout, "NSHumanReadableCopyright", copyright);
392398

399+
if (applicationCategory != null) {
400+
writeProperty(xout, "LSApplicationCategoryType", applicationCategory);
401+
}
402+
393403
// Write runtime
394404
if (runtime != null) {
395405
writeProperty(xout, "JVMRuntime", runtime.getDir().getParentFile().getParentFile().getName());

build.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ questions.
115115
displayname="SwingSet 2"
116116
identifier="com.oracle.javax.swing.SwingSet2"
117117
shortversion="1.0"
118+
applicationCategory="public.app-category.developer-tools"
118119
mainclassname="SwingSet2">
119120
<runtime dir="${env.JAVA_HOME}">
120121
<exclude name="db/"/>
@@ -135,6 +136,7 @@ questions.
135136
displayname="SwingSet 2 (Plugin)"
136137
identifier="com.oracle.javax.swing.SwingSet2Plugin"
137138
shortversion="1.0"
139+
applicationCategory="public.app-category.developer-tools"
138140
mainclassname="SwingSet2">
139141
<classpath file="/Library/Java/Demos/JFC/SwingSet2/SwingSet2.jar"/>
140142
<option value="-Dapple.laf.useScreenMenuBar=true"/>

0 commit comments

Comments
 (0)