< prev index next >

src/jdk.jpackage/share/classes/jdk/jpackage/internal/AddLauncherArguments.java

Print this page




  32 import jdk.jpackage.internal.Arguments.CLIOptions;
  33 
  34 /*
  35  * AddLauncherArguments
  36  *
  37  * Processes a add-launcher properties file to create the Map of
  38  * bundle params applicable to the add-launcher:
  39  *
  40  * BundlerParams p = (new AddLauncherArguments(file)).getLauncherMap();
  41  *
  42  * A add-launcher is another executable program generated by either the
  43  * create-app-image mode or the create-installer mode.
  44  * The add-launcher may be the same program with different configuration,
  45  * or a completely different program created from the same files.
  46  *
  47  * There may be multiple add-launchers, each created by using the
  48  * command line arg "--add-launcher <file path>
  49  *
  50  * The add-launcher properties file may have any of:
  51  *
  52  * name (required)
  53  * appVersion
  54  * module
  55  * add-modules
  56  * main-jar
  57  * main-class
  58  * icon
  59  * arguments
  60  * java-options
  61  * win-console
  62  *
  63  */
  64 class AddLauncherArguments {
  65 

  66     private final String filename;
  67     private Map<String, String> allArgs;
  68     private Map<String, ? super Object> bundleParams;
  69 
  70     AddLauncherArguments(String filename) {

  71         this.filename = filename;
  72     }
  73 
  74     private void initLauncherMap() {
  75         if (bundleParams != null) {
  76             return;
  77         }
  78 
  79         allArgs = Arguments.getPropertiesFromFile(filename);

  80 
  81         bundleParams = new HashMap<>();
  82         String mainJar = getOptionValue(CLIOptions.MAIN_JAR);
  83         String mainClass = getOptionValue(CLIOptions.APPCLASS);
  84         String module = getOptionValue(CLIOptions.MODULE);
  85 
  86         if (module != null && mainClass != null) {
  87             putUnlessNull(bundleParams, Arguments.CLIOptions.MODULE.getId(),
  88                     module + "/" + mainClass);
  89         } else if (module != null) {
  90             putUnlessNull(bundleParams, Arguments.CLIOptions.MODULE.getId(),
  91                     module);
  92         } else {
  93             putUnlessNull(bundleParams, Arguments.CLIOptions.MAIN_JAR.getId(),
  94                     mainJar);
  95             putUnlessNull(bundleParams, Arguments.CLIOptions.APPCLASS.getId(),
  96                     mainClass);
  97         }
  98 
  99         putUnlessNull(bundleParams, Arguments.CLIOptions.NAME.getId(),
 100                 getOptionValue(CLIOptions.NAME));
 101 
 102         putUnlessNull(bundleParams, Arguments.CLIOptions.VERSION.getId(),
 103                 getOptionValue(CLIOptions.VERSION));
 104 
 105         putUnlessNull(bundleParams,
 106                 Arguments.CLIOptions.ADD_MODULES.getId(),
 107                 getOptionValue(CLIOptions.ADD_MODULES));
 108 
 109         putUnlessNull(bundleParams,
 110                 Arguments.CLIOptions.WIN_CONSOLE_HINT.getId(),
 111                 getOptionValue(CLIOptions.WIN_CONSOLE_HINT));
 112 
 113         String value = getOptionValue(CLIOptions.ICON);
 114         putUnlessNull(bundleParams, Arguments.CLIOptions.ICON.getId(),
 115                 (value == null) ? null : new File(value));
 116 
 117         String argumentStr = getOptionValue(CLIOptions.ARGUMENTS);
 118         putUnlessNullOrEmpty(bundleParams,
 119                 CLIOptions.ARGUMENTS.getId(),
 120                 Arguments.getArgumentList(argumentStr));
 121 
 122         String jvmargsStr = getOptionValue(CLIOptions.JAVA_OPTIONS);
 123         putUnlessNullOrEmpty(bundleParams,
 124                 CLIOptions.JAVA_OPTIONS.getId(),
 125                 Arguments.getArgumentList(jvmargsStr));
 126     }
 127 
 128     private String getOptionValue(CLIOptions option) {
 129         if (option == null || allArgs == null) {
 130             return null;
 131         }
 132 
 133         String id = option.getId();
 134 




  32 import jdk.jpackage.internal.Arguments.CLIOptions;
  33 
  34 /*
  35  * AddLauncherArguments
  36  *
  37  * Processes a add-launcher properties file to create the Map of
  38  * bundle params applicable to the add-launcher:
  39  *
  40  * BundlerParams p = (new AddLauncherArguments(file)).getLauncherMap();
  41  *
  42  * A add-launcher is another executable program generated by either the
  43  * create-app-image mode or the create-installer mode.
  44  * The add-launcher may be the same program with different configuration,
  45  * or a completely different program created from the same files.
  46  *
  47  * There may be multiple add-launchers, each created by using the
  48  * command line arg "--add-launcher <file path>
  49  *
  50  * The add-launcher properties file may have any of:
  51  *

  52  * appVersion
  53  * module
  54  * add-modules
  55  * main-jar
  56  * main-class
  57  * icon
  58  * arguments
  59  * java-options
  60  * win-console
  61  *
  62  */
  63 class AddLauncherArguments {
  64 
  65     private final String name;
  66     private final String filename;
  67     private Map<String, String> allArgs;
  68     private Map<String, ? super Object> bundleParams;
  69 
  70     AddLauncherArguments(String name, String filename) {
  71         this.name = name;
  72         this.filename = filename;
  73     }
  74 
  75     private void initLauncherMap() {
  76         if (bundleParams != null) {
  77             return;
  78         }
  79 
  80         allArgs = Arguments.getPropertiesFromFile(filename);
  81         allArgs.put(CLIOptions.NAME.getId(), name);
  82 
  83         bundleParams = new HashMap<>();
  84         String mainJar = getOptionValue(CLIOptions.MAIN_JAR);
  85         String mainClass = getOptionValue(CLIOptions.APPCLASS);
  86         String module = getOptionValue(CLIOptions.MODULE);
  87 
  88         if (module != null && mainClass != null) {
  89             putUnlessNull(bundleParams, CLIOptions.MODULE.getId(),
  90                     module + "/" + mainClass);
  91         } else if (module != null) {
  92             putUnlessNull(bundleParams, CLIOptions.MODULE.getId(),
  93                     module);
  94         } else {
  95             putUnlessNull(bundleParams, CLIOptions.MAIN_JAR.getId(),
  96                     mainJar);
  97             putUnlessNull(bundleParams, CLIOptions.APPCLASS.getId(),
  98                     mainClass);
  99         }
 100 
 101         putUnlessNull(bundleParams, CLIOptions.NAME.getId(),
 102                 getOptionValue(CLIOptions.NAME));
 103 
 104         putUnlessNull(bundleParams, CLIOptions.VERSION.getId(),
 105                 getOptionValue(CLIOptions.VERSION));
 106 
 107         putUnlessNull(bundleParams,
 108                 CLIOptions.ADD_MODULES.getId(),
 109                 getOptionValue(CLIOptions.ADD_MODULES));
 110 
 111         putUnlessNull(bundleParams,
 112                 CLIOptions.WIN_CONSOLE_HINT.getId(),
 113                 getOptionValue(CLIOptions.WIN_CONSOLE_HINT));
 114 
 115         String value = getOptionValue(CLIOptions.ICON);
 116         putUnlessNull(bundleParams, CLIOptions.ICON.getId(),
 117                 (value == null) ? null : new File(value));
 118 
 119         String argumentStr = getOptionValue(CLIOptions.ARGUMENTS);
 120         putUnlessNullOrEmpty(bundleParams,
 121                 CLIOptions.ARGUMENTS.getId(),
 122                 Arguments.getArgumentList(argumentStr));
 123 
 124         String jvmargsStr = getOptionValue(CLIOptions.JAVA_OPTIONS);
 125         putUnlessNullOrEmpty(bundleParams,
 126                 CLIOptions.JAVA_OPTIONS.getId(),
 127                 Arguments.getArgumentList(jvmargsStr));
 128     }
 129 
 130     private String getOptionValue(CLIOptions option) {
 131         if (option == null || allArgs == null) {
 132             return null;
 133         }
 134 
 135         String id = option.getId();
 136 


< prev index next >