Skip to content

Commit

Permalink
8253426: jpackage is unable to generate working EXE for add-launcher …
Browse files Browse the repository at this point in the history
…configurations

Reviewed-by: almatvee, kizune, asemenyuk
  • Loading branch information
Andy Herrick committed Oct 5, 2020
1 parent c9d0407 commit 4fe68f5
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
26 changes: 26 additions & 0 deletions test/jdk/tools/jpackage/share/AddLauncherTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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(
Expand Down

1 comment on commit 4fe68f5

@bridgekeeper
Copy link

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.