Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ message.output-to-location=Package (.deb) saved to: {0}.
message.debs-like-licenses=Debian packages should specify a license. The absence of a license will cause some linux distributions to complain about the quality of the application.
message.outputting-bundle-location=Generating RPM for installer to: {0}.
message.output-bundle-location=Package (.rpm) saved to: {0}.
message.creating-association-with-null-extension=Creating association with null extension.

message.ldd-not-available=ldd command not found. Package dependencies will not be generated.
message.deb-ldd-not-available.advice=Install "libc-bin" DEB package to get ldd.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,14 @@
error.invalid-cfbundle-version.advice=Set a compatible 'app-version' value. Valid versions are one to three integers separated by dots.
error.explicit-sign-no-cert=Signature explicitly requested but no signing certificate found
error.explicit-sign-no-cert.advice=Specify a valid mac-signing-key-user-name and mac-signing-keychain
error.must-sign-app-store=Mac App Store apps must be signed, and signing has been disabled by bundler configuration
error.must-sign-app-store.advice=Use --mac-sign option with appropriate user-name and keychain
error.certificate.expired=Error: Certificate expired {0}
error.certificate.expired=Certificate expired {0}
error.cert.not.found=No certificate found matching [{0}] using keychain [{1}]
error.multiple.certs.found=Multiple certificates matching name [{0}] found in keychain [{1}]
error.app-image.mac-sign.required=Error: --mac-sign option is required with predefined application image and with type [app-image]
error.tool.failed.with.output=Error: "{0}" failed with following output:
error.app-image.mac-sign.required=--mac-sign option is required with predefined application image and with type [app-image]
error.tool.failed.with.output="{0}" failed with following output:
error.invalid-runtime-image-missing-file=Runtime image "{0}" is missing "{1}" file
error.invalid-runtime-image-bin-dir=Runtime image "{0}" should not contain "bin" folder
error.invalid-runtime-image-bin-dir.advice=Use --strip-native-commands jlink option when generating runtime image used with {0} option
resource.bundle-config-file=Bundle config file
resource.app-info-plist=Application Info.plist
resource.app-runtime-info-plist=Embedded Java Runtime Info.plist
resource.runtime-info-plist=Java Runtime Info.plist
Expand All @@ -59,14 +56,10 @@ message.preparing-info-plist=Preparing Info.plist: {0}.
message.icon-not-icns= The specified icon "{0}" is not an ICNS file and will not be used. The default icon will be used in it's place.
message.version-string-too-many-components='app-version' may have between 1 and 3 numbers: 1, 1.2, 1.2.3.
message.version-string-first-number-not-zero=The first number in an app-version cannot be zero or negative.
message.creating-association-with-null-extension=Creating association with null extension.
message.ignoring.symlink=Warning: codesign is skipping the symlink {0}.
message.already.signed=File already signed: {0}.
message.keychain.error=Error: unable to get keychain list.
message.invalid-identifier=invalid mac bundle identifier [{0}].
message.keychain.error=Unable to get keychain list.
message.invalid-identifier=Invalid mac bundle identifier [{0}].
message.invalid-identifier.advice=specify identifier with "--mac-package-identifier".
message.building-dmg=Building DMG package for {0}.
message.running-script=Running shell script on application image [{0}].
message.preparing-dmg-setup=Preparing dmg setup: {0}.
message.creating-dmg-file=Creating DMG file: {0}.
message.dmg-cannot-be-overwritten=Dmg file exists [{0}] and can not be removed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
*/
package jdk.jpackage.internal;

import java.io.IOException;
import java.nio.file.Files;
import static jdk.jpackage.internal.cli.StandardValidator.IS_DIRECTORY_EMPTY_OR_NON_EXISTENT_PREDICATE;

import java.nio.file.Path;
import java.util.Objects;
import java.util.Optional;
Expand All @@ -41,19 +41,11 @@ final class BuildEnvBuilder {
}

BuildEnv create() {
var exceptionBuilder = I18N.buildConfigException("ERR_BuildRootInvalid", root);
if (Files.isDirectory(root)) {
try (var rootDirContents = Files.list(root)) {
if (rootDirContents.findAny().isPresent()) {
// The root directory is not empty.
throw exceptionBuilder.create();
}
} catch (IOException ioe) {
throw exceptionBuilder.cause(ioe).create();
}
} else if (Files.exists(root)) {
// The root is not a directory.
throw exceptionBuilder.create();
// The directory should be validated earlier with a proper error message.
// Here is only a sanity check.
if (!IS_DIRECTORY_EMPTY_OR_NON_EXISTENT_PREDICATE.test(root)) {
throw new UnsupportedOperationException(
String.format("Root work directory [%s] should be empty or non existent", root));
}

return BuildEnv.create(root, Optional.ofNullable(resourceDir), verbose,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,13 +418,10 @@ Optional<ExceptionWithOrigin> validate(Options cmdline) {
asOptionList(PREDEFINED_RUNTIME_IMAGE, ADD_MODULES),
asOptionList(PREDEFINED_RUNTIME_IMAGE, JLINK_OPTIONS),
asOptionList(MAC_SIGNING_KEY_NAME, MAC_APP_IMAGE_SIGN_IDENTITY),
asOptionList(MAC_SIGNING_KEY_NAME, MAC_INSTALLER_SIGN_IDENTITY)
asOptionList(MAC_SIGNING_KEY_NAME, MAC_INSTALLER_SIGN_IDENTITY),
asOptionList(MODULE, MAIN_JAR)
).map(MutualExclusiveOptions::new).forEach(config::add);

config.add(new MutualExclusiveOptions(asOptionList(MODULE, MAIN_JAR), _ -> {
return error("ERR_BothMainJarAndModule");
}));

MUTUAL_EXCLUSIVE_OPTIONS = List.copyOf(config);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import static jdk.jpackage.internal.cli.StandardBundlingOperation.SIGN_MAC_APP_IMAGE;
import static jdk.jpackage.internal.cli.StandardBundlingOperation.fromOptionName;
import static jdk.jpackage.internal.cli.StandardOptionContext.createOptionSpecBuilderMutator;
import static jdk.jpackage.internal.cli.StandardOptionValueExceptionFactory.ERROR_WITHOUT_CONTEXT;
import static jdk.jpackage.internal.cli.StandardOptionValueExceptionFactory.ERROR_WITH_VALUE;
import static jdk.jpackage.internal.cli.StandardOptionValueExceptionFactory.ERROR_WITH_VALUE_AND_OPTION_NAME;
import static jdk.jpackage.internal.cli.StandardOptionValueExceptionFactory.forMessageWithOptionValueAndName;
Expand Down Expand Up @@ -177,10 +176,7 @@ public boolean test(Path path) {

public static final OptionValue<String> COPYRIGHT = stringOption("copyright").valuePattern("copyright string").create();

public static final OptionValue<Path> LICENSE_FILE = fileOption("license-file")
.validatorExceptionFormatString("ERR_LicenseFileNotExit")
.validatorExceptionFactory(ERROR_WITHOUT_CONTEXT)
.create();
public static final OptionValue<Path> LICENSE_FILE = fileOption("license-file").create();

public static final OptionValue<String> APP_VERSION = stringOption("app-version").create();

Expand Down Expand Up @@ -216,12 +212,10 @@ public boolean test(Path path) {
.validatorExceptionFactory((optionName, optionValue, formatString, cause) -> {
if (cause.orElseThrow() instanceof StandardValidator.DirectoryListingIOException) {
formatString = "error.path-parameter-ioexception";
return ERROR_WITH_VALUE_AND_OPTION_NAME.create(optionName, optionValue, formatString, cause);
} else {
return ERROR_WITH_VALUE.create(optionName, optionValue, formatString, cause);
}
return ERROR_WITH_VALUE_AND_OPTION_NAME.create(optionName, optionValue, formatString, cause);
})
.validatorExceptionFormatString("ERR_BuildRootInvalid")
.validatorExceptionFormatString("error.parameter-not-empty-directory")
.validator(StandardValidator.IS_DIRECTORY_EMPTY_OR_NON_EXISTENT)
.create();

Expand All @@ -236,8 +230,6 @@ public boolean test(Path path) {

public static final OptionValue<Path> PREDEFINED_APP_IMAGE = directoryOption("app-image")
.scope(CREATE_NATIVE).inScope(SIGN_MAC_APP_IMAGE).inScope(BundlingOperationModifier.BUNDLE_PREDEFINED_APP_IMAGE)
.validatorExceptionFactory(ERROR_WITH_VALUE)
.validatorExceptionFormatString("ERR_AppImageNotExist")
.mutate(createOptionSpecBuilderMutator((b, context) -> {
if (context.os() == OperatingSystem.MACOS) {
b.description("help.option.app-image" + resourceKeySuffix(context.os()));
Expand Down Expand Up @@ -538,7 +530,7 @@ static Consumer<OptionSpecBuilder<LauncherShortcut>> launcherShortcutOptionMutat
});
}))
.converterExceptionFactory(ERROR_WITH_VALUE_AND_OPTION_NAME)
.converterExceptionFormatString("error.invalid-option-value")
.converterExceptionFormatString("error.parameter-not-launcher-shortcut-dir")
.converter(mainLauncherShortcutConv())
.defaultOptionalValue(new LauncherShortcut(LauncherShortcutStartupDirectory.DEFAULT))
.valuePattern("shortcut startup directory");
Expand Down Expand Up @@ -637,8 +629,8 @@ private static OptionValue<AdditionalLauncher[]> createAddLauncherOption(String
.converterExceptionFactory((optionName, optionValue, formatString, cause) -> {
final var theCause = cause.orElseThrow();
if (theCause instanceof AddLauncherSyntaxException) {
return ERROR_WITHOUT_CONTEXT.create(optionName,
optionValue, "ERR_NoAddLauncherName", cause);
return ERROR_WITH_VALUE_AND_OPTION_NAME.create(optionName,
optionValue, "error.parameter-add-launcher-malformed", cause);
} else {
return (RuntimeException)theCause;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,10 @@

final class StandardOptionValueExceptionFactory {

static OptionValueExceptionFactory<JPackageException> forMessageWithOptionValue(Path propertyFile) {
return forMessageWithOptionValue(appendPath(propertyFile)).printOptionPrefix(false).create();
}

static OptionValueExceptionFactory<JPackageException> forMessageWithOptionValueAndName(Path propertyFile) {
return forMessageWithOptionValueAndName(appendPath(propertyFile)).printOptionPrefix(false).create();
}

static OptionValueExceptionFactory<JPackageException> forFixedMessage(Path propertyFile) {
return forFixedMessage(appendPath(propertyFile)).printOptionPrefix(false).create();
}

private StandardOptionValueExceptionFactory() {
}

Expand All @@ -63,17 +55,9 @@ private static OptionValueExceptionFactory.Builder<JPackageException> forMessage
.formatArgumentsTransformer(mapper.apply(StandardArgumentsMapper.VALUE_AND_NAME));
}

private static OptionValueExceptionFactory.Builder<JPackageException> forFixedMessage(UnaryOperator<ArgumentsMapper> mapper) {
return OptionValueExceptionFactory.build(JPackageException::new)
.formatArgumentsTransformer(mapper.apply(StandardArgumentsMapper.NONE));
}

static final OptionValueExceptionFactory<JPackageException> ERROR_WITH_VALUE =
forMessageWithOptionValue(UnaryOperator.identity()).create();

static final OptionValueExceptionFactory<JPackageException> ERROR_WITHOUT_CONTEXT =
forFixedMessage(UnaryOperator.identity()).create();

static final OptionValueExceptionFactory<JPackageException> ERROR_WITH_VALUE_AND_OPTION_NAME =
forMessageWithOptionValueAndName(UnaryOperator.identity()).create();
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ message.creating-app-bundle=Creating app package: {0} in {1}
message.debug-working-directory=Kept working directory for debug: {0}
message.bundle-created=Succeeded in building {0} package
message.module-version=Using version "{0}" from module "{1}" as application version
message.module-class=Using class "{0}" from module "{1}" as application main class

message.error-header={0}
message.advice-header=Advice to fix: {0}
Expand All @@ -58,7 +57,7 @@ error.version-string-invalid-component=Version [{0}] contains invalid component

error.cannot-create-output-dir=Destination directory {0} cannot be created
error.cannot-write-to-output-dir=Destination directory {0} is not writable
error.root-exists=Error: Application destination directory {0} already exists
error.root-exists=Application destination directory {0} already exists
error.no-main-class-with-main-jar=A main class was not specified nor was one found in the jar {0}
error.no-main-class-with-main-jar.advice=Specify a main class or ensure that the jar {0} specifies one in the manifest
error.main-jar-does-not-exist=The configured main jar does not exist {0} in the input directory
Expand All @@ -73,6 +72,7 @@ error.parameter-not-uuid=The value "{0}" provided for parameter {1} is not a val
error.parameter-not-path=The value "{0}" provided for parameter {1} is not a valid path
error.parameter-not-file=The value "{0}" provided for parameter {1} is not a file
error.parameter-not-directory=The value "{0}" provided for parameter {1} is not a directory
error.parameter-not-empty-directory=The value "{0}" provided for parameter {1} is not an empty directory or non existent path
error.parameter-not-url=The value "{0}" provided for parameter {1} is not a valid URL
error.parameter-not-launcher-shortcut-dir=The value "{0}" provided for parameter {1} is not a valid shortcut startup directory
error.path-parameter-ioexception=I/O error accessing path value "{0}" of parameter {1}
Expand Down Expand Up @@ -101,33 +101,25 @@ error.blocked.option=jlink option [{0}] is not permitted in --jlink-options
error.no.name=Name not specified with --name and cannot infer one from app-image
error.no.name.advice=Specify name with --name

error.missing-app-image-file=Error: "{0}" file is missing in the predefined app image "{1}"
error.invalid-app-image-file=Error: "{0}" file in the predefined app image "{1}" is corrupted or was created by another version of jpackage
error.malformed-app-image-file=Error: "{0}" file in the predefined app image "{1}" contains malformed XML data
error.reading-app-image-file=Error: Failed to read "{0}" file in the predefined app image "{1}"
error.missing-app-image-file="{0}" file is missing in the predefined app image "{1}"
error.invalid-app-image-file="{0}" file in the predefined app image "{1}" is corrupted or was created by another version of jpackage
error.malformed-app-image-file="{0}" file in the predefined app image "{1}" contains malformed XML data
error.reading-app-image-file=Failed to read "{0}" file in the predefined app image "{1}"

error.invalid-install-dir=Invalid installation directory "{0}"

error.invalid-option-value=Invalid value "{0}" of option {1}

ERR_NoMainClass=Error: Main application class is missing
ERR_UnsupportedOption=Error: Option [{0}] is not valid on this platform
ERR_InvalidTypeOption=Error: Option [{0}] is not valid with type [{1}]
ERR_NoInstallerEntryPoint=Error: Option [{0}] is not valid without --module or --main-jar entry point option
ERR_MutuallyExclusiveOptions=Error: Mutually exclusive options [{0}] and [{1}]
ERR_InvalidOptionWithAppImageSigning=Error: Option [{0}] is not valid when signing application image

ERR_MissingArgument=Error: Missing argument: {0}
ERR_MissingArgument2=Error: Missing argument: {0} or {1}
ERR_AppImageNotExist=Error: App image directory "{0}" does not exist
ERR_NoAddLauncherName=Error: --add-launcher option requires a name and a file path (--add-launcher <name>=<file path>)
ERR_InvalidAppName=Error: Invalid Application name: {0}
ERR_InvalidSLName=Error: Invalid Add Launcher name: {0}
ERR_LicenseFileNotExit=Error: Specified license file does not exist
ERR_BuildRootInvalid=Error: temp ({0}) must be non-existent or empty directory
ERR_InvalidOption=Error: Invalid Option: [{0}]
ERR_InvalidInstallerType=Error: Invalid or unsupported type: [{0}]
ERR_BothMainJarAndModule=Error: Cannot have both --main-jar and --module Options
ERR_NoEntryPoint=Error: creating application image requires --main-jar or --module Option
ERR_CannotParseOptions=Error: Processing @filename option: {0}
ERR_MissingJLinkOptMacAppStore=Error: --mac-app-store argument requires a {0} option for --jlink-options argument
ERR_NoMainClass=Main application class is missing
ERR_UnsupportedOption=Option [{0}] is not valid on this platform
ERR_InvalidTypeOption=Option [{0}] is not valid with type [{1}]
ERR_NoInstallerEntryPoint=Option [{0}] is not valid without --module or --main-jar entry point option
ERR_MutuallyExclusiveOptions=Mutually exclusive options [{0}] and [{1}]
ERR_InvalidOptionWithAppImageSigning=Option [{0}] is not valid when signing application image

ERR_MissingArgument2=Missing argument: {0} or {1}
ERR_InvalidAppName=Invalid Application name: {0}
ERR_InvalidSLName=Invalid Add Launcher name: {0}
ERR_InvalidOption=Invalid Option: [{0}]
ERR_InvalidInstallerType=Invalid or unsupported type: [{0}]
ERR_NoEntryPoint=creating application image requires --main-jar or --module Option
ERR_CannotParseOptions=Processing @filename option: {0}
ERR_MissingJLinkOptMacAppStore=--mac-app-store argument requires a {0} option for --jlink-options argument
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
param.menu-group.default=Unknown

resource.executable-properties-template=Template for creating executable properties file
resource.setup-icon=setup dialog icon
resource.post-msi-script=script to run after msi file for exe installer is created
resource.wxl-file=WiX localization file
resource.main-wix-file=Main WiX project file
Expand Down Expand Up @@ -60,12 +59,10 @@ message.potential.windows.defender.issue=Warning: Windows Defender may prevent j
message.outputting-to-location=Generating EXE for installer to: {0}.
message.output-location=Installer (.exe) saved to: {0}
message.tool-version=Detected [{0}] version [{1}].
message.creating-association-with-null-extension=Creating association with null extension.
message.wrong-tool-version=Detected [{0}] version {1} but version {2} is required.
message.use-wix36-features=WiX {0} detected. Enabling advanced cleanup action.
message.product-code=MSI ProductCode: {0}.
message.upgrade-code=MSI UpgradeCode: {0}.
message.preparing-msi-config=Preparing MSI config: {0}.
message.generating-msi=Generating MSI: {0}.
message.invalid.install.dir=Warning: Invalid install directory {0}. Install directory should be a relative sub-path under the default installation location such as "Program Files". Defaulting to application name "{1}".

Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ public void testBundlingOperationConfigurationErrors(@TempDir Path workDir) {
@Test
public void testMultipleCommandLineStructureAnalyzerErrors() {
build().createAppImageByDefault().expectValidationErrors(
new JPackageException(I18N.format("ERR_BothMainJarAndModule")),
new JPackageException(I18N.format("ERR_MutuallyExclusiveOptions", "-m", "--main-jar")),
new JPackageException(I18N.format("ERR_MissingArgument2", "--runtime-image", "--module-path")),
new JPackageException(I18N.format("error.no-input-parameter"))
).validationErrorsOrdered(false).create("-m", "com.foo", "--main-jar", "main.jar").validate();
Expand Down
Loading