@@ -69,24 +69,23 @@ public class AppBundlerTask extends Task {
69
69
private File runtime = null ;
70
70
private String mainClassName = null ;
71
71
private ArrayList <File > classPath = new ArrayList <>();
72
- private ArrayList <File > nativeLibraries = new ArrayList <>();
72
+ private ArrayList <File > libraryPath = new ArrayList <>();
73
73
private ArrayList <String > options = new ArrayList <>();
74
74
private ArrayList <String > arguments = new ArrayList <>();
75
75
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" ;
80
79
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" ;
88
87
89
- public static final int BUFFER_SIZE = 1024 ;
88
+ private static final int BUFFER_SIZE = 1024 ;
90
89
91
90
public void setOutputDirectory (File outputDirectory ) {
92
91
this .outputDirectory = outputDirectory ;
@@ -143,12 +142,15 @@ public void addConfiguredClassPath(FileSet classPath) {
143
142
}
144
143
}
145
144
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 ();
150
150
151
- nativeLibraries .add (nativeLibrary );
151
+ for (int i = 0 ; i < includedFiles .length ; i ++) {
152
+ this .libraryPath .add (new File (parent , includedFiles [i ]));
153
+ }
152
154
}
153
155
154
156
public void addConfiguredOption (Option option ) throws BuildException {
@@ -291,18 +293,16 @@ public void execute() throws BuildException {
291
293
292
294
// Copy class path entries to Java folder
293
295
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 ()));
298
298
} else {
299
- copy (entry , new File (javaDirectory , name ));
299
+ copy (entry , new File (javaDirectory , entry . getName () ));
300
300
}
301
301
}
302
302
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 ()));
306
306
}
307
307
308
308
// Copy icon to Resources folder
0 commit comments