Skip to content

Commit 56ed5ab

Browse files
committed
U creates application link directly in mounted volume on mac os
1 parent c245867 commit 56ed5ab

File tree

3 files changed

+11
-36
lines changed

3 files changed

+11
-36
lines changed

docs/macosx-specific-properties.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@
33
```xml
44
<macConfig>
55
<!-- general properties -->
6-
<appId>app unique identifier</appId>
6+
<appId>app unique identifier</appId>
77
<icnsFile>path/to/icon.icns</icnsFile>
88
<generateDmg>true|false</generateDmg>
99
<generatePkg>true|false</generatePkg>
1010
<relocateJar>true|false</relocateJar>
11-
<removeApplicationLink>true|false</removeApplicationLink>
1211
<!-- signing properties -->
13-
<developerId>singning identity</developerId>
14-
<entitlements>path/to/entitlements.plist</entitlements>
12+
<developerId>singning identity</developerId>
13+
<entitlements>path/to/entitlements.plist</entitlements>
1514
<!-- properties used in DMG disk image generation -->
1615
<backgroundImage>path/to/png</backgroundImage>
1716
<windowX>x</windowX>
@@ -35,13 +34,10 @@
3534
| `generateDmg` | :x: | `true` | Enables DMG disk image file generation. |
3635
| `generatePkg` | :x: | `true` | Enables installation package generation. |
3736
| `relocateJar` | :x: | `true` | If `true`, Jar files are located in `Contents/Resources/Java` folder, otherwise they are located in `Contents/Resources` folder. |
38-
|
39-
| `removeApplicationLink` | :x: | `removeApplicationLink` | If `true`, application link in build folder shall be removed after build. |
4037
| `appId` | :x: | `${mainClass}` | App unique identifier. |
4138
| `developerId` | :x: | `null` | Signing identity. |
4239
| `entitlements` | :x: | `null` | Path to [entitlements](https://developer.apple.com/documentation/bundleresources/entitlements) file. |
4340

44-
4541
## DMG generation properties
4642

4743
| Property | Mandatory | Default value | Description |

src/main/java/io/github/fvarrui/javapackager/model/MacConfig.java

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ public class MacConfig implements Serializable {
2727
private boolean generateDmg = true;
2828
private boolean generatePkg = true;
2929
private boolean relocateJar = true;
30-
private boolean removeApplicationLink = true;
3130
private String appId;
3231
private String developerId = "-";
3332
private File entitlements;
@@ -168,14 +167,6 @@ public void setRelocateJar(boolean relocateJar) {
168167
this.relocateJar = relocateJar;
169168
}
170169

171-
public boolean isRemoveApplicationLink() {
172-
return removeApplicationLink;
173-
}
174-
175-
public void setRemoveApplicationLink(boolean removeApplicationLink) {
176-
this.removeApplicationLink = removeApplicationLink;
177-
}
178-
179170
public String getAppId() {
180171
return appId;
181172
}
@@ -207,9 +198,7 @@ public String toString() {
207198
+ ", iconSize=" + iconSize + ", textSize=" + textSize + ", iconX=" + iconX + ", iconY=" + iconY
208199
+ ", appsLinkIconX=" + appsLinkIconX + ", appsLinkIconY=" + appsLinkIconY + ", volumeIcon=" + volumeIcon
209200
+ ", volumeName=" + volumeName + ", generateDmg=" + generateDmg + ", generatePkg=" + generatePkg
210-
+ ", relocateJar=" + relocateJar
211-
+ ", removeApplicationLink=" + removeApplicationLink
212-
+ ", appId=" + appId + ", developerId=" + developerId
201+
+ ", relocateJar=" + relocateJar + ", appId=" + appId + ", developerId=" + developerId
213202
+ ", entitlements=" + entitlements + "]";
214203
}
215204

src/main/java/io/github/fvarrui/javapackager/packagers/GenerateDmg.java

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,6 @@ public File apply(Packager packager) throws Exception {
5959
// mount dir
6060
File mountFolder = new File("/Volumes/" + volumeName);
6161

62-
// creates a symlink to Applications folder
63-
Logger.info("Creating Applications link");
64-
File targetFolder = new File("/Applications");
65-
File linkFile = new File(appFolder, "Applications");
66-
FileUtils.createSymlink(linkFile, targetFolder);
67-
6862
// copies background file
6963
Logger.info("Copying background image");
7064
File backgroundFolder = FileUtils.mkdir(appFolder, ".background");
@@ -102,7 +96,13 @@ public File apply(Packager packager) throws Exception {
10296
// pause to prevent occasional "Can't get disk" (-1728) issues
10397
// https://github.com/seltzered/create-dmg/commit/5fe7802917bb85b40c0630b026d33e421db914ea
10498
ThreadUtils.sleep(2000L);
105-
99+
100+
// creates a symlink to Applications folder
101+
Logger.info("Creating Applications link");
102+
File targetFolder = new File("/Applications");
103+
File linkFile = new File(mountFolder, "Applications");
104+
FileUtils.createSymlink(linkFile, targetFolder);
105+
106106
// renders applescript
107107
Logger.info("Rendering DMG customization applescript ... ");
108108
File applescriptFile = new File(assetsFolder, "customize-dmg.applescript");
@@ -128,16 +128,6 @@ public File apply(Packager packager) throws Exception {
128128
Logger.info("Unmounting volume: " + mountFolder);
129129
execute("hdiutil", "detach", mountFolder);
130130

131-
// remove application link (if required)
132-
boolean removeApplicationLink = macPackager.getMacConfig().isRemoveApplicationLink();
133-
if (removeApplicationLink) {
134-
boolean success = linkFile.delete();
135-
if (success)
136-
Logger.info("Application link successfully deleted");
137-
else
138-
Logger.info("Could not delete Application link");
139-
}
140-
141131
// compress image
142132
Logger.info("Compressing disk image...");
143133
execute("hdiutil", "convert", tempDmgFile, "-ov", "-format", "UDZO", "-imagekey", "zlib-level=9", "-o", dmgFile);

0 commit comments

Comments
 (0)