143 BIT_ARCH_64_RUNTIME.fetchFrom(params))) { |
143 BIT_ARCH_64_RUNTIME.fetchFrom(params))) { |
144 throw new ConfigException( |
144 throw new ConfigException( |
145 I18N.getString("error.bit-architecture-mismatch"), |
145 I18N.getString("error.bit-architecture-mismatch"), |
146 I18N.getString("error.bit-architecture-mismatch.advice")); |
146 I18N.getString("error.bit-architecture-mismatch.advice")); |
147 } |
147 } |
148 } |
|
149 |
|
150 // it is static for the sake of sharing with "Exe" bundles |
|
151 // that may skip calls to validate/bundle in this class! |
|
152 private static File getRootDir(File outDir, Map<String, ? super Object> p) { |
|
153 return new File(outDir, APP_NAME.fetchFrom(p)); |
|
154 } |
148 } |
155 |
149 |
156 private static boolean usePredefineAppName(Map<String, ? super Object> p) { |
150 private static boolean usePredefineAppName(Map<String, ? super Object> p) { |
157 return (PREDEFINED_APP_IMAGE.fetchFrom(p) != null); |
151 return (PREDEFINED_APP_IMAGE.fetchFrom(p) != null); |
158 } |
152 } |
204 |
198 |
205 public boolean bundle(Map<String, ? super Object> p, File outputDirectory) { |
199 public boolean bundle(Map<String, ? super Object> p, File outputDirectory) { |
206 return doBundle(p, outputDirectory, false) != null; |
200 return doBundle(p, outputDirectory, false) != null; |
207 } |
201 } |
208 |
202 |
209 private File createRoot(Map<String, ? super Object> p, |
|
210 File outputDirectory, boolean dependentTask) throws IOException { |
|
211 if (!outputDirectory.isDirectory() && !outputDirectory.mkdirs()) { |
|
212 throw new RuntimeException(MessageFormat.format( |
|
213 I18N.getString("error.cannot-create-output-dir"), |
|
214 outputDirectory.getAbsolutePath())); |
|
215 } |
|
216 if (!outputDirectory.canWrite()) { |
|
217 throw new RuntimeException(MessageFormat.format( |
|
218 I18N.getString("error.cannot-write-to-output-dir"), |
|
219 outputDirectory.getAbsolutePath())); |
|
220 } |
|
221 if (!dependentTask) { |
|
222 Log.verbose(MessageFormat.format( |
|
223 I18N.getString("message.creating-app-bundle"), |
|
224 APP_NAME.fetchFrom(p), outputDirectory.getAbsolutePath())); |
|
225 } |
|
226 |
|
227 // Create directory structure |
|
228 File rootDirectory = getRootDir(outputDirectory, p); |
|
229 IOUtils.deleteRecursive(rootDirectory); |
|
230 rootDirectory.mkdirs(); |
|
231 |
|
232 if (!p.containsKey(JLinkBundlerHelper.JLINK_BUILDER.getID())) { |
|
233 p.put(JLinkBundlerHelper.JLINK_BUILDER.getID(), |
|
234 "windowsapp-image-builder"); |
|
235 } |
|
236 |
|
237 return rootDirectory; |
|
238 } |
|
239 |
|
240 File doBundle(Map<String, ? super Object> p, |
203 File doBundle(Map<String, ? super Object> p, |
241 File outputDirectory, boolean dependentTask) { |
204 File outputDirectory, boolean dependentTask) { |
242 if (Arguments.CREATE_JRE_INSTALLER.fetchFrom(p)) { |
205 if (Arguments.CREATE_JRE_INSTALLER.fetchFrom(p)) { |
243 return doJreBundle(p, outputDirectory, dependentTask); |
206 return doJreBundle(p, outputDirectory, dependentTask); |
244 } else { |
207 } else { |
247 } |
210 } |
248 |
211 |
249 File doJreBundle(Map<String, ? super Object> p, |
212 File doJreBundle(Map<String, ? super Object> p, |
250 File outputDirectory, boolean dependentTask) { |
213 File outputDirectory, boolean dependentTask) { |
251 try { |
214 try { |
252 File rootDirectory = createRoot(p, outputDirectory, dependentTask); |
215 File rootDirectory = createRoot(p, outputDirectory, dependentTask, |
|
216 APP_NAME.fetchFrom(p), "windowsapp-image-builder"); |
253 AbstractAppImageBuilder appBuilder = new WindowsAppImageBuilder( |
217 AbstractAppImageBuilder appBuilder = new WindowsAppImageBuilder( |
254 APP_NAME.fetchFrom(p), |
218 APP_NAME.fetchFrom(p), |
255 outputDirectory.toPath()); |
219 outputDirectory.toPath()); |
256 File predefined = PREDEFINED_RUNTIME_IMAGE.fetchFrom(p); |
220 File predefined = PREDEFINED_RUNTIME_IMAGE.fetchFrom(p); |
257 if (predefined == null ) { |
221 if (predefined == null ) { |
268 } |
232 } |
269 |
233 |
270 File doAppBundle(Map<String, ? super Object> p, |
234 File doAppBundle(Map<String, ? super Object> p, |
271 File outputDirectory, boolean dependentTask) { |
235 File outputDirectory, boolean dependentTask) { |
272 try { |
236 try { |
273 File rootDirectory = |
237 File rootDirectory = createRoot(p, outputDirectory, dependentTask, |
274 createRoot(p, outputDirectory, dependentTask); |
238 APP_NAME.fetchFrom(p), "windowsapp-image-builder"); |
275 AbstractAppImageBuilder appBuilder = |
239 AbstractAppImageBuilder appBuilder = |
276 new WindowsAppImageBuilder(p, outputDirectory.toPath()); |
240 new WindowsAppImageBuilder(p, outputDirectory.toPath()); |
277 if (PREDEFINED_RUNTIME_IMAGE.fetchFrom(p) == null ) { |
241 if (PREDEFINED_RUNTIME_IMAGE.fetchFrom(p) == null ) { |
278 JLinkBundlerHelper.execute(p, appBuilder); |
242 JLinkBundlerHelper.execute(p, appBuilder); |
279 } else { |
243 } else { |