Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/custom launcher #238

Merged
merged 2 commits into from
Jul 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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