1 /*
2 * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
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
212 } else {
213 throw new PackagerException("ERR_UnknownArgument", arg);
214 }
215 }
216 if (srcdir != null && !srcdir.isDirectory()) {
217 throw new PackagerException("ERR_InvalidDirectory", srcdir.getAbsolutePath());
218 }
219 if (!srcfilesSet) {
220 //using "." as default dir is confusing. Require explicit list of inputs
221 if (srcdir == null) {
222 throw new PackagerException("ERR_MissingArgument", "-srcfiles (-srcdir)");
223 }
224 addResources(createJarParams, srcdir, ".");
225 }
226 packageAsJar = true;
227
228 } else if (args[0].equalsIgnoreCase("-deploy")) {
229 boolean srcfilesSet = false;
230 File templateInFile = null;
231 File templateOutFile = null;
232
233 //can only set it to true with command line, reset default
234 deployParams.setEmbedJNLP(false);
235 for (int i = 1; i < args.length; i++) {
236 String arg = args[i];
237 if (arg.startsWith("-B")) {
238 String key;
239 String value;
240
241 int keyStart = 2;
242 int equals = arg.indexOf("=");
243 int len = arg.length();
244 if (equals < keyStart) {
245 if (keyStart < len) {
246 key = arg.substring(keyStart, len);
247 value = Boolean.TRUE.toString();
248 } else {
249 continue;
250 }
251 } else if (keyStart < equals) {
257 deployParams.addBundleArgument(key, value);
258 } else if (arg.equalsIgnoreCase("-title")) {
259 deployParams.setTitle(nextArg(args, i++));
260 } else if (arg.equalsIgnoreCase("-vendor")) {
261 deployParams.setVendor(nextArg(args, i++));
262 } else if (arg.equalsIgnoreCase("-native")) {
263 //if no argument is provided we will treat it as ALL
264 // for compatibility with FX 2.2
265 BundleType type = BundleType.ALL;
266 String format = null; //null means ANY
267 if (i+1 < args.length && !args[i+1].startsWith("-")) {
268 String v = args[++i];
269 //parsing logic is the same as in DeployFXTask
270 if ("image".equals(v)) {
271 type = BundleType.IMAGE;
272 } else if ("installer".equals(v)) {
273 type = BundleType.INSTALLER;
274 } else {
275 //assume it is request to build only specific format
276 // (like exe or msi)
277 type = BundleType.INSTALLER;
278 format = (v != null) ? v.toLowerCase() : null;
279 }
280 }
281 deployParams.setBundleType(type);
282 deployParams.setTargetFormat(format);
283 } else if (arg.equalsIgnoreCase("-description")) {
284 deployParams.setDescription(nextArg(args, i++));
285 } else if(arg.equalsIgnoreCase("-appclass")) {
286 deployParams.setApplicationClass(nextArg(args, i++));
287 } else if(arg.equalsIgnoreCase("-daemon")) {
288 deployParams.setServiceHint(true);
289 } else if(arg.equalsIgnoreCase("-installdirChooser")) {
290 deployParams.setInstalldirChooser(true);
291 } else if (arg.equalsIgnoreCase("-preloader")) {
292 deployParams.setPreloader(nextArg(args, i++));
293 } else if (arg.equalsIgnoreCase("-paramFile")) {
294 deployParams.setParams(parseParams(nextArg(args, i++)));
295 } else if (arg.equalsIgnoreCase("-htmlParamFile")) {
296 deployParams.setHtmlParams(parseHtmlParams(nextArg(args, i++)));
297 } else if (arg.equalsIgnoreCase("-width")) {
321 deployParams.setAppId(appIdArg);
322 deployParams.setId(appIdArg);
323 } else if (arg.equalsIgnoreCase("-verbose") || arg.equalsIgnoreCase("-v")) {
324 deployParams.setVerbose(true);
325 verbose = true;
326 } else if (arg.equalsIgnoreCase("-includedt")) {
327 deployParams.setIncludeDT(true);
328 } else if (arg.equalsIgnoreCase("-outdir")) {
329 deployParams.setOutdir(new File(nextArg(args, i++)));
330 } else if (arg.equalsIgnoreCase("-outfile")) {
331 deployParams.setOutfile(nextArg(args, i++));
332 } else if (arg.equalsIgnoreCase("-srcdir")) {
333 srcdir = new File(nextArg(args, i++));
334 } else if (arg.equalsIgnoreCase("-srcfiles")) {
335 addResources(deployParams, srcdir, nextArg(args, i++));
336 srcfilesSet = true;
337 } else if (arg.equalsIgnoreCase("-argument")) {
338 addArgument(deployParams, nextArg(args, i++));
339 } else if (arg.equalsIgnoreCase("-nosign")) {
340 deployParams.setSignBundle(false);
341 } else {
342 throw new PackagerException("ERR_UnknownArgument", arg);
343 }
344 }
345 if (templateInFile != null) {
346 deployParams.addTemplate(templateInFile, templateOutFile);
347 }
348 if (srcdir != null && !srcdir.isDirectory()) {
349 throw new PackagerException("ERR_InvalidDirectory", srcdir.getAbsolutePath());
350 }
351 if (!srcfilesSet) {
352 //using "." as default dir is confusing. Require explicit list of inputs
353 if (srcdir == null) {
354 throw new PackagerException("ERR_MissingArgument", "-srcfiles (-srcdir)");
355 }
356 addResources(deployParams, srcdir, ".");
357 }
358 genJNLP = true;
359 } else if (args[0].equalsIgnoreCase("-createbss")) {
360 boolean srcfilesSet = false;
|
1 /*
2 * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
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
212 } else {
213 throw new PackagerException("ERR_UnknownArgument", arg);
214 }
215 }
216 if (srcdir != null && !srcdir.isDirectory()) {
217 throw new PackagerException("ERR_InvalidDirectory", srcdir.getAbsolutePath());
218 }
219 if (!srcfilesSet) {
220 //using "." as default dir is confusing. Require explicit list of inputs
221 if (srcdir == null) {
222 throw new PackagerException("ERR_MissingArgument", "-srcfiles (-srcdir)");
223 }
224 addResources(createJarParams, srcdir, ".");
225 }
226 packageAsJar = true;
227
228 } else if (args[0].equalsIgnoreCase("-deploy")) {
229 boolean srcfilesSet = false;
230 File templateInFile = null;
231 File templateOutFile = null;
232 deployParams.setBundleType(BundleType.JNLP);
233 deployParams.setTargetFormat("jnlp");
234
235
236 //can only set it to true with command line, reset default
237 deployParams.setEmbedJNLP(false);
238 for (int i = 1; i < args.length; i++) {
239 String arg = args[i];
240 if (arg.startsWith("-B")) {
241 String key;
242 String value;
243
244 int keyStart = 2;
245 int equals = arg.indexOf("=");
246 int len = arg.length();
247 if (equals < keyStart) {
248 if (keyStart < len) {
249 key = arg.substring(keyStart, len);
250 value = Boolean.TRUE.toString();
251 } else {
252 continue;
253 }
254 } else if (keyStart < equals) {
260 deployParams.addBundleArgument(key, value);
261 } else if (arg.equalsIgnoreCase("-title")) {
262 deployParams.setTitle(nextArg(args, i++));
263 } else if (arg.equalsIgnoreCase("-vendor")) {
264 deployParams.setVendor(nextArg(args, i++));
265 } else if (arg.equalsIgnoreCase("-native")) {
266 //if no argument is provided we will treat it as ALL
267 // for compatibility with FX 2.2
268 BundleType type = BundleType.ALL;
269 String format = null; //null means ANY
270 if (i+1 < args.length && !args[i+1].startsWith("-")) {
271 String v = args[++i];
272 //parsing logic is the same as in DeployFXTask
273 if ("image".equals(v)) {
274 type = BundleType.IMAGE;
275 } else if ("installer".equals(v)) {
276 type = BundleType.INSTALLER;
277 } else {
278 //assume it is request to build only specific format
279 // (like exe or msi)
280 format = (v != null) ? v.toLowerCase() : null;
281 }
282 }
283 deployParams.setBundleType(type);
284 deployParams.setTargetFormat(format);
285 } else if (arg.equalsIgnoreCase("-description")) {
286 deployParams.setDescription(nextArg(args, i++));
287 } else if(arg.equalsIgnoreCase("-appclass")) {
288 deployParams.setApplicationClass(nextArg(args, i++));
289 } else if(arg.equalsIgnoreCase("-daemon")) {
290 deployParams.setServiceHint(true);
291 } else if(arg.equalsIgnoreCase("-installdirChooser")) {
292 deployParams.setInstalldirChooser(true);
293 } else if (arg.equalsIgnoreCase("-preloader")) {
294 deployParams.setPreloader(nextArg(args, i++));
295 } else if (arg.equalsIgnoreCase("-paramFile")) {
296 deployParams.setParams(parseParams(nextArg(args, i++)));
297 } else if (arg.equalsIgnoreCase("-htmlParamFile")) {
298 deployParams.setHtmlParams(parseHtmlParams(nextArg(args, i++)));
299 } else if (arg.equalsIgnoreCase("-width")) {
323 deployParams.setAppId(appIdArg);
324 deployParams.setId(appIdArg);
325 } else if (arg.equalsIgnoreCase("-verbose") || arg.equalsIgnoreCase("-v")) {
326 deployParams.setVerbose(true);
327 verbose = true;
328 } else if (arg.equalsIgnoreCase("-includedt")) {
329 deployParams.setIncludeDT(true);
330 } else if (arg.equalsIgnoreCase("-outdir")) {
331 deployParams.setOutdir(new File(nextArg(args, i++)));
332 } else if (arg.equalsIgnoreCase("-outfile")) {
333 deployParams.setOutfile(nextArg(args, i++));
334 } else if (arg.equalsIgnoreCase("-srcdir")) {
335 srcdir = new File(nextArg(args, i++));
336 } else if (arg.equalsIgnoreCase("-srcfiles")) {
337 addResources(deployParams, srcdir, nextArg(args, i++));
338 srcfilesSet = true;
339 } else if (arg.equalsIgnoreCase("-argument")) {
340 addArgument(deployParams, nextArg(args, i++));
341 } else if (arg.equalsIgnoreCase("-nosign")) {
342 deployParams.setSignBundle(false);
343 } else if (arg.equals("-addmods")) {
344 deployParams.addModules.add(nextArg(args, i++));
345 } else if (arg.equals("-limitmods")) {
346 deployParams.limitModules.add(nextArg(args, i++));
347 } else if (arg.equals("-detectmods")) {
348 deployParams.detectModules = true;
349 } else if (arg.equals("-stripexecutables")) {
350 deployParams.stripExecutables = true;
351 } else if (arg.equals("-modulepath")) {
352 if (deployParams.modulePath == null) {
353 deployParams.modulePath = nextArg(args, i++);
354 } else {
355 deployParams.modulePath =
356 deployParams.modulePath
357 + File.pathSeparator
358 + nextArg(args, i++);
359 }
360 } else if (arg.equals("-jdkmodulepath")) {
361 if (deployParams.jdkModulePath == null) {
362 deployParams.jdkModulePath = nextArg(args, i++);
363 } else {
364 deployParams.jdkModulePath =
365 deployParams.jdkModulePath
366 + File.pathSeparator
367 + nextArg(args, i++);
368 }
369 } else {
370 throw new PackagerException("ERR_UnknownArgument", arg);
371 }
372 }
373 if (templateInFile != null) {
374 deployParams.addTemplate(templateInFile, templateOutFile);
375 }
376 if (srcdir != null && !srcdir.isDirectory()) {
377 throw new PackagerException("ERR_InvalidDirectory", srcdir.getAbsolutePath());
378 }
379 if (!srcfilesSet) {
380 //using "." as default dir is confusing. Require explicit list of inputs
381 if (srcdir == null) {
382 throw new PackagerException("ERR_MissingArgument", "-srcfiles (-srcdir)");
383 }
384 addResources(deployParams, srcdir, ".");
385 }
386 genJNLP = true;
387 } else if (args[0].equalsIgnoreCase("-createbss")) {
388 boolean srcfilesSet = false;
|