Skip to content
Draft
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 @@ -27,8 +27,6 @@
import static jdk.jpackage.internal.FromOptions.buildApplicationBuilder;
import static jdk.jpackage.internal.FromOptions.createPackageBuilder;
import static jdk.jpackage.internal.MacPackagingPipeline.APPLICATION_LAYOUT;
import static jdk.jpackage.internal.MacRuntimeValidator.validateRuntimeHasJliLib;
import static jdk.jpackage.internal.MacRuntimeValidator.validateRuntimeHasNoBinDir;
import static jdk.jpackage.internal.OptionUtils.isBundlingOperation;
import static jdk.jpackage.internal.cli.StandardBundlingOperation.CREATE_MAC_PKG;
import static jdk.jpackage.internal.cli.StandardOption.APPCLASS;
Expand Down Expand Up @@ -203,12 +201,14 @@ private static ApplicationBuilder createApplicationBuilder(Options options) {
final var predefinedRuntimeLayout = PREDEFINED_RUNTIME_IMAGE.findIn(options)
.map(MacPackage::guessRuntimeLayout);

predefinedRuntimeLayout.ifPresent(layout -> {
validateRuntimeHasJliLib(layout);
if (MAC_APP_STORE.containsIn(options)) {
validateRuntimeHasNoBinDir(layout);
}
});
predefinedRuntimeLayout.ifPresent(MacRuntimeValidator::validateRuntimeHasJliLib);

if (MAC_APP_STORE.containsIn(options)) {
PREDEFINED_APP_IMAGE.findIn(options)
.map(APPLICATION_LAYOUT::resolveAt)
.ifPresent(MacRuntimeValidator::validateRuntimeHasNoBinDir);
predefinedRuntimeLayout.ifPresent(MacRuntimeValidator::validateRuntimeHasNoBinDir);
}

final var launcherFromOptions = new LauncherFromOptions().faMapper(MacFromOptions::createMacFa);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
import java.util.function.Predicate;
import jdk.jpackage.internal.model.AppImageLayout;
import jdk.jpackage.internal.model.ApplicationLayout;
import jdk.jpackage.internal.model.ConfigException;
import jdk.jpackage.internal.model.JPackageException;
import jdk.jpackage.internal.model.RuntimeLayout;

final class MacRuntimeValidator {
Expand All @@ -45,17 +49,29 @@ static void validateRuntimeHasJliLib(RuntimeLayout runtimeLayout) {
throw new UncheckedIOException(ex);
}

throw I18N.buildConfigException("error.invalid-runtime-image-missing-file",
throw new JPackageException(I18N.format("error.invalid-runtime-image-missing-file",
runtimeLayout.rootDirectory(),
runtimeLayout.unresolve().runtimeDirectory().resolve("lib/**").resolve(jliName)).create();
runtimeLayout.unresolve().runtimeDirectory().resolve("lib/**").resolve(jliName)));
}

static void validateRuntimeHasNoBinDir(RuntimeLayout runtimeLayout) {
if (Files.isDirectory(runtimeLayout.runtimeDirectory().resolve("bin"))) {
throw I18N.buildConfigException()
.message("error.invalid-runtime-image-bin-dir", runtimeLayout.rootDirectory())
.advice("error.invalid-runtime-image-bin-dir.advice", "--mac-app-store")
.create();
static void validateRuntimeHasNoBinDir(AppImageLayout appImageLayout) {
if (Files.isDirectory(appImageLayout.runtimeDirectory().resolve("bin"))) {
switch (appImageLayout) {
case RuntimeLayout runtimeLayout -> {
throw new ConfigException(
I18N.format("error.invalid-runtime-image-bin-dir", runtimeLayout.rootDirectory()),
I18N.format("error.invalid-runtime-image-bin-dir.advice", "--mac-app-store"));
}
case ApplicationLayout appLayout -> {
throw new JPackageException(I18N.format("error.invalid-app-image-runtime-image-bin-dir",
appLayout.rootDirectory().relativize(appLayout.runtimeDirectory()),
appLayout.rootDirectory()));
}
default -> {
throw new IllegalArgumentException();
}
}

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ 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=--mac-sign option is required with predefined application image and with type [app-image]
error.invalid-runtime-image-missing-file=Runtime image "{0}" is missing "{1}" file
error.invalid-app-image-runtime-image-bin-dir=Runtime directory {0} in the predefined application image [{1}] should not contain "bin" folder
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
error.invalid-app-image-plist-file=Invalid "{0}" file in the predefined application image
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ public boolean test(Path path) {

public static final OptionValue<Boolean> MAC_SIGN = booleanOption("mac-sign").scope(MAC_SIGNING).addAliases("s").create();

public static final OptionValue<Boolean> MAC_APP_STORE = booleanOption("mac-app-store").create();
public static final OptionValue<Boolean> MAC_APP_STORE = booleanOption("mac-app-store").scope(MAC_SIGNING).create();

public static final OptionValue<String> MAC_APP_CATEGORY = stringOption("mac-app-category").create();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
| --linux-shortcut | linux-deb, linux-rpm | x | x | x | USE_LAST |
| --mac-app-category | mac-bundle | x | x | | USE_LAST |
| --mac-app-image-sign-identity | mac | x | x | | USE_LAST |
| --mac-app-store | mac-bundle | x | x | | USE_LAST |
| --mac-app-store | mac | x | x | | USE_LAST |
| --mac-dmg-content | mac-dmg | x | x | | CONCATENATE |
| --mac-entitlements | mac | x | x | | USE_LAST |
| --mac-installer-sign-identity | mac-pkg | x | x | | USE_LAST |
Expand Down