Skip to content

Commit c245867

Browse files
authored
Merge pull request #74 from treimers/master
New feature "removeApplicationLink" for Mac OS X to remove link to /Application dir
2 parents 365c96d + 1346973 commit c245867

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

docs/macosx-specific-properties.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<generateDmg>true|false</generateDmg>
99
<generatePkg>true|false</generatePkg>
1010
<relocateJar>true|false</relocateJar>
11+
<removeApplicationLink>true|false</removeApplicationLink>
1112
<!-- signing properties -->
1213
<developerId>singning identity</developerId>
1314
<entitlements>path/to/entitlements.plist</entitlements>
@@ -34,6 +35,8 @@
3435
| `generateDmg` | :x: | `true` | Enables DMG disk image file generation. |
3536
| `generatePkg` | :x: | `true` | Enables installation package generation. |
3637
| `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. |
3740
| `appId` | :x: | `${mainClass}` | App unique identifier. |
3841
| `developerId` | :x: | `null` | Signing identity. |
3942
| `entitlements` | :x: | `null` | Path to [entitlements](https://developer.apple.com/documentation/bundleresources/entitlements) file. |

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ 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;
3031
private String appId;
3132
private String developerId = "-";
3233
private File entitlements;
@@ -167,6 +168,14 @@ public void setRelocateJar(boolean relocateJar) {
167168
this.relocateJar = relocateJar;
168169
}
169170

171+
public boolean isRemoveApplicationLink() {
172+
return removeApplicationLink;
173+
}
174+
175+
public void setRemoveApplicationLink(boolean removeApplicationLink) {
176+
this.removeApplicationLink = removeApplicationLink;
177+
}
178+
170179
public String getAppId() {
171180
return appId;
172181
}
@@ -198,7 +207,9 @@ public String toString() {
198207
+ ", iconSize=" + iconSize + ", textSize=" + textSize + ", iconX=" + iconX + ", iconY=" + iconY
199208
+ ", appsLinkIconX=" + appsLinkIconX + ", appsLinkIconY=" + appsLinkIconY + ", volumeIcon=" + volumeIcon
200209
+ ", volumeName=" + volumeName + ", generateDmg=" + generateDmg + ", generatePkg=" + generatePkg
201-
+ ", relocateJar=" + relocateJar + ", appId=" + appId + ", developerId=" + developerId
210+
+ ", relocateJar=" + relocateJar
211+
+ ", removeApplicationLink=" + removeApplicationLink
212+
+ ", appId=" + appId + ", developerId=" + developerId
202213
+ ", entitlements=" + entitlements + "]";
203214
}
204215

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package io.github.fvarrui.javapackager.packagers;
22

3-
import static org.apache.commons.lang3.StringUtils.defaultIfBlank;
43
import static io.github.fvarrui.javapackager.utils.CommandUtils.execute;
4+
import static org.apache.commons.lang3.StringUtils.defaultIfBlank;
55

66
import java.io.File;
77
import java.util.Arrays;
@@ -128,6 +128,16 @@ 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+
131141
// compress image
132142
Logger.info("Compressing disk image...");
133143
execute("hdiutil", "convert", tempDmgFile, "-ov", "-format", "UDZO", "-imagekey", "zlib-level=9", "-o", dmgFile);

0 commit comments

Comments
 (0)