51
51
*/
52
52
public class DmgBuilder extends AbstractBuilder <Dmg , SetupBuilder > {
53
53
54
- private String applicationName , applicationIdentifier , imageSourceRoot , firstExecutableName ;
54
+ private String imageSourceRoot , firstExecutableName ;
55
55
56
56
private SetupBuilder setup ;
57
57
58
- private TempPath tempPath ;
58
+ private TempPath tempPath ;
59
59
60
60
/**
61
61
* Create a new instance
@@ -99,13 +99,11 @@ public void build() throws RuntimeException {
99
99
}
100
100
}
101
101
102
- applicationIdentifier = setup .getAppIdentifier ();
103
- applicationName = setup .getApplication ();
104
102
imageSourceRoot = buildDir .toString (); // + "/" + setup.getApplication() + ".app";
105
103
106
104
// Just in case. If it still has not been set, we do not know what the user itends.
107
105
if ( firstExecutableName == null ) {
108
- firstExecutableName = applicationName ;
106
+ firstExecutableName = setup . getApplication () ;
109
107
}
110
108
111
109
if ( !setup .getServices ().isEmpty () ) {
@@ -232,7 +230,7 @@ private void createPackageFromApp() throws Throwable {
232
230
createAndPatchDistributionXML ();
233
231
234
232
imageSourceRoot = tempPath .get ( "distribution" ).toString ();
235
- File resultingPackage = new File ( imageSourceRoot , applicationName + ".pkg" );
233
+ File resultingPackage = new File ( imageSourceRoot , setup . getApplication () + ".pkg" );
236
234
237
235
// Build Product for packaging
238
236
ArrayList <String > command = new ArrayList <>();
@@ -253,7 +251,7 @@ private void createPackageFromApp() throws Throwable {
253
251
}
254
252
255
253
packageApplescript ();
256
- Files .copy ( resultingPackage .toPath (), new File ( setup .getDestinationDir (), "/" + applicationName + ".pkg" ).toPath (), java .nio .file .StandardCopyOption .REPLACE_EXISTING );
254
+ Files .copy ( resultingPackage .toPath (), new File ( setup .getDestinationDir (), "/" + setup . getApplication () + ".pkg" ).toPath (), java .nio .file .StandardCopyOption .REPLACE_EXISTING );
257
255
}
258
256
259
257
/**
@@ -268,7 +266,7 @@ private void extractApplicationInformation() throws IOException {
268
266
command .add ( "--analyze" );
269
267
command .add ( "--root" );
270
268
command .add ( buildDir .toString () );
271
- command .add ( tempPath .getTempString ( applicationIdentifier + ".plist" ) );
269
+ command .add ( tempPath .getTempString ( setup . getAppIdentifier () + ".plist" ) );
272
270
exec ( command );
273
271
274
272
// set identifier, create package
@@ -277,7 +275,7 @@ private void extractApplicationInformation() throws IOException {
277
275
command .add ( "--root" );
278
276
command .add ( buildDir .toString () );
279
277
command .add ( "--component-plist" );
280
- command .add ( tempPath .getTempString ( applicationIdentifier + ".plist" ) );
278
+ command .add ( tempPath .getTempString ( setup . getAppIdentifier () + ".plist" ) );
281
279
command .add ( "--identifier" );
282
280
command .add ( setup .getMainClass () != null ? setup .getMainClass () : setup .getAppIdentifier () );
283
281
command .add ( "--version" );
@@ -288,16 +286,16 @@ private void extractApplicationInformation() throws IOException {
288
286
289
287
// Application as default directory except there are more application parts to install.
290
288
command .add ( "/Applications/" + installationSubdirectory () );
291
- command .add ( tempPath .getTempString ( "packages" , applicationName + ".pkg" ) );
289
+ command .add ( tempPath .getTempString ( "packages" , setup . getApplication () + ".pkg" ) );
292
290
exec ( command );
293
291
294
- Files .copy ( tempPath .getTempFile ( "packages" , applicationName + ".pkg" ).toPath (), new File ( setup .getDestinationDir (), "/" + applicationIdentifier + ".pkgbuild.pkg" ).toPath (), java .nio .file .StandardCopyOption .REPLACE_EXISTING );
292
+ Files .copy ( tempPath .getTempFile ( "packages" , setup . getApplication () + ".pkg" ).toPath (), new File ( setup .getDestinationDir (), "/" + setup . getAppIdentifier () + ".pkgbuild.pkg" ).toPath (), java .nio .file .StandardCopyOption .REPLACE_EXISTING );
295
293
}
296
294
297
295
/**
298
- * Returns a subdirectory if needed because of the installation
296
+ * Returns a sub directory if needed because of the installation
299
297
*
300
- * @return subdirectory or ""
298
+ * @return sub directory or ""
301
299
*/
302
300
private String installationSubdirectory () {
303
301
return (setup .getServices ().size () + setup .getDesktopStarters ().size () > 1 ? setup .getApplication () + "/" : "" );
@@ -315,7 +313,7 @@ private void createAndPatchDistributionXML() throws Throwable {
315
313
command .add ( "/usr/bin/productbuild" );
316
314
command .add ( "--synthesize" );
317
315
command .add ( "--package" );
318
- command .add ( tempPath .getTempFile ( "packages" , applicationName + ".pkg" ).toString () );
316
+ command .add ( tempPath .getTempFile ( "packages" , setup . getApplication () + ".pkg" ).toString () );
319
317
command .add ( tempPath .getTempFile ( "distribution.xml" ).toString () );
320
318
exec ( command );
321
319
@@ -341,7 +339,7 @@ private void patchDistributionXML() throws Throwable {
341
339
342
340
// The title of the installer
343
341
Element title = xmlFile .getOrCreateChild ( distribution , "title" );
344
- xmlFile .addNodeText ( title , applicationName );
342
+ xmlFile .addNodeText ( title , setup . getApplication () );
345
343
346
344
// Product node
347
345
File backgroundImage = task .getSetupBackgroundImage ();
@@ -424,7 +422,7 @@ private void createTempImage() {
424
422
command .add ( "-format" );
425
423
command .add ( "UDRW" );
426
424
command .add ( "-volname" );
427
- command .add ( applicationName );
425
+ command .add ( setup . getApplication () );
428
426
command .add ( setup .getDestinationDir () + "/pack.temp.dmg" );
429
427
exec ( command );
430
428
}
@@ -455,7 +453,7 @@ private void detach() {
455
453
ArrayList <String > command = new ArrayList <>();
456
454
command .add ( "/usr/bin/hdiutil" );
457
455
command .add ( "detach" );
458
- command .add ( tempPath .get () + "/" + applicationName );
456
+ command .add ( tempPath .get () + "/" + setup . getApplication () );
459
457
exec ( command );
460
458
}
461
459
@@ -467,7 +465,7 @@ private void detach() {
467
465
private void setVolumeIcon () throws IOException {
468
466
469
467
// Copy Icon as file icon into attached container
470
- File iconDestination = tempPath .getTempFile ( applicationName , ".VolumeIcon.icns" );
468
+ File iconDestination = tempPath .getTempFile ( setup . getApplication () , ".VolumeIcon.icns" );
471
469
File icons = setup .getIconForType ( buildDir , "icns" );
472
470
if ( icons == null ) {
473
471
throw new IllegalArgumentException ( "You have to specify a valid icon file" );
@@ -478,7 +476,7 @@ private void setVolumeIcon() throws IOException {
478
476
479
477
if ( task .getBackgroundImage () != null ) {
480
478
String name = task .getBackgroundImage ().getName ();
481
- File backgroundDestination = tempPath .getTempFile ( applicationName , "/.resources/background" + name .substring ( name .lastIndexOf ( '.' ) ) );
479
+ File backgroundDestination = tempPath .getTempFile ( setup . getApplication () , "/.resources/background" + name .substring ( name .lastIndexOf ( '.' ) ) );
482
480
Files .createDirectories ( backgroundDestination .getParentFile ().toPath (), new FileAttribute [0 ] );
483
481
Files .copy ( task .getBackgroundImage ().toPath (), backgroundDestination .toPath (), java .nio .file .StandardCopyOption .REPLACE_EXISTING );
484
482
BufferedImage image = ImageIO .read ( backgroundDestination );
@@ -535,7 +533,7 @@ private void packageApplescript() throws IOException {
535
533
536
534
Template applescript = new Template ( "dmg/template/package.applescript.txt" );
537
535
applescript .setPlaceholder ( "icon" , ImageFactory .getImageFile ( task .getProject (), task .getSetupIcon (), buildDir , "icns" ).getAbsolutePath () );
538
- applescript .setPlaceholder ( "package" , new File ( imageSourceRoot , applicationName + ".pkg" ).getAbsolutePath () );
536
+ applescript .setPlaceholder ( "package" , new File ( imageSourceRoot , setup . getApplication () + ".pkg" ).getAbsolutePath () );
539
537
540
538
ArrayList <String > command = new ArrayList <>();
541
539
command .add ( "/usr/bin/osascript" );
0 commit comments