123 private boolean hasMainJar = false; |
123 private boolean hasMainJar = false; |
124 private boolean hasMainClass = false; |
124 private boolean hasMainClass = false; |
125 private boolean hasMainModule = false; |
125 private boolean hasMainModule = false; |
126 private boolean hasTargetFormat = false; |
126 private boolean hasTargetFormat = false; |
127 private boolean hasAppImage = false; |
127 private boolean hasAppImage = false; |
128 |
128 private boolean retainBuildRoot = false; |
|
129 |
|
130 private String buildRoot = null; |
129 private String mainJarPath = null; |
131 private String mainJarPath = null; |
130 |
132 |
131 private static boolean jreInstaller = false; |
133 private static boolean jreInstaller = false; |
132 |
134 |
133 private List<jdk.jpackage.internal.Bundler> platformBundlers = null; |
135 private List<jdk.jpackage.internal.Bundler> platformBundlers = null; |
308 OptionCategories.PROPERTY, () -> { |
310 OptionCategories.PROPERTY, () -> { |
309 context().secondaryLaunchers.add( |
311 context().secondaryLaunchers.add( |
310 new SecondaryLauncherArguments(popArg())); |
312 new SecondaryLauncherArguments(popArg())); |
311 }), |
313 }), |
312 |
314 |
313 BUILD_ROOT ("build-root", OptionCategories.PROPERTY), |
315 BUILD_ROOT ("build-root", OptionCategories.PROPERTY, () -> { |
|
316 context().buildRoot = popArg(); |
|
317 context().retainBuildRoot = true; |
|
318 setOptionValue("build-root", context().buildRoot); |
|
319 }), |
314 |
320 |
315 INSTALL_DIR ("install-dir", OptionCategories.PROPERTY), |
321 INSTALL_DIR ("install-dir", OptionCategories.PROPERTY), |
316 |
322 |
317 PREDEFINED_APP_IMAGE ("app-image", OptionCategories.PROPERTY, ()-> { |
323 PREDEFINED_APP_IMAGE ("app-image", OptionCategories.PROPERTY, ()-> { |
318 setOptionValue("app-image", popArg()); |
324 setOptionValue("app-image", popArg()); |
716 } |
722 } |
717 |
723 |
718 private boolean generateBundle(Map<String,? super Object> params) |
724 private boolean generateBundle(Map<String,? super Object> params) |
719 throws PackagerException { |
725 throws PackagerException { |
720 boolean bundleCreated = false; |
726 boolean bundleCreated = false; |
|
727 File imageDir = null; |
721 |
728 |
722 for (jdk.jpackage.internal.Bundler bundler : getPlatformBundlers()) { |
729 for (jdk.jpackage.internal.Bundler bundler : getPlatformBundlers()) { |
723 Map<String, ? super Object> localParams = new HashMap<>(params); |
730 Map<String, ? super Object> localParams = new HashMap<>(params); |
724 try { |
731 try { |
725 if (bundler.validate(localParams)) { |
732 if (bundler.validate(localParams)) { |
726 File result = |
733 File result = |
727 bundler.execute(localParams, deployParams.outdir); |
734 bundler.execute(localParams, deployParams.outdir); |
728 bundler.cleanup(localParams); |
735 if (!retainBuildRoot) { |
|
736 bundler.cleanup(localParams); |
|
737 } |
729 if (result == null) { |
738 if (result == null) { |
730 throw new PackagerException("MSG_BundlerFailed", |
739 throw new PackagerException("MSG_BundlerFailed", |
731 bundler.getID(), bundler.getName()); |
740 bundler.getID(), bundler.getName()); |
732 } |
741 } |
733 bundleCreated = true; // Set that at least one bundle was created |
742 bundleCreated = true; // at least one bundle was created |
734 } |
743 } |
735 } catch (UnsupportedPlatformException e) { |
744 } catch (UnsupportedPlatformException e) { |
736 Log.debug(MessageFormat.format( |
745 Log.debug(MessageFormat.format( |
737 I18N.getString("MSG_BundlerPlatformException"), |
746 I18N.getString("MSG_BundlerPlatformException"), |
738 bundler.getName())); |
747 bundler.getName())); |
750 } catch (RuntimeException re) { |
759 } catch (RuntimeException re) { |
751 Log.error(MessageFormat.format( |
760 Log.error(MessageFormat.format( |
752 I18N.getString("MSG_BundlerRuntimeException"), |
761 I18N.getString("MSG_BundlerRuntimeException"), |
753 bundler.getName(), re.toString())); |
762 bundler.getName(), re.toString())); |
754 Log.debug(re); |
763 Log.debug(re); |
|
764 } finally { |
|
765 if (retainBuildRoot) { |
|
766 Log.verbose(MessageFormat.format( |
|
767 I18N.getString("message.debug-working-directory"), |
|
768 (new File(buildRoot)).getAbsolutePath())); |
|
769 } |
755 } |
770 } |
756 } |
771 } |
757 |
772 |
758 return bundleCreated; |
773 return bundleCreated; |
759 } |
774 } |
767 |
782 |
768 File baseDir = new File(inputdir); |
783 File baseDir = new File(inputdir); |
769 |
784 |
770 if (!baseDir.isDirectory()) { |
785 if (!baseDir.isDirectory()) { |
771 Log.error( |
786 Log.error( |
772 "Unable to add resources: \"-srcdir\" is not a directory."); |
787 "Unable to add resources: \"--input\" is not a directory."); |
773 return; |
788 return; |
774 } |
789 } |
775 |
790 |
776 List<String> fileNames; |
791 List<String> fileNames; |
777 if (inputfiles != null) { |
792 if (inputfiles != null) { |