Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
8251988: jpackage --runtime-image fails on mac when using JDK11 based…
… runtime

Reviewed-by: asemenyuk, almatvee, prr
  • Loading branch information
Andy Herrick committed Aug 25, 2020
1 parent bb354b9 commit 5bdf05590f0c84888b9c8bb3297ad647e6b77113
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 96 deletions.
@@ -52,6 +52,8 @@ void initJvmLauncher() {
jvmLauncher = AppLauncher()
.setImageRoot(appImageRoot)
.addJvmLibName(_T("Contents/Home/lib/libjli.dylib"))
// add backup - older version such as JDK11 have it in jli sub-dir
.addJvmLibName(_T("Contents/Home/lib/jli/libjli.dylib"))
.setAppDir(FileUtils::mkpath() << appImageRoot << _T("Contents/app"))
.setDefaultRuntimePath(FileUtils::mkpath() << appImageRoot
<< _T("Contents/runtime"))
@@ -25,6 +25,7 @@
package jdk.incubator.jpackage.internal;

import java.io.IOException;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
@@ -35,6 +36,7 @@
import static jdk.incubator.jpackage.internal.StandardBundlerParam.APP_NAME;
import static jdk.incubator.jpackage.internal.StandardBundlerParam.JAVA_OPTIONS;
import static jdk.incubator.jpackage.internal.StandardBundlerParam.ARGUMENTS;
import static jdk.incubator.jpackage.internal.StandardBundlerParam.VERSION;

/**
* App launcher's config file.
@@ -49,6 +51,7 @@ CfgFile initFromParams(Map<String, ? super Object> params) {
launcherName = APP_NAME.fetchFrom(params);
javaOptions = JAVA_OPTIONS.fetchFrom(params);
arguments = ARGUMENTS.fetchFrom(params);
version = VERSION.fetchFrom(params);
return this;
}

@@ -82,11 +85,20 @@ void create(Path appImage) throws IOException {

ApplicationLayout appImagelayout = appLayout.resolveAt(appImage);
Path modsDir = appImagelayout.appModsDirectory();
if (!javaOptions.isEmpty() || Files.isDirectory(modsDir)) {
content.add(Map.entry("[JavaOptions]", SECTION_TAG));
for (var value : javaOptions) {
content.add(Map.entry("java-options", value));
}

content.add(Map.entry("[JavaOptions]", SECTION_TAG));

// always let app know it's version
content.add(Map.entry(
"java-options", "-Djpackage.app-version=" + version));

// add user supplied java options if there are any
for (var value : javaOptions) {
content.add(Map.entry("java-options", value));
}

// add module path if there is one
if (Files.isDirectory(modsDir)) {
content.add(Map.entry("java-options", "--module-path"));
content.add(Map.entry("java-options",
appCfgLayout.appModsDirectory()));
@@ -126,6 +138,7 @@ private ApplicationLayout createAppCfgLayout() {
}

private String launcherName;
private String version;
private LauncherData launcherData;
List<String> arguments;
List<String> javaOptions;
@@ -89,6 +89,11 @@ Jvm& Jvm::initFromConfigFile(const CfgFile& cfgFile) {
}
} while (0);

do {
addArgument(_T("-Djpackage.app-path=")
+ SysInfo::getProcessModulePath());
} while (0);

// No validation of data in config file related to how Java app should be
// launched intentionally.
// Just read what is in config file and put on jvm's command line as is.

This file was deleted.

This file was deleted.

@@ -68,7 +68,13 @@ private static List<String> printArgs(String[] args) {

lines.add("args.length: " + args.length);

lines.addAll(List.of(args));
for (String arg : args) {
if (arg.startsWith("jpackage.app")) {
lines.add(arg + "=" + System.getProperty(arg));
} else {
lines.add(arg);
}
}

for (int index = 1; index <= EXPECTED_NUM_OF_PARAMS; index++) {
String value = System.getProperty("param" + index);
@@ -64,6 +64,28 @@ public void testNoArgs() {
output, "Check jpackage output");
}

@Test
public void testJpackageProps() {
String appVersion = "3.0";
JPackageCommand cmd = JPackageCommand.helloAppImage(
JavaAppDesc.parse("Hello"))
// Disable default logic adding `--verbose` option
// to jpackage command line.
.ignoreDefaultVerbose(true)
.saveConsoleOutput(true)
.addArguments("--app-version", appVersion, "--arguments",
"jpackage.app-version jpackage.app-path")
.ignoreDefaultRuntime(true);

cmd.executeAndAssertImageCreated();
Path launcherPath = cmd.appLauncherPath();

List<String> output = HelloApp.executeLauncher(cmd).getOutput();

TKit.assertTextStream("jpackage.app-version=" + appVersion).apply(output.stream());
TKit.assertTextStream("jpackage.app-path=").apply(output.stream());
}

@Test
public void testVersion() {
List<String> output =

0 comments on commit 5bdf055

Please sign in to comment.