@@ -139,7 +139,12 @@ public void addConfiguredClassPath(FileSet classPath) {
139139 String [] includedFiles = directoryScanner .getIncludedFiles ();
140140
141141 for (int i = 0 ; i < includedFiles .length ; i ++) {
142- this .classPath .add (new File (parent , includedFiles [i ]));
142+ File entry = new File (parent , includedFiles [i ]);
143+ if (entry .isDirectory ()) {
144+ throw new BuildException ("Class path entry cannot be a directory." );
145+ }
146+
147+ this .classPath .add (entry );
143148 }
144149 }
145150
@@ -259,25 +264,12 @@ public void execute() throws BuildException {
259264 File javaDirectory = new File (contentsDirectory , "Java" );
260265 javaDirectory .mkdir ();
261266
262- File classesDirectory = new File (javaDirectory , "Classes" );
263- classesDirectory .mkdir ();
264-
265267 File plugInsDirectory = new File (contentsDirectory , "PlugIns" );
266268 plugInsDirectory .mkdir ();
267269
268270 File resourcesDirectory = new File (contentsDirectory , "Resources" );
269271 resourcesDirectory .mkdir ();
270272
271- // Generate Info.plist
272- File infoPlistFile = new File (contentsDirectory , "Info.plist" );
273- infoPlistFile .createNewFile ();
274- writeInfoPlist (infoPlistFile );
275-
276- // Generate PkgInfo
277- File pkgInfoFile = new File (contentsDirectory , "PkgInfo" );
278- pkgInfoFile .createNewFile ();
279- writePkgInfo (pkgInfoFile );
280-
281273 // Copy executable to MacOS folder
282274 File executableFile = new File (macOSDirectory , EXECUTABLE_NAME );
283275 copy (getClass ().getResource (EXECUTABLE_NAME ), executableFile );
@@ -291,20 +283,25 @@ public void execute() throws BuildException {
291283
292284 // Copy class path entries to Java folder
293285 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 ));
298- } else {
299- copy (entry , new File (javaDirectory , name ));
300- }
286+ // TODO Don't copy if in JRE
287+ copy (entry , new File (javaDirectory , entry .getName ()));
301288 }
302289
303- // Copy native libraries to Java folder
290+ // Copy native libraries to MacOS folder
304291 for (File nativeLibrary : nativeLibraries ) {
305- copy (nativeLibrary , new File (javaDirectory , nativeLibrary .getName ()));
292+ copy (nativeLibrary , new File (macOSDirectory , nativeLibrary .getName ()));
306293 }
307294
295+ // Generate Info.plist
296+ File infoPlistFile = new File (contentsDirectory , "Info.plist" );
297+ infoPlistFile .createNewFile ();
298+ writeInfoPlist (infoPlistFile );
299+
300+ // Generate PkgInfo
301+ File pkgInfoFile = new File (contentsDirectory , "PkgInfo" );
302+ pkgInfoFile .createNewFile ();
303+ writePkgInfo (pkgInfoFile );
304+
308305 // Copy icon to Resources folder
309306 if (icon == null ) {
310307 copy (getClass ().getResource (DEFAULT_ICON_NAME ), new File (resourcesDirectory ,
@@ -363,6 +360,20 @@ private void writeInfoPlist(File file) throws IOException {
363360 // Write main class name
364361 writeProperty (xout , "JVMMainClassName" , mainClassName );
365362
363+ // Write class path
364+ writeKey (xout , "JVMClassPath" );
365+
366+ xout .writeStartElement (ARRAY_TAG );
367+ xout .writeCharacters ("\n " );
368+
369+ for (File entry : classPath ) {
370+ // TODO Write appropriate path based on location
371+ writeString (xout , "Contents/Java/" + entry .getName ());
372+ }
373+
374+ xout .writeEndElement ();
375+ xout .writeCharacters ("\n " );
376+
366377 // Write options
367378 writeKey (xout , "JVMOptions" );
368379
0 commit comments