Skip to content

Commit ef575af

Browse files
committed
Take app name and identifier from main configuration
1 parent f8bf5ab commit ef575af

File tree

2 files changed

+22
-20
lines changed

2 files changed

+22
-20
lines changed

src/com/inet/gradle/setup/dmg/DmgBuilder.java

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@
5151
*/
5252
public class DmgBuilder extends AbstractBuilder<Dmg, SetupBuilder> {
5353

54-
private String applicationName, applicationIdentifier, imageSourceRoot, firstExecutableName;
54+
private String imageSourceRoot, firstExecutableName;
5555

5656
private SetupBuilder setup;
5757

58-
private TempPath tempPath;
58+
private TempPath tempPath;
5959

6060
/**
6161
* Create a new instance
@@ -99,13 +99,11 @@ public void build() throws RuntimeException {
9999
}
100100
}
101101

102-
applicationIdentifier = setup.getAppIdentifier();
103-
applicationName = setup.getApplication();
104102
imageSourceRoot = buildDir.toString(); // + "/" + setup.getApplication() + ".app";
105103

106104
// Just in case. If it still has not been set, we do not know what the user itends.
107105
if ( firstExecutableName == null ) {
108-
firstExecutableName = applicationName;
106+
firstExecutableName = setup.getApplication();
109107
}
110108

111109
if( !setup.getServices().isEmpty() ) {
@@ -232,7 +230,7 @@ private void createPackageFromApp() throws Throwable {
232230
createAndPatchDistributionXML();
233231

234232
imageSourceRoot = tempPath.get( "distribution" ).toString();
235-
File resultingPackage = new File( imageSourceRoot, applicationName + ".pkg" );
233+
File resultingPackage = new File( imageSourceRoot, setup.getApplication() + ".pkg" );
236234

237235
// Build Product for packaging
238236
ArrayList<String> command = new ArrayList<>();
@@ -253,7 +251,7 @@ private void createPackageFromApp() throws Throwable {
253251
}
254252

255253
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 );
257255
}
258256

259257
/**
@@ -268,7 +266,7 @@ private void extractApplicationInformation() throws IOException {
268266
command.add( "--analyze" );
269267
command.add( "--root" );
270268
command.add( buildDir.toString() );
271-
command.add( tempPath.getTempString( applicationIdentifier + ".plist" ) );
269+
command.add( tempPath.getTempString( setup.getAppIdentifier() + ".plist" ) );
272270
exec( command );
273271

274272
// set identifier, create package
@@ -277,7 +275,7 @@ private void extractApplicationInformation() throws IOException {
277275
command.add( "--root" );
278276
command.add( buildDir.toString() );
279277
command.add( "--component-plist" );
280-
command.add( tempPath.getTempString( applicationIdentifier + ".plist" ) );
278+
command.add( tempPath.getTempString( setup.getAppIdentifier() + ".plist" ) );
281279
command.add( "--identifier" );
282280
command.add( setup.getMainClass() != null ? setup.getMainClass() : setup.getAppIdentifier() );
283281
command.add( "--version" );
@@ -288,16 +286,16 @@ private void extractApplicationInformation() throws IOException {
288286

289287
// Application as default directory except there are more application parts to install.
290288
command.add( "/Applications/" + installationSubdirectory() );
291-
command.add( tempPath.getTempString( "packages", applicationName + ".pkg" ) );
289+
command.add( tempPath.getTempString( "packages", setup.getApplication() + ".pkg" ) );
292290
exec( command );
293291

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 );
295293
}
296294

297295
/**
298-
* Returns a subdirectory if needed because of the installation
296+
* Returns a sub directory if needed because of the installation
299297
*
300-
* @return subdirectory or ""
298+
* @return sub directory or ""
301299
*/
302300
private String installationSubdirectory() {
303301
return (setup.getServices().size() + setup.getDesktopStarters().size() > 1 ? setup.getApplication() + "/" : "");
@@ -315,7 +313,7 @@ private void createAndPatchDistributionXML() throws Throwable {
315313
command.add( "/usr/bin/productbuild" );
316314
command.add( "--synthesize" );
317315
command.add( "--package" );
318-
command.add( tempPath.getTempFile( "packages", applicationName + ".pkg" ).toString() );
316+
command.add( tempPath.getTempFile( "packages", setup.getApplication() + ".pkg" ).toString() );
319317
command.add( tempPath.getTempFile( "distribution.xml" ).toString() );
320318
exec( command );
321319

@@ -341,7 +339,7 @@ private void patchDistributionXML() throws Throwable {
341339

342340
// The title of the installer
343341
Element title = xmlFile.getOrCreateChild( distribution, "title" );
344-
xmlFile.addNodeText( title, applicationName );
342+
xmlFile.addNodeText( title, setup.getApplication() );
345343

346344
// Product node
347345
File backgroundImage = task.getSetupBackgroundImage();
@@ -424,7 +422,7 @@ private void createTempImage() {
424422
command.add( "-format" );
425423
command.add( "UDRW" );
426424
command.add( "-volname" );
427-
command.add( applicationName );
425+
command.add( setup.getApplication() );
428426
command.add( setup.getDestinationDir() + "/pack.temp.dmg" );
429427
exec( command );
430428
}
@@ -455,7 +453,7 @@ private void detach() {
455453
ArrayList<String> command = new ArrayList<>();
456454
command.add( "/usr/bin/hdiutil" );
457455
command.add( "detach" );
458-
command.add( tempPath.get() + "/" + applicationName );
456+
command.add( tempPath.get() + "/" + setup.getApplication() );
459457
exec( command );
460458
}
461459

@@ -467,7 +465,7 @@ private void detach() {
467465
private void setVolumeIcon() throws IOException {
468466

469467
// 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" );
471469
File icons = setup.getIconForType( buildDir, "icns" );
472470
if( icons == null ) {
473471
throw new IllegalArgumentException( "You have to specify a valid icon file" );
@@ -478,7 +476,7 @@ private void setVolumeIcon() throws IOException {
478476

479477
if( task.getBackgroundImage() != null ) {
480478
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( '.' ) ) );
482480
Files.createDirectories( backgroundDestination.getParentFile().toPath(), new FileAttribute[0] );
483481
Files.copy( task.getBackgroundImage().toPath(), backgroundDestination.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING );
484482
BufferedImage image = ImageIO.read( backgroundDestination );
@@ -535,7 +533,7 @@ private void packageApplescript() throws IOException {
535533

536534
Template applescript = new Template( "dmg/template/package.applescript.txt" );
537535
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() );
539537

540538
ArrayList<String> command = new ArrayList<>();
541539
command.add( "/usr/bin/osascript" );

src/com/inet/gradle/setup/dmg/template/applescript.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,12 @@ try
5151
end try
5252

5353
update without registering applications
54+
5455
close
56+
5557
open
58+
59+
close
5660
end tell
5761
end tell
5862
end try

0 commit comments

Comments
 (0)