8251988: jpackage --runtime-image fails on mac when using JDK11 based runtime
Reviewed-by: asemenyuk, almatvee, prr
This commit is contained in:
parent
d4626d89cc
commit
9e6782d24b
@ -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.LAUNCHER_DATA
|
||||
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 @@ final class CfgFile {
|
||||
launcherName = APP_NAME.fetchFrom(params);
|
||||
javaOptions = JAVA_OPTIONS.fetchFrom(params);
|
||||
arguments = ARGUMENTS.fetchFrom(params);
|
||||
version = VERSION.fetchFrom(params);
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -82,11 +85,20 @@ final class CfgFile {
|
||||
|
||||
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 @@ final class CfgFile {
|
||||
}
|
||||
|
||||
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.
|
||||
|
@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.hello;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
public class Hello {
|
||||
|
||||
private static final String MSG = "jpackage test application";
|
||||
private static final int EXPECTED_NUM_OF_PARAMS = 3; // Starts at 1
|
||||
|
||||
public static void main(String[] args) {
|
||||
String outputFile = "appOutput.txt";
|
||||
File file = new File(outputFile);
|
||||
|
||||
try (PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(file)))) {
|
||||
System.out.println(MSG);
|
||||
out.println(MSG);
|
||||
|
||||
System.out.println("args.length: " + args.length);
|
||||
out.println("args.length: " + args.length);
|
||||
|
||||
for (String arg : args) {
|
||||
System.out.println(arg);
|
||||
out.println(arg);
|
||||
}
|
||||
|
||||
for (int index = 1; index <= EXPECTED_NUM_OF_PARAMS; index++) {
|
||||
String value = System.getProperty("param" + index);
|
||||
if (value != null) {
|
||||
System.out.println("-Dparam" + index + "=" + value);
|
||||
out.println("-Dparam" + index + "=" + value);
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
System.err.println(ex.toString());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
module com.hello {
|
||||
exports com.hello;
|
||||
}
|
@ -68,7 +68,13 @@ public class Hello implements OpenFilesHandler {
|
||||
|
||||
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 final class BasicTest {
|
||||
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 =
|
||||
|
Loading…
Reference in New Issue
Block a user