348 if (REDIST_MSVCR_URL != null && REDIST_MSVCP_URL != null) {
349 IOUtils.copyFromURL(
350 REDIST_MSVCR_URL,
351 new File(rootDirectory, REDIST_MSVCR.replaceAll("VS_VER", VS_VER)));
352 IOUtils.copyFromURL(
353 REDIST_MSVCP_URL,
354 new File(rootDirectory, REDIST_MSVCP.replaceAll("VS_VER", VS_VER)));
355 return true;
356 }
357
358 return false; // not found
359 }
360
361 private void createLauncherForEntryPoint(Map<String, ? super Object> p, File rootDirectory) throws IOException {
362 prepareConfigFiles(p);
363
364 // Generate launcher .cfg file
365 if (LAUNCHER_CFG_FORMAT.fetchFrom(p).equals(CFG_FORMAT_PROPERTIES)) {
366 writeCfgFile(p, rootDirectory);
367 } else {
368 writeCfgFile(p, new File(rootDirectory, getLauncherCfgName(p)), "$APPDIR\\runtime");
369 }
370
371 // Copy executable root folder
372 File executableFile = new File(rootDirectory, getLauncherName(p));
373 IOUtils.copyFromURL(
374 RAW_EXECUTABLE_URL.fetchFrom(p),
375 executableFile);
376 executableFile.setExecutable(true, false);
377
378 //Update branding of exe file
379 if (REBRAND_EXECUTABLE.fetchFrom(p) && getConfig_AppIcon(p).exists()) {
380 //extract helper tool
381 File iconSwapTool = File.createTempFile("iconswap", ".exe");
382 iconSwapTool.delete();
383 IOUtils.copyFromURL(
384 WinResources.class.getResource(TOOL_ICON_SWAP),
385 iconSwapTool);
386 iconSwapTool.setExecutable(true, false);
387 iconSwapTool.deleteOnExit();
388
401 new File(rootDirectory, APP_NAME.fetchFrom(p) + ".ico"));
402 }
403
404 private void copyApplication(Map<String, ? super Object> params, File appDirectory) throws IOException {
405 List<RelativeFileSet> appResourcesList = APP_RESOURCES_LIST.fetchFrom(params);
406 if (appResourcesList == null) {
407 throw new RuntimeException("Null app resources?");
408 }
409 for (RelativeFileSet appResources : appResourcesList) {
410 if (appResources == null) {
411 throw new RuntimeException("Null app resources?");
412 }
413 File srcdir = appResources.getBaseDirectory();
414 for (String fname : appResources.getIncludedFiles()) {
415 IOUtils.copyFile(
416 new File(srcdir, fname), new File(appDirectory, fname));
417 }
418 }
419 }
420
421 private void writeCfgFile(Map<String, ? super Object> params, File rootDir) throws FileNotFoundException {
422 File cfgFile = new File(rootDir, getLauncherCfgName(params));
423
424 cfgFile.delete();
425
426 PrintStream out = new PrintStream(cfgFile);
427 if (WIN_RUNTIME.fetchFrom(params) == null) {
428 out.println("app.runtime=");
429 } else {
430 out.println("app.runtime=$APPDIR\\runtime");
431 }
432 out.println("app.mainjar=" + MAIN_JAR.fetchFrom(params).getIncludedFiles().iterator().next());
433 out.println("app.version=" + VERSION.fetchFrom(params));
434 //for future AU support (to be able to find app in the registry)
435 out.println("app.id=" + IDENTIFIER.fetchFrom(params));
436 out.println("app.preferences.id=" + PREFERENCES_ID.fetchFrom(params));
437 out.println("app.identifier=" + IDENTIFIER.fetchFrom(params));
438
439 out.println("app.mainclass=" +
440 MAIN_CLASS.fetchFrom(params).replaceAll("\\.", "/"));
441 out.println("app.classpath=" + CLASSPATH.fetchFrom(params));
442
443 List<String> jvmargs = JVM_OPTIONS.fetchFrom(params);
444 int idx = 1;
445 for (String a : jvmargs) {
446 out.println("jvmarg."+idx+"="+a);
447 idx++;
448 }
449 Map<String, String> jvmProps = JVM_PROPERTIES.fetchFrom(params);
450 for (Map.Entry<String, String> entry : jvmProps.entrySet()) {
451 out.println("jvmarg."+idx+"=-D"+entry.getKey()+"="+entry.getValue());
|
348 if (REDIST_MSVCR_URL != null && REDIST_MSVCP_URL != null) {
349 IOUtils.copyFromURL(
350 REDIST_MSVCR_URL,
351 new File(rootDirectory, REDIST_MSVCR.replaceAll("VS_VER", VS_VER)));
352 IOUtils.copyFromURL(
353 REDIST_MSVCP_URL,
354 new File(rootDirectory, REDIST_MSVCP.replaceAll("VS_VER", VS_VER)));
355 return true;
356 }
357
358 return false; // not found
359 }
360
361 private void createLauncherForEntryPoint(Map<String, ? super Object> p, File rootDirectory) throws IOException {
362 prepareConfigFiles(p);
363
364 // Generate launcher .cfg file
365 if (LAUNCHER_CFG_FORMAT.fetchFrom(p).equals(CFG_FORMAT_PROPERTIES)) {
366 writeCfgFile(p, rootDirectory);
367 } else {
368 writeCfgFile(p, new File(rootDirectory, getLauncherCfgName(p)), getRuntimeLocation(p));
369 }
370
371 // Copy executable root folder
372 File executableFile = new File(rootDirectory, getLauncherName(p));
373 IOUtils.copyFromURL(
374 RAW_EXECUTABLE_URL.fetchFrom(p),
375 executableFile);
376 executableFile.setExecutable(true, false);
377
378 //Update branding of exe file
379 if (REBRAND_EXECUTABLE.fetchFrom(p) && getConfig_AppIcon(p).exists()) {
380 //extract helper tool
381 File iconSwapTool = File.createTempFile("iconswap", ".exe");
382 iconSwapTool.delete();
383 IOUtils.copyFromURL(
384 WinResources.class.getResource(TOOL_ICON_SWAP),
385 iconSwapTool);
386 iconSwapTool.setExecutable(true, false);
387 iconSwapTool.deleteOnExit();
388
401 new File(rootDirectory, APP_NAME.fetchFrom(p) + ".ico"));
402 }
403
404 private void copyApplication(Map<String, ? super Object> params, File appDirectory) throws IOException {
405 List<RelativeFileSet> appResourcesList = APP_RESOURCES_LIST.fetchFrom(params);
406 if (appResourcesList == null) {
407 throw new RuntimeException("Null app resources?");
408 }
409 for (RelativeFileSet appResources : appResourcesList) {
410 if (appResources == null) {
411 throw new RuntimeException("Null app resources?");
412 }
413 File srcdir = appResources.getBaseDirectory();
414 for (String fname : appResources.getIncludedFiles()) {
415 IOUtils.copyFile(
416 new File(srcdir, fname), new File(appDirectory, fname));
417 }
418 }
419 }
420
421 private String getRuntimeLocation(Map<String, ? super Object> params) {
422 if (WIN_RUNTIME.fetchFrom(params) == null) {
423 return "";
424 } else {
425 return "$APPDIR\\runtime";
426 }
427 }
428
429 private void writeCfgFile(Map<String, ? super Object> params, File rootDir) throws FileNotFoundException {
430 File cfgFile = new File(rootDir, getLauncherCfgName(params));
431
432 cfgFile.delete();
433
434 PrintStream out = new PrintStream(cfgFile);
435 out.println("app.runtime=" + getRuntimeLocation(params));
436 out.println("app.mainjar=" + MAIN_JAR.fetchFrom(params).getIncludedFiles().iterator().next());
437 out.println("app.version=" + VERSION.fetchFrom(params));
438 //for future AU support (to be able to find app in the registry)
439 out.println("app.id=" + IDENTIFIER.fetchFrom(params));
440 out.println("app.preferences.id=" + PREFERENCES_ID.fetchFrom(params));
441 out.println("app.identifier=" + IDENTIFIER.fetchFrom(params));
442
443 out.println("app.mainclass=" +
444 MAIN_CLASS.fetchFrom(params).replaceAll("\\.", "/"));
445 out.println("app.classpath=" + CLASSPATH.fetchFrom(params));
446
447 List<String> jvmargs = JVM_OPTIONS.fetchFrom(params);
448 int idx = 1;
449 for (String a : jvmargs) {
450 out.println("jvmarg."+idx+"="+a);
451 idx++;
452 }
453 Map<String, String> jvmProps = JVM_PROPERTIES.fetchFrom(params);
454 for (Map.Entry<String, String> entry : jvmProps.entrySet()) {
455 out.println("jvmarg."+idx+"=-D"+entry.getKey()+"="+entry.getValue());
|