# HG changeset patch # User herrick # Date 1555630615 14400 # Node ID a30edd277572cb938edbe79101ec9b076e9752e9 # Parent 8009cf5b833dacebbafc05d14f1b72c6d46c62b8 8222733: Modify jpackage option --add-launcher synta Reviewed-by: kbr, almatvee diff -r 8009cf5b833d -r a30edd277572 src/jdk.jpackage/share/classes/jdk/jpackage/internal/AddLauncherArguments.java --- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/AddLauncherArguments.java Mon Apr 15 12:03:26 2019 -0400 +++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/AddLauncherArguments.java Thu Apr 18 19:36:55 2019 -0400 @@ -49,7 +49,6 @@ * * The add-launcher properties file may have any of: * - * name (required) * appVersion * module * add-modules @@ -63,11 +62,13 @@ */ class AddLauncherArguments { + private final String name; private final String filename; private Map allArgs; private Map bundleParams; - AddLauncherArguments(String filename) { + AddLauncherArguments(String name, String filename) { + this.name = name; this.filename = filename; } @@ -77,6 +78,7 @@ } allArgs = Arguments.getPropertiesFromFile(filename); + allArgs.put(CLIOptions.NAME.getId(), name); bundleParams = new HashMap<>(); String mainJar = getOptionValue(CLIOptions.MAIN_JAR); @@ -84,34 +86,34 @@ String module = getOptionValue(CLIOptions.MODULE); if (module != null && mainClass != null) { - putUnlessNull(bundleParams, Arguments.CLIOptions.MODULE.getId(), + putUnlessNull(bundleParams, CLIOptions.MODULE.getId(), module + "/" + mainClass); } else if (module != null) { - putUnlessNull(bundleParams, Arguments.CLIOptions.MODULE.getId(), + putUnlessNull(bundleParams, CLIOptions.MODULE.getId(), module); } else { - putUnlessNull(bundleParams, Arguments.CLIOptions.MAIN_JAR.getId(), + putUnlessNull(bundleParams, CLIOptions.MAIN_JAR.getId(), mainJar); - putUnlessNull(bundleParams, Arguments.CLIOptions.APPCLASS.getId(), + putUnlessNull(bundleParams, CLIOptions.APPCLASS.getId(), mainClass); } - putUnlessNull(bundleParams, Arguments.CLIOptions.NAME.getId(), + putUnlessNull(bundleParams, CLIOptions.NAME.getId(), getOptionValue(CLIOptions.NAME)); - putUnlessNull(bundleParams, Arguments.CLIOptions.VERSION.getId(), + putUnlessNull(bundleParams, CLIOptions.VERSION.getId(), getOptionValue(CLIOptions.VERSION)); putUnlessNull(bundleParams, - Arguments.CLIOptions.ADD_MODULES.getId(), + CLIOptions.ADD_MODULES.getId(), getOptionValue(CLIOptions.ADD_MODULES)); putUnlessNull(bundleParams, - Arguments.CLIOptions.WIN_CONSOLE_HINT.getId(), + CLIOptions.WIN_CONSOLE_HINT.getId(), getOptionValue(CLIOptions.WIN_CONSOLE_HINT)); String value = getOptionValue(CLIOptions.ICON); - putUnlessNull(bundleParams, Arguments.CLIOptions.ICON.getId(), + putUnlessNull(bundleParams, CLIOptions.ICON.getId(), (value == null) ? null : new File(value)); String argumentStr = getOptionValue(CLIOptions.ARGUMENTS); diff -r 8009cf5b833d -r a30edd277572 src/jdk.jpackage/share/classes/jdk/jpackage/internal/Arguments.java --- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/Arguments.java Mon Apr 15 12:03:26 2019 -0400 +++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/Arguments.java Thu Apr 18 19:36:55 2019 -0400 @@ -263,8 +263,16 @@ ADD_LAUNCHER ("add-launcher", OptionCategories.PROPERTY, () -> { + String spec = popArg(); + String name = null; + String filename = spec; + if (spec.contains("=")) { + String[] values = spec.split("=", 2); + name = values[0]; + filename = values[1]; + } context().addLaunchers.add( - new AddLauncherArguments(popArg())); + new AddLauncherArguments(name, filename)); }), TEMP_ROOT ("temp-root", OptionCategories.PROPERTY, () -> { diff -r 8009cf5b833d -r a30edd277572 src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/HelpResources.properties --- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/HelpResources.properties Mon Apr 15 12:03:26 2019 -0400 +++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/HelpResources.properties Thu Apr 18 19:36:55 2019 -0400 @@ -59,6 +59,7 @@ Generic Options:\n\ \ @ \n\ \ Read options and/or mode from a file \n\ +\ This option can be used multiple times.\n\ \ --app-version \n\ \ Version of the application and/or installer\n\ \ --copyright \n\ @@ -95,11 +96,13 @@ \ if not specified, either just the main module (if --module is\n\ \ specified), or the default set of modules (if --main-jar is \n\ \ specified) are used.\n\ +\ This option can be used multiple times.\n\ \ --module-path -p ...\n\ \ A {0} separated list of paths\n\ \ Each path is either a directory of modules or the path to a\n\ \ modular jar.\n\ \ (each path is absolute or relative to the current directory)\n\ +\ This option can be used multiple times.\n\ \ --runtime-image \n\ \ Path of the predefined runtime image that will be copied into\n\ \ the application image\n\ @@ -121,22 +124,26 @@ \ application image.\n\ \n\ \Options for creating the application launcher(s):\n\ -\ --add-launcher \n\ -\ Path to a Properties file that contains list of key, value pairs\n\ +\ --add-launcher =\n\ +\ Name of launcher, and a path to a Properties file that contains\n\ +\ a list of key, value pairs\n\ \ (absolute path or relative to the current directory)\n\ -\ The keys "name" (required), "module", "add-modules",\n\ -\ "main-jar", "main-class", "arguments", "java-options",\n\ -\ "app-version", "icon", and "win-console" can be used.\n\ +\ The keys "module", "add-modules", "main-jar", "main-class",\n\ +\ "arguments", "java-options", "app-version", "icon", and\n\ +\ "win-console" can be used.\n\ \ These options are added to, or used to overwrite, the original\n\ \ command line options to build an additional alternative launcher.\n\ \ The main application launcher will be built from the command line\n\ -\ options. Additional alternative launchers may be built using\n\ -\ this option.\n\ +\ options. Additional alternative launchers can be built using\n\ +\ this option, and this option can be used multiple times to\n\ +\ build multiple additional launchers. \n\ \ --arguments
\n\ \ Command line arguments to pass to the main class if no command\n\ \ line arguments are given to the launcher\n\ +\ This option can be used multiple times.\n\ \ --java-options \n\ \ Options to pass to the Java runtime\n\ +\ This option can be used multiple times.\n\ \ --main-class \n\ \ Qualified name of the application main class to execute\n\ \ This option can only be used if --main-jar is specified.\n\ @@ -163,6 +170,7 @@ \ (absolute path or relative to the current directory)\n\ \ The keys "extension", "mime-type", "icon", and "description"\n\ \ can be used to describe the association.\n\ +\ This option can be used multiple times.\n\ \ --identifier \n\ \ An identifier that uniquely identifies the application\n\ \ Defaults to the main class name.\n\ diff -r 8009cf5b833d -r a30edd277572 src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/HelpResources_ja.properties --- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/HelpResources_ja.properties Mon Apr 15 12:03:26 2019 -0400 +++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/HelpResources_ja.properties Thu Apr 18 19:36:55 2019 -0400 @@ -59,6 +59,7 @@ Generic Options:\n\ \ @ \n\ \ Read options and/or mode from a file \n\ +\ This option can be used multiple times.\n\ \ --app-version \n\ \ Version of the application and/or installer\n\ \ --copyright \n\ @@ -95,11 +96,13 @@ \ if not specified, either just the main module (if --module is\n\ \ specified), or the default set of modules (if --main-jar is \n\ \ specified) are used.\n\ +\ This option can be used multiple times.\n\ \ --module-path -p ...\n\ \ A {0} separated list of paths\n\ \ Each path is either a directory of modules or the path to a\n\ \ modular jar.\n\ \ (each path is absolute or relative to the current directory)\n\ +\ This option can be used multiple times.\n\ \ --runtime-image \n\ \ Path of the predefined runtime image that will be copied into\n\ \ the application image\n\ @@ -121,22 +124,26 @@ \ application image.\n\ \n\ \Options for creating the application launcher(s):\n\ -\ --add-launcher \n\ -\ Path to a Properties file that contains list of key, value pairs\n\ +\ --add-launcher =\n\ +\ Name of launcher, and a path to a Properties file that contains\n\ +\ a list of key, value pairs\n\ \ (absolute path or relative to the current directory)\n\ -\ The keys "name" (required), "module", "add-modules",\n\ -\ "main-jar", "main-class", "arguments", "java-options",\n\ -\ "app-version", "icon", and "win-console" can be used.\n\ +\ The keys "module", "add-modules", "main-jar", "main-class",\n\ +\ "arguments", "java-options", "app-version", "icon", and\n\ +\ "win-console" can be used.\n\ \ These options are added to, or used to overwrite, the original\n\ \ command line options to build an additional alternative launcher.\n\ \ The main application launcher will be built from the command line\n\ -\ options. Additional alternative launchers may be built using\n\ -\ this option.\n\ +\ options. Additional alternative launchers can be built using\n\ +\ this option, and this option can be used multiple times to\n\ +\ build multiple additional launchers. \n\ \ --arguments
\n\ \ Command line arguments to pass to the main class if no command\n\ \ line arguments are given to the launcher\n\ +\ This option can be used multiple times.\n\ \ --java-options \n\ \ Options to pass to the Java runtime\n\ +\ This option can be used multiple times.\n\ \ --main-class \n\ \ Qualified name of the application main class to execute\n\ \ This option can only be used if --main-jar is specified.\n\ @@ -163,6 +170,7 @@ \ (absolute path or relative to the current directory)\n\ \ The keys "extension", "mime-type", "icon", and "description"\n\ \ can be used to describe the association.\n\ +\ This option can be used multiple times.\n\ \ --identifier \n\ \ An identifier that uniquely identifies the application\n\ \ Defaults to the main class name.\n\ diff -r 8009cf5b833d -r a30edd277572 src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/HelpResources_zh_CN.properties --- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/HelpResources_zh_CN.properties Mon Apr 15 12:03:26 2019 -0400 +++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/HelpResources_zh_CN.properties Thu Apr 18 19:36:55 2019 -0400 @@ -59,6 +59,7 @@ Generic Options:\n\ \ @ \n\ \ Read options and/or mode from a file \n\ +\ This option can be used multiple times.\n\ \ --app-version \n\ \ Version of the application and/or installer\n\ \ --copyright \n\ @@ -95,11 +96,13 @@ \ if not specified, either just the main module (if --module is\n\ \ specified), or the default set of modules (if --main-jar is \n\ \ specified) are used.\n\ +\ This option can be used multiple times.\n\ \ --module-path -p ...\n\ \ A {0} separated list of paths\n\ \ Each path is either a directory of modules or the path to a\n\ \ modular jar.\n\ \ (each path is absolute or relative to the current directory)\n\ +\ This option can be used multiple times.\n\ \ --runtime-image \n\ \ Path of the predefined runtime image that will be copied into\n\ \ the application image\n\ @@ -121,22 +124,26 @@ \ application image.\n\ \n\ \Options for creating the application launcher(s):\n\ -\ --add-launcher \n\ -\ Path to a Properties file that contains list of key, value pairs\n\ +\ --add-launcher =\n\ +\ Name of launcher, and a path to a Properties file that contains\n\ +\ a list of key, value pairs\n\ \ (absolute path or relative to the current directory)\n\ -\ The keys "name" (required), "module", "add-modules",\n\ -\ "main-jar", "main-class", "arguments", "java-options",\n\ -\ "app-version", "icon", and "win-console" can be used.\n\ +\ The keys "module", "add-modules", "main-jar", "main-class",\n\ +\ "arguments", "java-options", "app-version", "icon", and\n\ +\ "win-console" can be used.\n\ \ These options are added to, or used to overwrite, the original\n\ \ command line options to build an additional alternative launcher.\n\ \ The main application launcher will be built from the command line\n\ -\ options. Additional alternative launchers may be built using\n\ -\ this option.\n\ +\ options. Additional alternative launchers can be built using\n\ +\ this option, and this option can be used multiple times to\n\ +\ build multiple additional launchers. \n\ \ --arguments
\n\ \ Command line arguments to pass to the main class if no command\n\ \ line arguments are given to the launcher\n\ +\ This option can be used multiple times.\n\ \ --java-options \n\ \ Options to pass to the Java runtime\n\ +\ This option can be used multiple times.\n\ \ --main-class \n\ \ Qualified name of the application main class to execute\n\ \ This option can only be used if --main-jar is specified.\n\ @@ -163,6 +170,7 @@ \ (absolute path or relative to the current directory)\n\ \ The keys "extension", "mime-type", "icon", and "description"\n\ \ can be used to describe the association.\n\ +\ This option can be used multiple times.\n\ \ --identifier \n\ \ An identifier that uniquely identifies the application\n\ \ Defaults to the main class name.\n\ diff -r 8009cf5b833d -r a30edd277572 src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/MainResources.properties --- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/MainResources.properties Mon Apr 15 12:03:26 2019 -0400 +++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/MainResources.properties Thu Apr 18 19:36:55 2019 -0400 @@ -81,8 +81,8 @@ ERR_MissingAppResources=Error: No application jars found. ERR_AppImageNotExist=Error: App image directory "{0}" does not exist. ERR_AppImageInvalid=Error: App image directory "{0}" does not contain "app" sub-directory. -ERR_NoAddLauncherName=Error: Add Launchers require a name parameter. -ERR_NoUniqueName=Error: Add Launchers require a unique name parameter. +ERR_NoAddLauncherName=Error: --add-launcher option requires a name and a file path (--add-launcher =). +ERR_NoUniqueName=Error: --add-launcher = requires a unique name. ERR_NoJreInstallerName=Error: Jre Installers require a name parameter. ERR_InvalidAppName=Error: Invalid Application name: {0}. ERR_InvalidSLName=Error: Invalid Add Launcher name: {0}. diff -r 8009cf5b833d -r a30edd277572 src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/MainResources_ja.properties --- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/MainResources_ja.properties Mon Apr 15 12:03:26 2019 -0400 +++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/MainResources_ja.properties Thu Apr 18 19:36:55 2019 -0400 @@ -81,8 +81,8 @@ ERR_MissingAppResources=Error: No application jars found. ERR_AppImageNotExist=Error: App image directory "{0}" does not exist. ERR_AppImageInvalid=Error: App image directory "{0}" does not contain "app" sub-directory. -ERR_NoAddLauncherName=Error: Add Launchers require a name parameter. -ERR_NoUniqueName=Error: Add Launchers require a unique name parameter. +ERR_NoAddLauncherName=Error: --add-launcher option requires a name and a file path (--add-launcher =). +ERR_NoUniqueName=Error: --add-launcher = requires a unique name. ERR_NoJreInstallerName=Error: Jre Installers require a name parameter. ERR_InvalidAppName=Error: Invalid Application name: {0}. ERR_InvalidSLName=Error: Invalid Add Launcher name: {0}. diff -r 8009cf5b833d -r a30edd277572 src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/MainResources_zh_CN.properties --- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/MainResources_zh_CN.properties Mon Apr 15 12:03:26 2019 -0400 +++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/MainResources_zh_CN.properties Thu Apr 18 19:36:55 2019 -0400 @@ -81,8 +81,8 @@ ERR_MissingAppResources=Error: No application jars found. ERR_AppImageNotExist=Error: App image directory "{0}" does not exist. ERR_AppImageInvalid=Error: App image directory "{0}" does not contain "app" sub-directory. -ERR_NoAddLauncherName=Error: Add Launchers require a name parameter. -ERR_NoUniqueName=Error: Add Launchers require a unique name parameter. +ERR_NoAddLauncherName=Error: --add-launcher option requires a name and a file path (--add-launcher =). +ERR_NoUniqueName=Error: --add-launcher = requires a unique name. ERR_NoJreInstallerName=Error: Jre Installers require a name parameter. ERR_InvalidAppName=Error: Invalid Application name: {0}. ERR_InvalidSLName=Error: Invalid Add Launcher name: {0}. diff -r 8009cf5b833d -r a30edd277572 test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageAddLauncherBase.java --- a/test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageAddLauncherBase.java Mon Apr 15 12:03:26 2019 -0400 +++ b/test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageAddLauncherBase.java Thu Apr 18 19:36:55 2019 -0400 @@ -132,7 +132,6 @@ try (PrintWriter out = new PrintWriter(new BufferedWriter( new FileWriter("sl.properties")))) { - out.println("name=test2"); out.println("arguments=" + argumentsMap); out.println("java-options=" + vmArgumentsMap); } diff -r 8009cf5b833d -r a30edd277572 test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageAddLauncherModuleTest.java --- a/test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageAddLauncherModuleTest.java Mon Apr 15 12:03:26 2019 -0400 +++ b/test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageAddLauncherModuleTest.java Thu Apr 18 19:36:55 2019 -0400 @@ -39,7 +39,7 @@ "--name", "test", "--module", "com.hello/com.hello.Hello", "--module-path", "input", - "--add-launcher", "sl.properties"}; + "--add-launcher", "test2=sl.properties"}; public static void main(String[] args) throws Exception { JPackageHelper.createHelloModule(); diff -r 8009cf5b833d -r a30edd277572 test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageAddLauncherTest.java --- a/test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageAddLauncherTest.java Mon Apr 15 12:03:26 2019 -0400 +++ b/test/jdk/tools/jpackage/createappimage/JPackageCreateAppImageAddLauncherTest.java Thu Apr 18 19:36:55 2019 -0400 @@ -40,7 +40,7 @@ "--name", "test", "--main-jar", "hello.jar", "--main-class", "Hello", - "--add-launcher", "sl.properties"}; + "--add-launcher", "test2=sl.properties"}; public static void main(String[] args) throws Exception { JPackageHelper.createHelloImageJar();