12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package jdk.incubator.jpackage.internal;
27
28 import java.util.Collection;
29 import java.util.HashMap;
30 import java.util.Map;
31 import java.io.File;
32 import jdk.incubator.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 *
143 return allArgs.get(id);
144 }
145
146 return null;
147 }
148
149 Map<String, ? super Object> getLauncherMap() {
150 initLauncherMap();
151 return bundleParams;
152 }
153
154 private void putUnlessNull(Map<String, ? super Object> params,
155 String param, Object value) {
156 if (value != null) {
157 params.put(param, value);
158 }
159 }
160
161 static Map<String, ? super Object> merge(
162 Map<String, ? super Object> original,
163 Map<String, ? super Object> additional) {
164 Map<String, ? super Object> tmp = new HashMap<>(original);
165 if (additional.containsKey(CLIOptions.MODULE.getId())) {
166 tmp.remove(CLIOptions.MAIN_JAR.getId());
167 tmp.remove(CLIOptions.APPCLASS.getId());
168 } else if (additional.containsKey(CLIOptions.MAIN_JAR.getId())) {
169 tmp.remove(CLIOptions.MODULE.getId());
170 }
171 if (additional.containsKey(CLIOptions.ARGUMENTS.getId())) {
172 // if add launcher properties file contains "arguments", even with
173 // null value, disregard the "arguments" from command line
174 tmp.remove(CLIOptions.ARGUMENTS.getId());
175 }
176 if (additional.containsKey(CLIOptions.JAVA_OPTIONS.getId())) {
177 // same thing for java-options
178 tmp.remove(CLIOptions.JAVA_OPTIONS.getId());
179 }
180 tmp.putAll(additional);
181 return tmp;
182 }
183
184 }
|
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package jdk.incubator.jpackage.internal;
27
28 import java.util.Collection;
29 import java.util.HashMap;
30 import java.util.Map;
31 import java.io.File;
32 import java.util.List;
33 import jdk.incubator.jpackage.internal.Arguments.CLIOptions;
34
35 /*
36 * AddLauncherArguments
37 *
38 * Processes a add-launcher properties file to create the Map of
39 * bundle params applicable to the add-launcher:
40 *
41 * BundlerParams p = (new AddLauncherArguments(file)).getLauncherMap();
42 *
43 * A add-launcher is another executable program generated by either the
44 * create-app-image mode or the create-installer mode.
45 * The add-launcher may be the same program with different configuration,
46 * or a completely different program created from the same files.
47 *
48 * There may be multiple add-launchers, each created by using the
49 * command line arg "--add-launcher <file path>
50 *
51 * The add-launcher properties file may have any of:
52 *
144 return allArgs.get(id);
145 }
146
147 return null;
148 }
149
150 Map<String, ? super Object> getLauncherMap() {
151 initLauncherMap();
152 return bundleParams;
153 }
154
155 private void putUnlessNull(Map<String, ? super Object> params,
156 String param, Object value) {
157 if (value != null) {
158 params.put(param, value);
159 }
160 }
161
162 static Map<String, ? super Object> merge(
163 Map<String, ? super Object> original,
164 Map<String, ? super Object> additional, String... exclude) {
165 Map<String, ? super Object> tmp = new HashMap<>(original);
166 List.of(exclude).forEach(tmp::remove);
167
168 if (additional.containsKey(CLIOptions.MODULE.getId())) {
169 tmp.remove(CLIOptions.MAIN_JAR.getId());
170 tmp.remove(CLIOptions.APPCLASS.getId());
171 } else if (additional.containsKey(CLIOptions.MAIN_JAR.getId())) {
172 tmp.remove(CLIOptions.MODULE.getId());
173 }
174 if (additional.containsKey(CLIOptions.ARGUMENTS.getId())) {
175 // if add launcher properties file contains "arguments", even with
176 // null value, disregard the "arguments" from command line
177 tmp.remove(CLIOptions.ARGUMENTS.getId());
178 }
179 if (additional.containsKey(CLIOptions.JAVA_OPTIONS.getId())) {
180 // same thing for java-options
181 tmp.remove(CLIOptions.JAVA_OPTIONS.getId());
182 }
183 tmp.putAll(additional);
184 return tmp;
185 }
186
187 }
|