468 @Override |
465 @Override |
469 public void validate() throws PackagerException { |
466 public void validate() throws PackagerException { |
470 if (outdir == null) { |
467 if (outdir == null) { |
471 throw new PackagerException("ERR_MissingArgument", "--output"); |
468 throw new PackagerException("ERR_MissingArgument", "--output"); |
472 } |
469 } |
|
470 |
|
471 boolean hasModule = (bundlerArguments.get( |
|
472 Arguments.CLIOptions.MODULE.getId()) != null); |
|
473 boolean hasImage = (bundlerArguments.get( |
|
474 Arguments.CLIOptions.PREDEFINED_APP_IMAGE.getId()) != null); |
|
475 boolean hasClass = (bundlerArguments.get( |
|
476 Arguments.CLIOptions.APPCLASS.getId()) != null); |
|
477 boolean hasMain = (bundlerArguments.get( |
|
478 Arguments.CLIOptions.MAIN_JAR.getId()) != null); |
|
479 |
|
480 // if bundling non-modular image, or installer without app-image |
|
481 // then we need some resources and a main class |
|
482 if (!hasModule && !hasImage && !jreInstaller) { |
|
483 if (resources.isEmpty()) { |
|
484 throw new PackagerException("ERR_MissingAppResources"); |
|
485 } |
|
486 if (!hasClass) { |
|
487 throw new PackagerException("ERR_MissingArgument", "--class"); |
|
488 } |
|
489 if (!hasMain) { |
|
490 throw new PackagerException("ERR_MissingArgument", "--main-jar"); |
|
491 } |
|
492 } |
473 } |
493 } |
474 |
494 |
475 public boolean validateForBundle() { |
495 public boolean validateForBundle() { |
476 boolean result = false; |
496 boolean result = false; |
477 |
497 |
480 (module != null && !module.isEmpty()))) { |
500 (module != null && !module.isEmpty()))) { |
481 result = true; |
501 result = true; |
482 } |
502 } |
483 |
503 |
484 return result; |
504 return result; |
485 } |
|
486 |
|
487 // could be icon or splash |
|
488 // TODO: do we still need this class? |
|
489 static class Icon { |
|
490 final static int UNDEFINED = -1; |
|
491 |
|
492 String href; |
|
493 String kind; |
|
494 int width = UNDEFINED; |
|
495 int height = UNDEFINED; |
|
496 int depth = UNDEFINED; |
|
497 RunMode mode = RunMode.ALL; |
|
498 |
|
499 Icon(String href, String kind, int w, int h, int d, RunMode m) { |
|
500 mode = m; |
|
501 this.href = href; |
|
502 this.kind = kind; |
|
503 if (w > 0) { |
|
504 width = w; |
|
505 } |
|
506 if (h > 0) { |
|
507 height = h; |
|
508 } |
|
509 if (d > 0) { |
|
510 depth = d; |
|
511 } |
|
512 } |
|
513 } |
|
514 |
|
515 List<Icon> icons = new LinkedList<>(); |
|
516 |
|
517 public void addIcon( |
|
518 String href, String kind, int w, int h, int d, RunMode m) { |
|
519 icons.add(new Icon(href, kind, w, h, d, m)); |
|
520 } |
505 } |
521 |
506 |
522 BundleType bundleType = BundleType.NONE; |
507 BundleType bundleType = BundleType.NONE; |
523 String targetFormat = null; //means any |
508 String targetFormat = null; //means any |
524 |
509 |
666 |
651 |
667 if (detectmods != null) { |
652 if (detectmods != null) { |
668 bundleParams.setDetectMods(detectmods); |
653 bundleParams.setDetectMods(detectmods); |
669 } |
654 } |
670 |
655 |
671 File appIcon = null; |
|
672 List<Map<String, ? super Object>> bundlerIcons = new ArrayList<>(); |
|
673 for (Icon ic: icons) { |
|
674 // NB: in theory we should be paying attention to RunMode but |
|
675 // currently everything is marked as webstart internally and |
|
676 // runmode is not publicly documented property |
|
677 if (/* (ic.mode == RunMode.ALL || |
|
678 ic.mode == RunMode.STANDALONE) && */ |
|
679 (ic.kind == null || ic.kind.equals("default"))) |
|
680 { |
|
681 //could be full path or something relative to the output folder |
|
682 appIcon = new File(ic.href); |
|
683 if (!appIcon.exists()) { |
|
684 jdk.packager.internal.Log.debug( |
|
685 "Icon [" + ic.href + "] is not valid absolute path. " |
|
686 + "Assume it is relative to the output dir."); |
|
687 appIcon = new File(outdir, ic.href); |
|
688 } |
|
689 } |
|
690 |
|
691 Map<String, ? super Object> iconInfo = new TreeMap<>(); |
|
692 /* |
|
693 if (ic.href != null) iconInfo.put(ICONS_HREF.getID(), ic.href); |
|
694 if (ic.kind != null) iconInfo.put(ICONS_KIND.getID(), ic.kind); |
|
695 if (ic.width > 0) iconInfo.put(ICONS_WIDTH.getID(), |
|
696 Integer.toString(ic.width)); |
|
697 if (ic.height > 0) iconInfo.put(ICONS_HEIGHT.getID(), |
|
698 Integer.toString(ic.height)); |
|
699 if (ic.depth > 0) iconInfo.put(ICONS_DEPTH.getID(), |
|
700 Integer.toString(ic.depth)); |
|
701 */ |
|
702 if (!iconInfo.isEmpty()) bundlerIcons.add(iconInfo); |
|
703 } |
|
704 // putUnlessNullOrEmpty(ICONS.getID(), bundlerIcons); |
|
705 |
|
706 bundleParams.setIcon(appIcon); |
|
707 |
|
708 Map<String, String> paramsMap = new TreeMap<>(); |
656 Map<String, String> paramsMap = new TreeMap<>(); |
709 if (params != null) { |
657 if (params != null) { |
710 for (Param p : params) { |
658 for (Param p : params) { |
711 paramsMap.put(p.name, p.value); |
659 paramsMap.put(p.name, p.value); |
712 } |
660 } |
713 } |
661 } |
714 |
662 |
715 Map<String, String> unescapedHtmlParams = new TreeMap<>(); |
663 Map<String, String> unescapedHtmlParams = new TreeMap<>(); |
716 Map<String, String> escapedHtmlParams = new TreeMap<>(); |
664 Map<String, String> escapedHtmlParams = new TreeMap<>(); |
717 |
665 |
718 // putUnlessNullOrEmpty(JNLPBundler.APPLET_PARAMS.getID(), |
|
719 // unescapedHtmlParams); |
|
720 // putUnlessNullOrEmpty(ESCAPED_APPLET_PARAMS.getID(), |
|
721 // escapedHtmlParams); |
|
722 |
|
723 /* |
|
724 putUnlessNull(WIDTH.getID(), width); |
|
725 putUnlessNull(HEIGHT.getID(), height); |
|
726 putUnlessNull(EMBEDDED_WIDTH.getID(), embeddedWidth); |
|
727 putUnlessNull(EMBEDDED_HEIGHT.getID(), embeddedHeight); |
|
728 |
|
729 putUnlessNull(CODEBASE.getID(), codebase); |
|
730 putUnlessNull(EMBED_JNLP.getID(), embedJNLP); |
|
731 // embedCertificates |
|
732 putUnlessNull(ALL_PERMISSIONS.getID(), allPermissions); |
|
733 putUnlessNull(UPDATE_MODE.getID(), updateMode); |
|
734 putUnlessNull(EXTENSION.getID(), isExtension); |
|
735 putUnlessNull(SWING_APP.getID(), isSwingApp); |
|
736 |
|
737 putUnlessNull(OUT_FILE.getID(), outfile); |
|
738 putUnlessNull(INCLUDE_DT.getID(), includeDT); |
|
739 putUnlessNull(PLACEHOLDER.getID(), placeholder); |
|
740 putUnlessNull(OFFLINE_ALLOWED.getID(), offlineAllowed); |
|
741 |
|
742 putUnlessNull(TEMPLATES.getID(), templatesMap); |
|
743 |
|
744 putUnlessNull(FX_PLATFORM.getID(), fxPlatform); |
|
745 putUnlessNull(JRE_PLATFORM.getID(), jrePlatform); |
|
746 |
|
747 putUnlessNull(FALLBACK_APP.getID(), fallbackApp); |
|
748 */ |
|
749 // check for collisions |
666 // check for collisions |
750 TreeSet<String> keys = new TreeSet<>(bundlerArguments.keySet()); |
667 TreeSet<String> keys = new TreeSet<>(bundlerArguments.keySet()); |
751 keys.retainAll(bundleParams.getBundleParamsAsMap().keySet()); |
668 keys.retainAll(bundleParams.getBundleParamsAsMap().keySet()); |
752 |
669 |
753 if (!keys.isEmpty()) { |
670 if (!keys.isEmpty()) { |