@@ -127,6 +127,8 @@ public void addConfiguredRuntime(FileSet runtime) throws BuildException {
127
127
}
128
128
129
129
this .runtime = runtime ;
130
+
131
+ // TODO Add default excludes
130
132
}
131
133
132
134
public void addConfiguredClassPath (FileSet classPath ) {
@@ -214,14 +216,11 @@ public void execute() throws BuildException {
214
216
throw new IllegalStateException ("Main class name is required." );
215
217
}
216
218
217
- if (classPath .isEmpty ()) {
218
- throw new IllegalStateException ("Class path is required." );
219
- }
220
-
221
- // Create directory structure
219
+ // Create the app bundle
222
220
try {
223
221
System .out .println ("Creating app bundle: " + name );
224
222
223
+ // Create directory structure
225
224
File rootDirectory = new File (outputDirectory , name + ".app" );
226
225
delete (rootDirectory );
227
226
rootDirectory .mkdir ();
@@ -258,76 +257,92 @@ public void execute() throws BuildException {
258
257
executableFile .setExecutable (true );
259
258
260
259
// Copy runtime to PlugIns folder
261
- if (runtime != null ) {
262
- // Create root directory
263
- File runtimeDirectory = runtime .getDir ();
264
- File pluginDirectory = new File (plugInsDirectory , runtimeDirectory .getName ());
265
- pluginDirectory .mkdir ();
266
-
267
- // Create Contents directory
268
- File runtimeContentsDirectory = new File (runtimeDirectory , "Contents" );
269
- File pluginContentsDirectory = new File (pluginDirectory , runtimeContentsDirectory .getName ());
270
- pluginContentsDirectory .mkdir ();
271
-
272
- // Copy MacOS directory
273
- File runtimeMacOSDirectory = new File (runtimeContentsDirectory , "MacOS" );
274
- copy (runtimeMacOSDirectory , new File (pluginContentsDirectory , runtimeMacOSDirectory .getName ()));
275
-
276
- // Copy Info.plist file
277
- File runtimeInfoPlistFile = new File (runtimeContentsDirectory , "Info.plist" );
278
- copy (runtimeInfoPlistFile , new File (pluginContentsDirectory , runtimeInfoPlistFile .getName ()));
279
-
280
- // Copy included contents of Home directory
281
- DirectoryScanner directoryScanner = runtime .getDirectoryScanner (getProject ());
282
- String [] includedFiles = directoryScanner .getIncludedFiles ();
283
-
284
- for (int i = 0 ; i < includedFiles .length ; i ++) {
285
- String includedFile = includedFiles [i ];
286
- File source = new File (runtimeDirectory , includedFile );
287
- File destination = new File (pluginDirectory , includedFile );
288
- copy (source , destination );
289
- }
290
- }
260
+ copyRuntime (plugInsDirectory );
291
261
292
262
// Copy class path entries to Java folder
293
- for (FileSet fileSet : classPath ) {
294
- File classPathDirectory = fileSet .getDir ();
295
- DirectoryScanner directoryScanner = fileSet .getDirectoryScanner (getProject ());
296
- String [] includedFiles = directoryScanner .getIncludedFiles ();
297
-
298
- for (int i = 0 ; i < includedFiles .length ; i ++) {
299
- String includedFile = includedFiles [i ];
300
- File source = new File (classPathDirectory , includedFile );
301
- File destination = new File (javaDirectory , new File (includedFile ).getName ());
302
- copy (source , destination );
303
- }
304
- }
263
+ copyClassPathEntries (javaDirectory );
305
264
306
- // Copy native libraries to MacOS folder
307
- for (FileSet fileSet : libraryPath ) {
308
- File libraryPathDirectory = fileSet .getDir ();
309
- DirectoryScanner directoryScanner = fileSet .getDirectoryScanner (getProject ());
310
- String [] includedFiles = directoryScanner .getIncludedFiles ();
311
-
312
- for (int i = 0 ; i < includedFiles .length ; i ++) {
313
- String includedFile = includedFiles [i ];
314
- File source = new File (libraryPathDirectory , includedFile );
315
- File destination = new File (macOSDirectory , new File (includedFile ).getName ());
316
- copy (source , destination );
317
- }
318
- }
265
+ // Copy library path entries to MacOS folder
266
+ copyLibraryPathEntries (macOSDirectory );
319
267
320
268
// Copy icon to Resources folder
321
- if (icon == null ) {
322
- copy (getClass ().getResource (DEFAULT_ICON_NAME ), new File (resourcesDirectory , DEFAULT_ICON_NAME ));
323
- } else {
324
- copy (icon , new File (resourcesDirectory , icon .getName ()));
325
- }
269
+ copyIcon (resourcesDirectory );
326
270
} catch (IOException exception ) {
327
271
throw new BuildException (exception );
328
272
}
329
273
}
330
274
275
+ private void copyRuntime (File plugInsDirectory ) throws IOException {
276
+ if (runtime != null ) {
277
+ // Create root directory
278
+ File runtimeDirectory = runtime .getDir ();
279
+ File pluginDirectory = new File (plugInsDirectory , runtimeDirectory .getName ());
280
+ pluginDirectory .mkdir ();
281
+
282
+ // Create Contents directory
283
+ File runtimeContentsDirectory = new File (runtimeDirectory , "Contents" );
284
+ File pluginContentsDirectory = new File (pluginDirectory , runtimeContentsDirectory .getName ());
285
+ pluginContentsDirectory .mkdir ();
286
+
287
+ // Copy MacOS directory
288
+ File runtimeMacOSDirectory = new File (runtimeContentsDirectory , "MacOS" );
289
+ copy (runtimeMacOSDirectory , new File (pluginContentsDirectory , runtimeMacOSDirectory .getName ()));
290
+
291
+ // Copy Info.plist file
292
+ File runtimeInfoPlistFile = new File (runtimeContentsDirectory , "Info.plist" );
293
+ copy (runtimeInfoPlistFile , new File (pluginContentsDirectory , runtimeInfoPlistFile .getName ()));
294
+
295
+ // Copy included contents of Home directory
296
+ DirectoryScanner directoryScanner = runtime .getDirectoryScanner (getProject ());
297
+ String [] includedFiles = directoryScanner .getIncludedFiles ();
298
+
299
+ for (int i = 0 ; i < includedFiles .length ; i ++) {
300
+ String includedFile = includedFiles [i ];
301
+ File source = new File (runtimeDirectory , includedFile );
302
+ File destination = new File (pluginDirectory , includedFile );
303
+ copy (source , destination );
304
+ }
305
+ }
306
+ }
307
+
308
+ private void copyClassPathEntries (File javaDirectory ) throws IOException {
309
+ for (FileSet fileSet : classPath ) {
310
+ File classPathDirectory = fileSet .getDir ();
311
+ DirectoryScanner directoryScanner = fileSet .getDirectoryScanner (getProject ());
312
+ String [] includedFiles = directoryScanner .getIncludedFiles ();
313
+
314
+ for (int i = 0 ; i < includedFiles .length ; i ++) {
315
+ String includedFile = includedFiles [i ];
316
+ File source = new File (classPathDirectory , includedFile );
317
+ File destination = new File (javaDirectory , new File (includedFile ).getName ());
318
+ copy (source , destination );
319
+ }
320
+ }
321
+ }
322
+
323
+ private void copyLibraryPathEntries (File macOSDirectory ) throws IOException {
324
+ for (FileSet fileSet : libraryPath ) {
325
+ File libraryPathDirectory = fileSet .getDir ();
326
+ DirectoryScanner directoryScanner = fileSet .getDirectoryScanner (getProject ());
327
+ String [] includedFiles = directoryScanner .getIncludedFiles ();
328
+
329
+ for (int i = 0 ; i < includedFiles .length ; i ++) {
330
+ String includedFile = includedFiles [i ];
331
+ File source = new File (libraryPathDirectory , includedFile );
332
+ File destination = new File (macOSDirectory , new File (includedFile ).getName ());
333
+ copy (source , destination );
334
+ }
335
+ }
336
+ }
337
+
338
+ private void copyIcon (File resourcesDirectory ) throws IOException {
339
+ if (icon == null ) {
340
+ copy (getClass ().getResource (DEFAULT_ICON_NAME ), new File (resourcesDirectory , DEFAULT_ICON_NAME ));
341
+ } else {
342
+ copy (icon , new File (resourcesDirectory , icon .getName ()));
343
+ }
344
+ }
345
+
331
346
private void writeInfoPlist (File file ) throws IOException {
332
347
Writer out = new BufferedWriter (new FileWriter (file ));
333
348
XMLOutputFactory output = XMLOutputFactory .newInstance ();
0 commit comments