65 String copyright;
66 String version;
67 Boolean systemWide;
68 Boolean serviceHint;
69 Boolean signBundle;
70 Boolean installdirChooser;
71
72 String applicationClass;
73 String preloader;
74
75 List<Param> params;
76 List<HtmlParam> htmlParams;
77 List<String> arguments; //unnamed arguments
78
79 // Java 9 modules support
80 Set<String> addModules = null;
81 Set<String> limitModules = null;
82 Boolean stripNativeCommands = null;
83 Boolean detectmods = null;
84 String modulePath = null;
85 String mainModule = null;
86 File srcdir;
87
88 int width;
89 int height;
90 String embeddedWidth = null;
91 String embeddedHeight = null;
92
93 String appName;
94 String codebase;
95
96 boolean embedJNLP = true;
97 @Deprecated final boolean embedCertificates = false;
98 boolean allPermissions = false;
99 String updateMode = "background";
100 boolean isExtension = false;
101 boolean isSwingApp = false;
102
103 Boolean needShortcut = null;
104 Boolean needMenu = null;
105 Boolean needInstall = null;
255 public void addAddModule(String module) {
256 if (addModules == null) {
257 addModules = new LinkedHashSet<>();
258 }
259
260 addModules.add(module);
261 }
262
263 public void addLimitModule(String module) {
264 if (limitModules == null) {
265 limitModules = new LinkedHashSet<>();
266 }
267
268 limitModules.add(module);
269 }
270
271 public void setModulePath(String value) {
272 this.modulePath = value;
273 }
274
275 public void setMainModule(String value) {
276 this.mainModule = value;
277 }
278
279 public void setStripNativeCommands(boolean value) {
280 this.stripNativeCommands = value;
281 }
282
283 public void setDetectMods(boolean value) {
284 this.detectmods = value;
285 }
286
287 public void setDescription(String description) {
288 this.description = description;
289 }
290
291 public void setEmbedJNLP(boolean embedJNLP) {
292 this.embedJNLP = embedJNLP;
293 }
294
295 @Deprecated
296 public void setEmbedCertifcates(boolean v) {
297 if (v) {
298 System.out.println("JavaFX Packager no longer supports embedding certificates in JNLP files. Setting will be ignored.");
299 }
300 }
301
302 public void setPlaceholder(String p) {
303 placeholder = p;
475 return testFile.isAbsolute()
476 ? testFile
477 : new File(baseDir == null
478 ? null
479 : baseDir.getAbsolutePath(),
480 path);
481 }
482
483
484 @Override
485 public void validate() throws PackagerException {
486 if (outdir == null) {
487 throw new PackagerException("ERR_MissingArgument", "-outdir");
488 }
489 if (outfile == null) {
490 throw new PackagerException("ERR_MissingArgument", "-outfile");
491 }
492 if (resources.isEmpty()) {
493 throw new PackagerException("ERR_MissingAppResources");
494 }
495 if (applicationClass == null && mainModule == null) { //TODO better error here for mainmodule
496 throw new PackagerException("ERR_MissingArgument", "-appclass");
497 }
498 }
499
500 public boolean validateForJNLP() {
501 boolean result = false;
502
503 // Success
504 if (applicationClass != null && !applicationClass.isEmpty() &&
505 (getBundleType() == BundleType.JNLP || getBundleType() == BundleType.ALL)) {
506 result = true;
507 }
508
509 // Failed
510 if ((mainModule != null && !mainModule.isEmpty()) ||
511 (addModules != null && !addModules.isEmpty()) ||
512 (limitModules != null && !limitModules.isEmpty()) |
513 (modulePath != null && !modulePath.isEmpty()) ||
514 getBundleType() == BundleType.INSTALLER ||
515 getBundleType() == BundleType.NATIVE ||
516 getBundleType() == BundleType.IMAGE) {
517
518 result = false;
519 }
520
521 return result;
522 }
523
524 public boolean validateForBundle() {
525 boolean result = false;
526
527 // Success
528 if (((applicationClass != null && !applicationClass.isEmpty()) ||
529 !mainModule.isEmpty())) {
530 result = true;
531 }
532
533 return result;
534 }
535
536 //could be icon or splash
537 static class Icon {
538 final static int UNDEFINED = -1;
539
540 String href;
541 String kind;
542 int width = UNDEFINED;
543 int height = UNDEFINED;
544 int depth = UNDEFINED;
545 RunMode mode = RunMode.WEBSTART;
546
547 Icon(String href, String kind, int w, int h, int d, RunMode m) {
548 mode = m;
549 this.href = href;
590
591 if ("x86".equals(arch) || "i386".equals(arch) || "i486".equals(arch)
592 || "i586".equals(arch) || "i686".equals(arch)) {
593 arch = "x86";
594 } else if ("x86_64".equals(arch) || "amd64".equals("arch")) {
595 arch = "x86_64";
596 }
597
598 return arch;
599 }
600
601 static final Set<String> multi_args = new TreeSet<>(Arrays.asList(
602 StandardBundlerParam.JVM_PROPERTIES.getID(),
603 StandardBundlerParam.JVM_OPTIONS.getID(),
604 StandardBundlerParam.USER_JVM_OPTIONS.getID(),
605 StandardBundlerParam.ARGUMENTS.getID(),
606 JLinkBundlerHelper.MODULE_PATH.getID(),
607 JLinkBundlerHelper.ADD_MODULES.getID(),
608 JLinkBundlerHelper.LIMIT_MODULES.getID(),
609 JLinkBundlerHelper.STRIP_NATIVE_COMMANDS.getID(),
610 JLinkBundlerHelper.DETECT_MODS.getID()
611 ));
612
613 @SuppressWarnings("unchecked")
614 public void addBundleArgument(String key, Object value) {
615 // special hack for multi-line arguments
616 if (multi_args.contains(key) && value instanceof String) {
617 Object existingValue = bundlerArguments.get(key);
618 if (existingValue instanceof String) {
619 bundlerArguments.put(key, existingValue + "\n\n" + value);
620 } else if (existingValue instanceof List) {
621 ((List)existingValue).add(value);
622 } else if (existingValue instanceof Map && ((String)value).contains("=")) {
623 String[] mapValues = ((String)value).split("=", 2);
624 ((Map)existingValue).put(mapValues[0], mapValues[1]);
625 } else {
626 bundlerArguments.put(key, value);
627 }
628 } else {
629 bundlerArguments.put(key, value);
630 }
689 bundleParams.setArguments(arguments);
690
691 if (addModules != null && !addModules.isEmpty()) {
692 bundleParams.setAddModules(addModules);
693 }
694
695 if (limitModules != null && !limitModules.isEmpty()) {
696 bundleParams.setLimitModules(limitModules);
697 }
698
699 if (stripNativeCommands != null) {
700 bundleParams.setStripNativeCommands(stripNativeCommands);
701 }
702
703 bundleParams.setSrcDir(srcdir);
704
705 if (modulePath != null && !modulePath.isEmpty()) {
706 bundleParams.setModulePath(modulePath);
707 }
708
709 if (mainModule != null && !mainModule.isEmpty()) {
710 bundleParams.setMainModule(mainModule);
711 }
712
713 if (detectmods != null) {
714 bundleParams.setDetectMods(detectmods);
715 }
716
717 File appIcon = null;
718 List<Map<String, ? super Object>> bundlerIcons = new ArrayList<>();
719 for (Icon ic: icons) {
720 //NB: in theory we should be paying attention to RunMode but
721 // currently everything is marked as webstart internally and runmode
722 // is not publicly documented property
723 if (/* (ic.mode == RunMode.ALL || ic.mode == RunMode.STANDALONE) && */
724 (ic.kind == null || ic.kind.equals("default")))
725 {
726 //could be full path or something relative to the output folder
727 appIcon = new File(ic.href);
728 if (!appIcon.exists()) {
729 com.oracle.tools.packager.Log.debug("Icon [" + ic.href + "] is not valid absolute path. " +
730 "Assume it is relative to the output dir.");
|
65 String copyright;
66 String version;
67 Boolean systemWide;
68 Boolean serviceHint;
69 Boolean signBundle;
70 Boolean installdirChooser;
71
72 String applicationClass;
73 String preloader;
74
75 List<Param> params;
76 List<HtmlParam> htmlParams;
77 List<String> arguments; //unnamed arguments
78
79 // Java 9 modules support
80 Set<String> addModules = null;
81 Set<String> limitModules = null;
82 Boolean stripNativeCommands = null;
83 Boolean detectmods = null;
84 String modulePath = null;
85 String module = null;
86 String debugPort = null;
87 File srcdir;
88
89 int width;
90 int height;
91 String embeddedWidth = null;
92 String embeddedHeight = null;
93
94 String appName;
95 String codebase;
96
97 boolean embedJNLP = true;
98 @Deprecated final boolean embedCertificates = false;
99 boolean allPermissions = false;
100 String updateMode = "background";
101 boolean isExtension = false;
102 boolean isSwingApp = false;
103
104 Boolean needShortcut = null;
105 Boolean needMenu = null;
106 Boolean needInstall = null;
256 public void addAddModule(String module) {
257 if (addModules == null) {
258 addModules = new LinkedHashSet<>();
259 }
260
261 addModules.add(module);
262 }
263
264 public void addLimitModule(String module) {
265 if (limitModules == null) {
266 limitModules = new LinkedHashSet<>();
267 }
268
269 limitModules.add(module);
270 }
271
272 public void setModulePath(String value) {
273 this.modulePath = value;
274 }
275
276 public void setModule(String value) {
277 this.module = value;
278 }
279
280 public void setDebugPort(String value) {
281 this.debugPort = value;
282 }
283
284 public void setStripNativeCommands(boolean value) {
285 this.stripNativeCommands = value;
286 }
287
288 public void setDetectModules(boolean value) {
289 this.detectmods = value;
290 }
291
292 public void setDescription(String description) {
293 this.description = description;
294 }
295
296 public void setEmbedJNLP(boolean embedJNLP) {
297 this.embedJNLP = embedJNLP;
298 }
299
300 @Deprecated
301 public void setEmbedCertifcates(boolean v) {
302 if (v) {
303 System.out.println("JavaFX Packager no longer supports embedding certificates in JNLP files. Setting will be ignored.");
304 }
305 }
306
307 public void setPlaceholder(String p) {
308 placeholder = p;
480 return testFile.isAbsolute()
481 ? testFile
482 : new File(baseDir == null
483 ? null
484 : baseDir.getAbsolutePath(),
485 path);
486 }
487
488
489 @Override
490 public void validate() throws PackagerException {
491 if (outdir == null) {
492 throw new PackagerException("ERR_MissingArgument", "-outdir");
493 }
494 if (outfile == null) {
495 throw new PackagerException("ERR_MissingArgument", "-outfile");
496 }
497 if (resources.isEmpty()) {
498 throw new PackagerException("ERR_MissingAppResources");
499 }
500 if (applicationClass == null && module == null) { //TODO better error here for mainmodule
501 throw new PackagerException("ERR_MissingArgument", "-appclass");
502 }
503 }
504
505 public boolean validateForJNLP() {
506 boolean result = false;
507
508 // Success
509 if (applicationClass != null && !applicationClass.isEmpty() &&
510 (getBundleType() == BundleType.JNLP || getBundleType() == BundleType.ALL)) {
511 result = true;
512 }
513
514 // Failed
515 if ((module != null && !module.isEmpty()) ||
516 (addModules != null && !addModules.isEmpty()) ||
517 (limitModules != null && !limitModules.isEmpty()) |
518 (modulePath != null && !modulePath.isEmpty()) ||
519 getBundleType() == BundleType.INSTALLER ||
520 getBundleType() == BundleType.NATIVE ||
521 getBundleType() == BundleType.IMAGE) {
522
523 result = false;
524 }
525
526 return result;
527 }
528
529 public boolean validateForBundle() {
530 boolean result = false;
531
532 // Success
533 if (((applicationClass != null && !applicationClass.isEmpty()) ||
534 !module.isEmpty())) {
535 result = true;
536 }
537
538 return result;
539 }
540
541 //could be icon or splash
542 static class Icon {
543 final static int UNDEFINED = -1;
544
545 String href;
546 String kind;
547 int width = UNDEFINED;
548 int height = UNDEFINED;
549 int depth = UNDEFINED;
550 RunMode mode = RunMode.WEBSTART;
551
552 Icon(String href, String kind, int w, int h, int d, RunMode m) {
553 mode = m;
554 this.href = href;
595
596 if ("x86".equals(arch) || "i386".equals(arch) || "i486".equals(arch)
597 || "i586".equals(arch) || "i686".equals(arch)) {
598 arch = "x86";
599 } else if ("x86_64".equals(arch) || "amd64".equals("arch")) {
600 arch = "x86_64";
601 }
602
603 return arch;
604 }
605
606 static final Set<String> multi_args = new TreeSet<>(Arrays.asList(
607 StandardBundlerParam.JVM_PROPERTIES.getID(),
608 StandardBundlerParam.JVM_OPTIONS.getID(),
609 StandardBundlerParam.USER_JVM_OPTIONS.getID(),
610 StandardBundlerParam.ARGUMENTS.getID(),
611 JLinkBundlerHelper.MODULE_PATH.getID(),
612 JLinkBundlerHelper.ADD_MODULES.getID(),
613 JLinkBundlerHelper.LIMIT_MODULES.getID(),
614 JLinkBundlerHelper.STRIP_NATIVE_COMMANDS.getID(),
615 JLinkBundlerHelper.DETECT_MODULES.getID()
616 ));
617
618 @SuppressWarnings("unchecked")
619 public void addBundleArgument(String key, Object value) {
620 // special hack for multi-line arguments
621 if (multi_args.contains(key) && value instanceof String) {
622 Object existingValue = bundlerArguments.get(key);
623 if (existingValue instanceof String) {
624 bundlerArguments.put(key, existingValue + "\n\n" + value);
625 } else if (existingValue instanceof List) {
626 ((List)existingValue).add(value);
627 } else if (existingValue instanceof Map && ((String)value).contains("=")) {
628 String[] mapValues = ((String)value).split("=", 2);
629 ((Map)existingValue).put(mapValues[0], mapValues[1]);
630 } else {
631 bundlerArguments.put(key, value);
632 }
633 } else {
634 bundlerArguments.put(key, value);
635 }
694 bundleParams.setArguments(arguments);
695
696 if (addModules != null && !addModules.isEmpty()) {
697 bundleParams.setAddModules(addModules);
698 }
699
700 if (limitModules != null && !limitModules.isEmpty()) {
701 bundleParams.setLimitModules(limitModules);
702 }
703
704 if (stripNativeCommands != null) {
705 bundleParams.setStripNativeCommands(stripNativeCommands);
706 }
707
708 bundleParams.setSrcDir(srcdir);
709
710 if (modulePath != null && !modulePath.isEmpty()) {
711 bundleParams.setModulePath(modulePath);
712 }
713
714 if (module != null && !module.isEmpty()) {
715 bundleParams.setMainModule(module);
716 }
717
718 if (debugPort != null && !debugPort.isEmpty()) {
719 bundleParams.setDebugPort(debugPort);
720 }
721
722 if (detectmods != null) {
723 bundleParams.setDetectMods(detectmods);
724 }
725
726 File appIcon = null;
727 List<Map<String, ? super Object>> bundlerIcons = new ArrayList<>();
728 for (Icon ic: icons) {
729 //NB: in theory we should be paying attention to RunMode but
730 // currently everything is marked as webstart internally and runmode
731 // is not publicly documented property
732 if (/* (ic.mode == RunMode.ALL || ic.mode == RunMode.STANDALONE) && */
733 (ic.kind == null || ic.kind.equals("default")))
734 {
735 //could be full path or something relative to the output folder
736 appIcon = new File(ic.href);
737 if (!appIcon.exists()) {
738 com.oracle.tools.packager.Log.debug("Icon [" + ic.href + "] is not valid absolute path. " +
739 "Assume it is relative to the output dir.");
|