8171959: add-launcher is not working when normal jar is used for first launcher and module is used for second launcher
Reviewed-by: almatvee
--- a/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxAppImageBuilder.java Mon Mar 11 21:00:22 2019 -0400
+++ b/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxAppImageBuilder.java Mon Mar 11 21:04:21 2019 -0400
@@ -193,9 +193,8 @@
List<Map<String, ? super Object>> entryPoints
= StandardBundlerParam.ADD_LAUNCHERS.fetchFrom(params);
for (Map<String, ? super Object> entryPoint : entryPoints) {
- Map<String, ? super Object> tmp = new HashMap<>(originalParams);
- tmp.putAll(entryPoint);
- createLauncherForEntryPoint(tmp, root);
+ createLauncherForEntryPoint(
+ AddLauncherArguments.merge(originalParams, entryPoint));
}
// Copy class path entries to Java folder
--- a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacAppImageBuilder.java Mon Mar 11 21:00:22 2019 -0400
+++ b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacAppImageBuilder.java Mon Mar 11 21:04:21 2019 -0400
@@ -323,8 +323,8 @@
List<Map<String, ? super Object>> entryPoints =
StandardBundlerParam.ADD_LAUNCHERS.fetchFrom(params);
for (Map<String, ? super Object> entryPoint : entryPoints) {
- Map<String, ? super Object> tmp = new HashMap<>(originalParams);
- tmp.putAll(entryPoint);
+ Map<String, ? super Object> tmp =
+ AddLauncherArguments.merge(originalParams, entryPoint);
// add executable for add launcher
Path addExecutable = macOSDir.resolve(getLauncherName(tmp));
--- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/AddLauncherArguments.java Mon Mar 11 21:00:22 2019 -0400
+++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/AddLauncherArguments.java Mon Mar 11 21:04:21 2019 -0400
@@ -164,4 +164,22 @@
params.put(param, value);
}
}
+
+ static Map<String, ? super Object> merge(
+ Map<String, ? super Object> original,
+ Map<String, ? super Object> additional) {
+ Map<String, ? super Object> tmp = new HashMap<>(original);
+ if (additional.containsKey("module")) {
+ tmp.remove("main-jar");
+ tmp.remove("main-class");
+ } else if (additional.containsKey("main-jar")) {
+ tmp.remove("module");
+ // should we only remove add-modules when it wasn't actually passed
+ // but was inferred or empty ?
+ tmp.remove("add-modules");
+ }
+ tmp.putAll(additional);
+ return tmp;
+ }
+
}
--- a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WindowsAppImageBuilder.java Mon Mar 11 21:00:22 2019 -0400
+++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WindowsAppImageBuilder.java Mon Mar 11 21:04:21 2019 -0400
@@ -254,9 +254,8 @@
List<Map<String, ? super Object>> entryPoints =
StandardBundlerParam.ADD_LAUNCHERS.fetchFrom(params);
for (Map<String, ? super Object> entryPoint : entryPoints) {
- Map<String, ? super Object> tmp = new HashMap<>(originalParams);
- tmp.putAll(entryPoint);
- createLauncherForEntryPoint(tmp);
+ createLauncherForEntryPoint(
+ AddLauncherArguments.merge(originalParams, entryPoint));
}
}