164 public JPackageCommand addArguments(String name, Path value) { |
164 public JPackageCommand addArguments(String name, Path value) { |
165 return addArguments(name, value.toString()); |
165 return addArguments(name, value.toString()); |
166 } |
166 } |
167 |
167 |
168 public boolean isImagePackageType() { |
168 public boolean isImagePackageType() { |
169 return PackageType.IMAGE == getArgumentValue("--package-type", |
169 return PackageType.IMAGE == getArgumentValue("--type", |
170 () -> null, PACKAGE_TYPES::get); |
170 () -> null, PACKAGE_TYPES::get); |
171 } |
171 } |
172 |
172 |
173 public PackageType packageType() { |
173 public PackageType packageType() { |
174 // Don't try to be in sync with jpackage defaults. Keep it simple: |
174 // Don't try to be in sync with jpackage defaults. Keep it simple: |
175 // if no `--package-type` explicitely set on the command line, consider |
175 // if no `--type` explicitely set on the command line, consider |
176 // this is operator's fault. |
176 // this is operator's fault. |
177 return getArgumentValue("--package-type", |
177 return getArgumentValue("--type", |
178 () -> { |
178 () -> { |
179 throw new IllegalStateException("Package type not set"); |
179 throw new IllegalStateException("Package type not set"); |
180 }, PACKAGE_TYPES::get); |
180 }, PACKAGE_TYPES::get); |
181 } |
181 } |
182 |
182 |
393 * Returns path to application's Java runtime. |
393 * Returns path to application's Java runtime. |
394 * If the command will package Java runtime only, returns correct path to |
394 * If the command will package Java runtime only, returns correct path to |
395 * runtime directory. |
395 * runtime directory. |
396 * |
396 * |
397 * E.g.: |
397 * E.g.: |
398 * [jpackage --name Foo --package-type rpm] -> `/opt/foo/lib/runtime` |
398 * [jpackage --name Foo --type rpm] -> `/opt/foo/lib/runtime` |
399 * [jpackage --name Foo --package-type app-image --dest bar] -> `bar/Foo/lib/runtime` |
399 * [jpackage --name Foo --type app-image --dest bar] -> `bar/Foo/lib/runtime` |
400 * [jpackage --name Foo --package-type rpm --runtime-image java] -> `/opt/foo` |
400 * [jpackage --name Foo --type rpm --runtime-image java] -> `/opt/foo` |
401 */ |
401 */ |
402 public Path appRuntimeDirectory() { |
402 public Path appRuntimeDirectory() { |
403 return appLayout().runtimeDirectory(); |
403 return appLayout().runtimeDirectory(); |
404 } |
404 } |
405 |
405 |
406 /** |
406 /** |
407 * Returns path for application launcher with the given name. |
407 * Returns path for application launcher with the given name. |
408 * |
408 * |
409 * E.g.: [jpackage --name Foo --package-type rpm] -> `/opt/foo/bin/Foo` |
409 * E.g.: [jpackage --name Foo --type rpm] -> `/opt/foo/bin/Foo` |
410 * [jpackage --name Foo --package-type app-image --dest bar] -> |
410 * [jpackage --name Foo --type app-image --dest bar] -> |
411 * `bar/Foo/bin/Foo` |
411 * `bar/Foo/bin/Foo` |
412 * |
412 * |
413 * @param launcherName name of launcher or {@code null} for the main |
413 * @param launcherName name of launcher or {@code null} for the main |
414 * launcher |
414 * launcher |
415 * |
415 * |
452 |
452 |
453 /** |
453 /** |
454 * Returns path to .cfg file of the given application launcher. |
454 * Returns path to .cfg file of the given application launcher. |
455 * |
455 * |
456 * E.g.: |
456 * E.g.: |
457 * [jpackage --name Foo --package-type rpm] -> `/opt/foo/lib/app/Foo.cfg` |
457 * [jpackage --name Foo --type rpm] -> `/opt/foo/lib/app/Foo.cfg` |
458 * [jpackage --name Foo --package-type app-image --dest bar] -> `bar/Foo/lib/app/Foo.cfg` |
458 * [jpackage --name Foo --type app-image --dest bar] -> `bar/Foo/lib/app/Foo.cfg` |
459 * |
459 * |
460 * @param launcher name of launcher or {@code null} for the main launcher |
460 * @param launcher name of launcher or {@code null} for the main launcher |
461 * |
461 * |
462 * @throws IllegalArgumentException if the command is configured for |
462 * @throws IllegalArgumentException if the command is configured for |
463 * packaging Java runtime |
463 * packaging Java runtime |
618 verifyIsOfType(types.toArray(PackageType[]::new)); |
618 verifyIsOfType(types.toArray(PackageType[]::new)); |
619 } |
619 } |
620 |
620 |
621 public void verifyIsOfType(PackageType ... types) { |
621 public void verifyIsOfType(PackageType ... types) { |
622 final var typesSet = Stream.of(types).collect(Collectors.toSet()); |
622 final var typesSet = Stream.of(types).collect(Collectors.toSet()); |
623 if (!hasArgument("--package-type")) { |
623 if (!hasArgument("--type")) { |
624 if (!isImagePackageType()) { |
624 if (!isImagePackageType()) { |
625 if (TKit.isLinux() && typesSet.equals(PackageType.LINUX)) { |
625 if (TKit.isLinux() && typesSet.equals(PackageType.LINUX)) { |
626 return; |
626 return; |
627 } |
627 } |
628 |
628 |