@@ -91,6 +91,20 @@ public File doCreateApp() throws Exception {
9191 // copies jarfile to Java folder
9292 FileUtils .copyFileToFolder (jarFile , javaFolder );
9393
94+ processStartupScript ();
95+
96+ processClasspath ();
97+
98+ processInfoPlistFile ();
99+
100+ processProvisionProfileFile ();
101+
102+ codesign ();
103+
104+ return appFile ;
105+ }
106+
107+ private void processStartupScript () throws Exception {
94108 if (this .administratorRequired ) {
95109
96110 // We need a helper script ("startup") in this case,
@@ -109,23 +123,15 @@ public File doCreateApp() throws Exception {
109123 FileUtils .copyFileToFolder (launcher , macOSFolder );
110124 this .executable = new File (macOSFolder , launcher .getName ());
111125 } else {
112- // sets startup file
113- File appStubFile = new File (macOSFolder , "universalJavaApplicationStub" );
114- String universalJavaApplicationStubResource = null ;
115- switch (macConfig .getMacStartup ()) {
116- case UNIVERSAL : universalJavaApplicationStubResource = "universalJavaApplicationStub" ; break ;
117- case X86_64 : universalJavaApplicationStubResource = "universalJavaApplicationStub.x86_64" ; break ;
118- case ARM64 : universalJavaApplicationStubResource = "universalJavaApplicationStub.arm64" ; break ;
119- case SCRIPT : universalJavaApplicationStubResource = "universalJavaApplicationStub.sh" ; break ;
120- }
121- FileUtils .copyResourceToFile ("/mac/" + universalJavaApplicationStubResource , appStubFile );
122- this .executable = appStubFile ;
126+ this .executable = preparePrecompiledStartupStub ();
123127 }
124128 }
125129 executable .setExecutable (true , false );
126130 Logger .info ("Startup script file created in " + executable .getAbsolutePath ());
131+ }
127132
128- // process classpath
133+ private void processClasspath () {
134+ // TODO: Why are we doing this here? I do not see any usage of 'classpath' or 'classpaths' here.
129135 classpath = (this .macConfig .isRelocateJar () ? "Java/" : "" ) + this .jarFile .getName () + (classpath != null ? ":" + classpath : "" );
130136 classpaths = Arrays .asList (classpath .split ("[:;]" ));
131137 if (!isUseResourcesAsWorkingDir ()) {
@@ -135,14 +141,30 @@ public File doCreateApp() throws Exception {
135141 .collect (Collectors .toList ());
136142 }
137143 classpath = StringUtils .join (classpaths , ":" );
144+ }
138145
139- // creates and write the Info.plist file
146+ /**
147+ * Creates and writes the Info.plist file
148+ * @throws Exception if anything goes wrong
149+ */
150+ private void processInfoPlistFile () throws Exception {
140151 File infoPlistFile = new File (contentsFolder , "Info.plist" );
141152 VelocityUtils .render ("mac/Info.plist.vtl" , infoPlistFile , this );
142153 XMLUtils .prettify (infoPlistFile );
143154 Logger .info ("Info.plist file created in " + infoPlistFile .getAbsolutePath ());
155+ }
144156
145- // copy provisionprofile
157+ private void codesign () throws Exception {
158+ if (!Platform .mac .isCurrentPlatform ()) {
159+ Logger .warn ("Generated app could not be signed due to current platform is " + Platform .getCurrentPlatform ());
160+ } else if (!getMacConfig ().isCodesignApp ()) {
161+ Logger .warn ("App codesigning disabled" );
162+ } else {
163+ codesign (this .macConfig .getDeveloperId (), this .macConfig .getEntitlements (), this .appFile );
164+ }
165+ }
166+
167+ private void processProvisionProfileFile () throws Exception {
146168 if (macConfig .getProvisionProfile () != null ) {
147169 // file name must be 'embedded.provisionprofile'
148170 File provisionProfile = new File (contentsFolder , "embedded.provisionprofile" );
@@ -151,17 +173,20 @@ public File doCreateApp() throws Exception {
151173 macConfig .getProvisionProfile () + " to \n " +
152174 provisionProfile .getAbsolutePath ());
153175 }
176+ }
154177
155- // codesigns app folder
156- if (!Platform .mac .isCurrentPlatform ()) {
157- Logger .warn ("Generated app could not be signed due to current platform is " + Platform .getCurrentPlatform ());
158- } else if (!getMacConfig ().isCodesignApp ()) {
159- Logger .warn ("App codesigning disabled" );
160- } else {
161- codesign (this .macConfig .getDeveloperId (), this .macConfig .getEntitlements (), this .appFile );
178+ private File preparePrecompiledStartupStub () throws Exception {
179+ // sets startup file
180+ File appStubFile = new File (macOSFolder , "universalJavaApplicationStub" );
181+ String universalJavaApplicationStubResource = null ;
182+ switch (macConfig .getMacStartup ()) {
183+ case UNIVERSAL : universalJavaApplicationStubResource = "universalJavaApplicationStub" ; break ;
184+ case X86_64 : universalJavaApplicationStubResource = "universalJavaApplicationStub.x86_64" ; break ;
185+ case ARM64 : universalJavaApplicationStubResource = "universalJavaApplicationStub.arm64" ; break ;
186+ case SCRIPT : universalJavaApplicationStubResource = "universalJavaApplicationStub.sh" ; break ;
162187 }
163-
164- return appFile ;
188+ FileUtils . copyResourceToFile ( "/mac/" + universalJavaApplicationStubResource , appStubFile );
189+ return appStubFile ;
165190 }
166191
167192 private void codesign (String developerId , File entitlements , File appFile ) throws Exception {
0 commit comments