8253426: jpackage is unable to generate working EXE for add-launcher configurations

Reviewed-by: almatvee, kizune, asemenyuk
This commit is contained in:
Andy Herrick 2020-10-05 21:10:48 +00:00
parent c9d0407e94
commit 4fe68f55a4
3 changed files with 33 additions and 3 deletions

View File

@ -30,6 +30,7 @@ import java.util.HashMap;
import java.util.Map;
import java.util.List;
import jdk.incubator.jpackage.internal.Arguments.CLIOptions;
import static jdk.incubator.jpackage.internal.StandardBundlerParam.LAUNCHER_DATA;
/*
* AddLauncherArguments
@ -157,6 +158,9 @@ class AddLauncherArguments {
Map<String, ? super Object> tmp = new HashMap<>(original);
List.of(exclude).forEach(tmp::remove);
// remove LauncherData from map so it will re-run the defaultValueFunction
tmp.remove(LAUNCHER_DATA.getID());
if (additional.containsKey(CLIOptions.MODULE.getId())) {
tmp.remove(CLIOptions.MAIN_JAR.getId());
tmp.remove(CLIOptions.APPCLASS.getId());

View File

@ -791,11 +791,11 @@ public final class JPackageCommand extends CommandArguments<JPackageCommand> {
}
}
public CfgFile readLaunherCfgFile() {
return readLaunherCfgFile(null);
public CfgFile readLauncherCfgFile() {
return readLauncherCfgFile(null);
}
public CfgFile readLaunherCfgFile(String launcherName) {
public CfgFile readLauncherCfgFile(String launcherName) {
verifyIsOfType(PackageType.IMAGE);
if (isRuntime()) {
return null;

View File

@ -22,6 +22,7 @@
*/
import java.nio.file.Path;
import java.io.File;
import java.util.Map;
import java.lang.invoke.MethodHandles;
import jdk.jpackage.test.PackageTest;
@ -32,6 +33,7 @@ import jdk.jpackage.test.JavaAppDesc;
import jdk.jpackage.test.TKit;
import jdk.jpackage.test.Annotations.Test;
import jdk.jpackage.test.Annotations.Parameter;
import jdk.jpackage.test.CfgFile;
/**
* Test --add-launcher parameter. Output of the test should be
@ -200,6 +202,30 @@ public class AddLauncherTest {
.applyTo(cmd);
cmd.executeAndAssertHelloAppImageCreated();
// check value of app.mainmodule in ModularAppLauncher's cfg file
CfgFile cfg = cmd.readLauncherCfgFile("ModularAppLauncher");
String moduleValue = cfg.getValue("Application", "app.mainmodule");
String mainClass = null;
String classpath = null;
String expectedMod = JavaAppDesc.parse(
modularAppDesc.toString()).setBundleFileName(null).toString();
TKit.assertEquals(expectedMod, moduleValue,
String.format("Check value of app.mainmodule=[%s]" +
"in ModularAppLauncher cfg file is as expected", expectedMod));
// check values of app.mainclass and app.classpath in cfg file
cfg = cmd.readLauncherCfgFile("NonModularAppLauncher");
moduleValue = null;
mainClass = cfg.getValue("Application", "app.mainclass");
classpath = cfg.getValue("Application", "app.classpath");
String ExpectedCN = nonModularAppDesc.className();
TKit.assertEquals(ExpectedCN, mainClass,
String.format("Check value of app.mainclass=[%s]" +
"in NonModularAppLauncher cfg file is as expected", ExpectedCN));
TKit.assertTrue(classpath.startsWith("$APPDIR" + File.separator
+ nonModularAppDesc.jarFileName()),
"Check app.classpath value in ModularAppLauncher cfg file");
}
private final static Path GOLDEN_ICON = TKit.TEST_SRC_ROOT.resolve(Path.of(