8261839: Error creating runtime package on macos without mac-package-identifier

Reviewed-by: asemenyuk, almatvee, kizune
This commit is contained in:
Andy Herrick 2021-03-01 19:33:27 +00:00
parent 682e120235
commit 642f45f9dc
4 changed files with 19 additions and 16 deletions

View File

@ -110,11 +110,13 @@ public class MacAppImageBuilder extends AbstractAppImageBuilder {
// Get identifier from app image if user provided // Get identifier from app image if user provided
// app image and did not provide the identifier via CLI. // app image and did not provide the identifier via CLI.
String identifier = extractBundleIdentifier(params); String identifier = extractBundleIdentifier(params);
if (identifier != null) { if (identifier == null) {
return identifier; identifier = MacAppBundler.getIdentifier(params);
} }
if (identifier == null) {
return MacAppBundler.getIdentifier(params); identifier = APP_NAME.fetchFrom(params);
}
return identifier;
}, },
(s, p) -> s); (s, p) -> s);

View File

@ -723,7 +723,7 @@ public final class JPackageCommand extends CommandArguments<JPackageCommand> {
.filter(path -> path.getFileName().equals(appImageFileName)) .filter(path -> path.getFileName().equals(appImageFileName))
.map(Path::toString) .map(Path::toString)
.collect(Collectors.toList()); .collect(Collectors.toList());
if (isImagePackageType() || TKit.isOSX()) { if (isImagePackageType() || (TKit.isOSX() && !isRuntime())) {
List<String> expected = List.of( List<String> expected = List.of(
AppImageFile.getPathInAppImage(rootDir).toString()); AppImageFile.getPathInAppImage(rootDir).toString());
TKit.assertStringListEquals(expected, appImageFiles, TKit.assertStringListEquals(expected, appImageFiles,
@ -750,11 +750,11 @@ public final class JPackageCommand extends CommandArguments<JPackageCommand> {
if (!isRuntime()) { if (!isRuntime()) {
TKit.assertExecutableFileExists(appLauncherPath()); TKit.assertExecutableFileExists(appLauncherPath());
TKit.assertFileExists(appLauncherCfgPath(null)); TKit.assertFileExists(appLauncherCfgPath(null));
}
if (TKit.isOSX()) { if (TKit.isOSX()) {
TKit.assertFileExists(appRuntimeDirectory().resolve( TKit.assertFileExists(appRuntimeDirectory().resolve(
"Contents/MacOS/libjli.dylib")); "Contents/MacOS/libjli.dylib"));
}
} }
return this; return this;

View File

@ -62,7 +62,8 @@ public class MacHelper {
final Path mountPoint = Path.of(plist.queryValue("mount-point")); final Path mountPoint = Path.of(plist.queryValue("mount-point"));
try { try {
Path dmgImage = mountPoint.resolve(cmd.name() + ".app"); Path dmgImage = mountPoint.resolve(cmd.name() +
(cmd.isRuntime() ? "" : ".app"));
TKit.trace(String.format("Exploded [%s] in [%s] directory", TKit.trace(String.format("Exploded [%s] in [%s] directory",
cmd.outputBundle(), dmgImage)); cmd.outputBundle(), dmgImage));
ThrowingConsumer.toConsumer(consumer).accept(dmgImage); ThrowingConsumer.toConsumer(consumer).accept(dmgImage);
@ -215,7 +216,7 @@ public class MacHelper {
static Path getInstallationDirectory(JPackageCommand cmd) { static Path getInstallationDirectory(JPackageCommand cmd) {
cmd.verifyIsOfType(PackageType.MAC); cmd.verifyIsOfType(PackageType.MAC);
return Path.of(cmd.getArgumentValue("--install-dir", () -> "/Applications")) return Path.of(cmd.getArgumentValue("--install-dir", () -> "/Applications"))
.resolve(cmd.name() + ".app"); .resolve(cmd.name() + (cmd.isRuntime() ? "" : ".app"));
} }
private static String getPackageName(JPackageCommand cmd) { private static String getPackageName(JPackageCommand cmd) {

View File

@ -53,8 +53,6 @@ import jdk.jpackage.test.Annotations.Test;
* @library ../helpers * @library ../helpers
* @key jpackagePlatformPackage * @key jpackagePlatformPackage
* @build jdk.jpackage.test.* * @build jdk.jpackage.test.*
* @comment Temporary disable for OSX until functionality implemented
* @requires (os.family != "mac")
* @requires (jpackage.test.SQETest == null) * @requires (jpackage.test.SQETest == null)
* @modules jdk.jpackage/jdk.jpackage.internal * @modules jdk.jpackage/jdk.jpackage.internal
* @compile RuntimePackageTest.java * @compile RuntimePackageTest.java
@ -68,8 +66,6 @@ import jdk.jpackage.test.Annotations.Test;
* @library ../helpers * @library ../helpers
* @key jpackagePlatformPackage * @key jpackagePlatformPackage
* @build jdk.jpackage.test.* * @build jdk.jpackage.test.*
* @comment Temporary disable for OSX until functionality implemented
* @requires (os.family != "mac")
* @requires (jpackage.test.SQETest != null) * @requires (jpackage.test.SQETest != null)
* @modules jdk.jpackage/jdk.jpackage.internal * @modules jdk.jpackage/jdk.jpackage.internal
* @compile RuntimePackageTest.java * @compile RuntimePackageTest.java
@ -111,7 +107,11 @@ public class RuntimePackageTest {
}) })
.addInstallVerifier(cmd -> { .addInstallVerifier(cmd -> {
Set<Path> srcRuntime = listFiles(Path.of(cmd.getArgumentValue("--runtime-image"))); Set<Path> srcRuntime = listFiles(Path.of(cmd.getArgumentValue("--runtime-image")));
Set<Path> dstRuntime = listFiles(cmd.appRuntimeDirectory()); Path dest = cmd.appRuntimeDirectory();
if (TKit.isOSX()) {
dest = dest.resolve("Contents/Home");
}
Set<Path> dstRuntime = listFiles(dest);
Set<Path> intersection = new HashSet<>(srcRuntime); Set<Path> intersection = new HashSet<>(srcRuntime);
intersection.retainAll(dstRuntime); intersection.retainAll(dstRuntime);