99import org .apache .commons .lang3 .StringUtils ;
1010import org .apache .commons .lang3 .SystemUtils ;
1111
12+ import io .github .fvarrui .javapackager .model .MacStartup ;
1213import io .github .fvarrui .javapackager .model .Platform ;
1314import io .github .fvarrui .javapackager .utils .CommandUtils ;
1415import io .github .fvarrui .javapackager .utils .FileUtils ;
@@ -105,6 +106,7 @@ public File doCreateApp() throws Exception {
105106 }
106107
107108 private void processStartupScript () throws Exception {
109+
108110 if (this .administratorRequired ) {
109111
110112 // We need a helper script ("startup") in this case,
@@ -116,6 +118,7 @@ private void processStartupScript() throws Exception {
116118
117119 // creates startup file to boot java app
118120 VelocityUtils .render ("mac/startup.vtl" , executable , this );
121+
119122 } else {
120123
121124 File launcher = macConfig .getCustomLauncher ();
@@ -126,6 +129,7 @@ private void processStartupScript() throws Exception {
126129 this .executable = preparePrecompiledStartupStub ();
127130 }
128131 }
132+
129133 executable .setExecutable (true , false );
130134 Logger .info ("Startup script file created in " + executable .getAbsolutePath ());
131135 }
@@ -189,7 +193,8 @@ private File preparePrecompiledStartupStub() throws Exception {
189193 case ARM64 : universalJavaApplicationStubResource = "universalJavaApplicationStub.arm64" ; break ;
190194 case SCRIPT : universalJavaApplicationStubResource = "universalJavaApplicationStub.sh" ; break ;
191195 }
192- FileUtils .copyResourceToFile ("/mac/" + universalJavaApplicationStubResource , appStubFile );
196+ // unixStyleNewLinux=true if startup is a script (this will replace '\r\n' with '\n')
197+ FileUtils .copyResourceToFile ("/mac/" + universalJavaApplicationStubResource , appStubFile , macConfig .getMacStartup () == MacStartup .SCRIPT );
193198 return appStubFile ;
194199 }
195200
0 commit comments