Skip to content

Commit

Permalink
Merge pull request #238 from kerner1000/feature/custom-launcher
Browse files Browse the repository at this point in the history
Feature/custom launcher
  • Loading branch information
fvarrui authored Jul 26, 2022
2 parents 4228ce5 + 79219c9 commit 5514389
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class MacConfig implements Serializable {
private String developerId = "-";
private File entitlements;
private File provisionProfile;
private File customLauncher;
private boolean codesignApp = true;
private InfoPlist infoPlist = new InfoPlist();
private boolean hardenedCodesign = true;
Expand Down Expand Up @@ -191,6 +192,14 @@ public void setDeveloperId(String developerId) {
this.developerId = developerId;
}

public File getCustomLauncher() {
return customLauncher;
}

public void setCustomLauncher(File customLauncher) {
this.customLauncher = customLauncher;
}

public File getProvisionProfile() {
return provisionProfile;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,33 +93,37 @@ public File doCreateApp() throws Exception {

if (this.administratorRequired) {

// We need a helper script ("startup") in this case,
// which invokes the launcher script/ executable with administrator rights.
// TODO: admin script depends on launcher file name 'universalJavaApplicationStub'

// sets startup file
this.executable = new File(macOSFolder, "startup");

// creates startup file to boot java app
VelocityUtils.render("mac/startup.vtl", executable, this);
executable.setExecutable(true, false);
Logger.info("Startup script file created in " + executable.getAbsolutePath());

} else {

// sets startup file
this.executable = new File(macOSFolder, "universalJavaApplicationStub");
Logger.info("Using " + executable.getAbsolutePath() + " as startup script");

}

// copies universalJavaApplicationStub startup file to boot java app
File appStubFile = new File(macOSFolder, "universalJavaApplicationStub");
String universalJavaApplicationStubResource = null;
switch (macConfig.getMacStartup()) {
case UNIVERSAL: universalJavaApplicationStubResource = "universalJavaApplicationStub"; break;
case X86_64: universalJavaApplicationStubResource = "universalJavaApplicationStub.x86_64"; break;
case ARM64: universalJavaApplicationStubResource = "universalJavaApplicationStub.arm64"; break;
case SCRIPT: universalJavaApplicationStubResource = "universalJavaApplicationStub.sh"; break;
File launcher = macConfig.getCustomLauncher();
if(launcher != null && launcher.canRead() && launcher.isFile()){
FileUtils.copyFileToFolder(launcher, macOSFolder);
this.executable = new File(macOSFolder, launcher.getName());
} else {
// sets startup file
File appStubFile = new File(macOSFolder, "universalJavaApplicationStub");
String universalJavaApplicationStubResource = null;
switch (macConfig.getMacStartup()) {
case UNIVERSAL: universalJavaApplicationStubResource = "universalJavaApplicationStub"; break;
case X86_64: universalJavaApplicationStubResource = "universalJavaApplicationStub.x86_64"; break;
case ARM64: universalJavaApplicationStubResource = "universalJavaApplicationStub.arm64"; break;
case SCRIPT: universalJavaApplicationStubResource = "universalJavaApplicationStub.sh"; break;
}
FileUtils.copyResourceToFile("/mac/" + universalJavaApplicationStubResource, appStubFile);
this.executable = appStubFile;
}
}
FileUtils.copyResourceToFile("/mac/" + universalJavaApplicationStubResource, appStubFile);
appStubFile.setExecutable(true, false);
executable.setExecutable(true, false);
Logger.info("Startup script file created in " + executable.getAbsolutePath());

// process classpath
classpath = (this.macConfig.isRelocateJar() ? "Java/" : "") + this.jarFile.getName() + (classpath != null ? ":" + classpath : "");
Expand Down

0 comments on commit 5514389

Please sign in to comment.