Skip to content
Permalink
Browse files

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

…configurations

Reviewed-by: almatvee, kizune, asemenyuk
  • Loading branch information
Andy Herrick
Andy Herrick committed Oct 5, 2020
1 parent c9d0407 commit 4fe68f55a4f6e0ae00eed2a7361276e38ce115bf
@@ -30,6 +30,7 @@
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 @@ private String getOptionValue(CLIOptions option) {
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());
@@ -791,11 +791,11 @@ public void verifyIsOfType(PackageType ... types) {
}
}

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;
@@ -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.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 void testMainLauncherIsModular(boolean mainLauncherIsModular) {
.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(

1 comment on commit 4fe68f5

@bridgekeeper

This comment has been minimized.

Copy link

@bridgekeeper bridgekeeper bot commented on 4fe68f5 Oct 5, 2020

Please sign in to comment.