author | herrick |
Fri, 12 Oct 2018 19:00:51 -0400 | |
branch | JDK-8200758-branch |
changeset 56963 | eaca4369b068 |
permissions | -rw-r--r-- |
56963
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
1 |
/* |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
2 |
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
4 |
* |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
8 |
* |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
13 |
* accompanied this code). |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
14 |
* |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
18 |
* |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
21 |
* questions. |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
22 |
*/ |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
23 |
|
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
24 |
package jnlp.converter; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
25 |
|
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
26 |
import java.io.File; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
27 |
import java.util.ArrayList; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
28 |
import java.util.List; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
29 |
|
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
30 |
public class Options { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
31 |
|
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
32 |
private boolean createImage = false; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
33 |
private boolean createInstaller = false; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
34 |
private String installerType = null; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
35 |
private String jnlp = null; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
36 |
private String output = null; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
37 |
private String keep = null; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
38 |
private boolean help = false; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
39 |
private boolean verbose = false; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
40 |
private boolean version = false; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
41 |
private final List<String> jpackagerOptions = new ArrayList<>(); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
42 |
private boolean isRuntimeImageSet = false; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
43 |
|
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
44 |
private static final String JNLP_OPTION_PREFIX = "--jnlp="; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
45 |
private static final String OUTPUT_OPTION_PREFIX = "--output="; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
46 |
private static final String KEEP_OPTION_PREFIX = "--keep="; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
47 |
private static final String JNLP_OPTION_SHORT_PREFIX = "-j"; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
48 |
private static final String OUTPUT_OPTION_SHORT_PREFIX = "-o"; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
49 |
private static final String KEEP_OPTION_SHORT_PREFIX = "-k"; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
50 |
|
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
51 |
private static final String [] INSTALLER_TYPES = {"msi", "rpm", "deb", |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
52 |
"dmg", "pkg", "pkg-app-store"}; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
53 |
|
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
54 |
// --output, -o, --input, -i, --files, -f, --main-jar, -j, --class, -c |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
55 |
private static final String [] BLOCKED_JPACKAGER_OPTIONS = {"--output", "-o", "--input", "-i", |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
56 |
"--files", "-f", "--main-jar", |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
57 |
"-j", "--class", "-c"}; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
58 |
|
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
59 |
private static final String RUNTIME_IMAGE_OPTION = "--runtime-image"; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
60 |
|
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
61 |
private static final String ERR_UNKNOWN_OPTION = "Unknown option: "; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
62 |
private static final String ERR_MISSING_VALUE = "Value is required for option "; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
63 |
private static final String ERR_MISSING_MODE = "Error: create-image or create-installer mode is required"; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
64 |
private static final String ERR_MISSING_JNLP = "Error: --jnlp is required"; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
65 |
private static final String ERR_MISSING_OUTPUT = "Error: --output is required"; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
66 |
private static final String ERR_OUTPUT_EXISTS = "Error: output folder already exists"; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
67 |
private static final String ERR_KEEP_EXISTS = "Error: folder for --keep argument already exists"; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
68 |
private static final String ERR_INVALID_PROTOCOL_JNLP = "Error: Invalid protocol for JNLP file. Only HTTP, HTTPS and FILE protocols are supported."; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
69 |
|
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
70 |
public boolean createImage() { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
71 |
return createImage; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
72 |
} |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
73 |
|
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
74 |
public boolean createInstaller() { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
75 |
return createInstaller; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
76 |
} |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
77 |
|
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
78 |
public String getInstallerType() { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
79 |
return installerType; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
80 |
} |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
81 |
|
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
82 |
public String getJNLP() { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
83 |
return jnlp; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
84 |
} |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
85 |
|
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
86 |
public String getOutput() { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
87 |
return output; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
88 |
} |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
89 |
|
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
90 |
public String keep() { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
91 |
return keep; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
92 |
} |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
93 |
|
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
94 |
public boolean help() { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
95 |
return help; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
96 |
} |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
97 |
|
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
98 |
public boolean verbose() { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
99 |
return verbose; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
100 |
} |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
101 |
|
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
102 |
public boolean version() { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
103 |
return version; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
104 |
} |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
105 |
|
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
106 |
public List<String> getJPackagerOptions() { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
107 |
return jpackagerOptions; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
108 |
} |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
109 |
|
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
110 |
public boolean isRuntimeImageSet() { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
111 |
return isRuntimeImageSet; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
112 |
} |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
113 |
|
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
114 |
// Helper method to dump all options |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
115 |
private void display() { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
116 |
System.out.println("Options:"); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
117 |
System.out.println("createImage: " + createImage); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
118 |
System.out.println("createInstaller: " + createInstaller); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
119 |
System.out.println("installerType: " + installerType); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
120 |
System.out.println("jnlp: " + jnlp); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
121 |
System.out.println("output: " + output); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
122 |
System.out.println("keep: " + keep); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
123 |
System.out.println("help: " + help); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
124 |
System.out.println("verbose: " + verbose); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
125 |
System.out.println("version: " + version); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
126 |
for (int i = 0; i < jpackagerOptions.size(); i++) { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
127 |
System.out.println("jpackagerOptions[" + i + "]: " + jpackagerOptions.get(i)); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
128 |
} |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
129 |
} |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
130 |
|
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
131 |
private void validate() { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
132 |
if (help || version) { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
133 |
return; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
134 |
} |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
135 |
|
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
136 |
if (!createImage && !createInstaller) { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
137 |
optionError(ERR_MISSING_MODE); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
138 |
} |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
139 |
|
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
140 |
if (jnlp == null) { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
141 |
optionError(ERR_MISSING_JNLP); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
142 |
} else { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
143 |
int index = jnlp.indexOf(":"); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
144 |
if (index == -1 || index == 0) { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
145 |
optionError(ERR_INVALID_PROTOCOL_JNLP); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
146 |
} else { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
147 |
String protocol = jnlp.substring(0, index); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
148 |
if (!protocol.equalsIgnoreCase("http") && |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
149 |
!protocol.equalsIgnoreCase("https") && |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
150 |
!protocol.equalsIgnoreCase("file")) { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
151 |
optionError(ERR_INVALID_PROTOCOL_JNLP); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
152 |
} |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
153 |
} |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
154 |
} |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
155 |
|
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
156 |
if (output == null) { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
157 |
optionError(ERR_MISSING_OUTPUT); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
158 |
} else { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
159 |
File file = new File(output); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
160 |
if (file.exists()) { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
161 |
optionErrorNoHelp(ERR_OUTPUT_EXISTS); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
162 |
} |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
163 |
} |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
164 |
|
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
165 |
if (keep != null) { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
166 |
File file = new File(keep); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
167 |
if (file.exists()) { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
168 |
optionErrorNoHelp(ERR_KEEP_EXISTS); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
169 |
} |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
170 |
} |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
171 |
|
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
172 |
jpackagerOptions.forEach((option) -> { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
173 |
if (isBlockedOption(option)) { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
174 |
Log.error(option + " is not allowed via --jpackager-options, since it will conflict with " |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
175 |
+ "same option generated by JNLPConverter."); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
176 |
} |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
177 |
}); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
178 |
} |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
179 |
|
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
180 |
public boolean isOptionPresent(String option) { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
181 |
for (String jpackagerOption : jpackagerOptions) { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
182 |
if (jpackagerOption.equalsIgnoreCase(option)) { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
183 |
return true; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
184 |
} |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
185 |
} |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
186 |
|
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
187 |
return false; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
188 |
} |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
189 |
|
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
190 |
private boolean isBlockedOption(String option) { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
191 |
for (String blockedOption : BLOCKED_JPACKAGER_OPTIONS) { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
192 |
if (blockedOption.equalsIgnoreCase(option)) { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
193 |
return true; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
194 |
} |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
195 |
} |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
196 |
|
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
197 |
return false; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
198 |
} |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
199 |
|
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
200 |
public static void showHelp() { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
201 |
// System.out.println("********* Help should not be longer then 80 characters as per JEP-293 *********"); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
202 |
System.out.println("Usage: java -jar JNLPConverter.jar <mode> <options>"); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
203 |
System.out.println(""); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
204 |
System.out.println("where mode is one of:"); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
205 |
System.out.println(" create-image"); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
206 |
System.out.println(" Generates a platform-specific application image."); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
207 |
System.out.println(" create-installer <type>"); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
208 |
System.out.println(" Generates a platform-specific installer for the application."); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
209 |
System.out.println(" Valid values for \"type\" are \"msi\", \"rpm\", \"deb\", \"dmg\", \"pkg\","); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
210 |
System.out.println(" \"pkg-app-store\". If \"type\" is omitted, all supported types of installable"); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
211 |
System.out.println(" packages for current platform will be generated."); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
212 |
System.out.println(""); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
213 |
System.out.println("Possible options include:"); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
214 |
System.out.println(" -j, --jnlp <path>"); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
215 |
System.out.println(" Full path to JNLP file. Supported protocols are HTTP/HTTPS/FILE."); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
216 |
System.out.println(" -o, --output <path>"); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
217 |
System.out.println(" Name of the directory where generated output files are placed."); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
218 |
System.out.println(" -k, --keep <path>"); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
219 |
System.out.println(" Keep JNLP, JARs and command line arguments for jpackager"); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
220 |
System.out.println(" in directory provided."); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
221 |
System.out.println(" --jpackager-options <options>"); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
222 |
System.out.println(" Specify additional jpackager options or overwrite provided by JNLPConverter."); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
223 |
System.out.println(" All jpackager options can be specified except: --output -o, --input -i,"); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
224 |
System.out.println(" --files -f, --main-jar -j and --class -c."); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
225 |
System.out.println(" -h, --help, -?"); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
226 |
System.out.println(" Print this help message"); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
227 |
System.out.println(" -v, --verbose"); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
228 |
System.out.println(" Enable verbose output."); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
229 |
System.out.println(" --version"); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
230 |
System.out.println(" Version information."); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
231 |
System.out.println("To specify an argument for a long option, you can use --<name>=<value> or"); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
232 |
System.out.println("--<name> <value>."); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
233 |
System.out.println("To specify proxy server use standard Java properties http.proxyHost and http.proxyPort."); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
234 |
} |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
235 |
|
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
236 |
private static boolean isInstallerType(String type) { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
237 |
for (String installerType : INSTALLER_TYPES) { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
238 |
if (installerType.equals(type)) { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
239 |
return true; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
240 |
} |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
241 |
} |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
242 |
|
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
243 |
return false; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
244 |
} |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
245 |
|
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
246 |
public static Options parseArgs(String[] args) { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
247 |
Options options = new Options(); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
248 |
|
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
249 |
int index = 0; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
250 |
if (args.length >= 1) { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
251 |
switch (args[0]) { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
252 |
case "create-image": |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
253 |
options.createImage = true; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
254 |
index = 1; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
255 |
break; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
256 |
case "create-installer": |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
257 |
options.createInstaller = true; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
258 |
index = 1; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
259 |
if (args.length >= 2) { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
260 |
if (isInstallerType(args[1])) { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
261 |
options.installerType = args[1]; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
262 |
index = 2; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
263 |
} |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
264 |
} |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
265 |
break; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
266 |
case "-h": |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
267 |
case "--help": |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
268 |
case "-?": |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
269 |
case "--version": |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
270 |
break; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
271 |
default: |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
272 |
optionError(Options.ERR_MISSING_MODE); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
273 |
break; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
274 |
} |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
275 |
} |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
276 |
|
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
277 |
for (int i = index; i < args.length; i++) { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
278 |
String arg = args[i]; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
279 |
|
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
280 |
if (arg.equals("--jnlp")) { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
281 |
if (++i >= args.length) { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
282 |
optionError(Options.ERR_MISSING_VALUE, "--jnlp"); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
283 |
} |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
284 |
options.jnlp = args[i]; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
285 |
} else if (arg.startsWith(JNLP_OPTION_PREFIX)) { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
286 |
options.jnlp = arg.substring(JNLP_OPTION_PREFIX.length()); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
287 |
} else if (arg.equals("--output")) { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
288 |
if (++i >= args.length) { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
289 |
optionError(Options.ERR_MISSING_VALUE, "--output"); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
290 |
} |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
291 |
options.output = args[i]; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
292 |
} else if (arg.startsWith(OUTPUT_OPTION_PREFIX)) { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
293 |
options.output = arg.substring(OUTPUT_OPTION_PREFIX.length()); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
294 |
} else if (arg.equals("--keep")) { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
295 |
if (++i >= args.length) { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
296 |
optionError(Options.ERR_MISSING_VALUE, "--keep"); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
297 |
} |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
298 |
options.keep = args[i]; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
299 |
} else if (arg.startsWith(KEEP_OPTION_PREFIX)) { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
300 |
options.keep = arg.substring(KEEP_OPTION_PREFIX.length()); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
301 |
} else if (arg.equals("--help")) { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
302 |
options.help = true; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
303 |
} else if (arg.equals("--verbose")) { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
304 |
options.verbose = true; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
305 |
} else if (arg.equals("--version")) { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
306 |
options.version = true; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
307 |
} else if (arg.equals("-j")) { // short options |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
308 |
if (++i >= args.length) { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
309 |
optionError(Options.ERR_MISSING_VALUE, "-j"); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
310 |
} |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
311 |
options.jnlp = args[i]; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
312 |
} else if (arg.startsWith(JNLP_OPTION_SHORT_PREFIX)) { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
313 |
options.jnlp = arg.substring(JNLP_OPTION_SHORT_PREFIX.length()); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
314 |
} else if (arg.equals("-o")) { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
315 |
if (++i >= args.length) { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
316 |
optionError(Options.ERR_MISSING_VALUE, "-o"); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
317 |
} |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
318 |
options.output = args[i]; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
319 |
} else if (arg.startsWith(OUTPUT_OPTION_SHORT_PREFIX)) { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
320 |
options.output = arg.substring(OUTPUT_OPTION_SHORT_PREFIX.length()); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
321 |
} else if (arg.equals("-k")) { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
322 |
if (++i >= args.length) { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
323 |
optionError(Options.ERR_MISSING_VALUE, "-k"); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
324 |
} |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
325 |
options.keep = args[i]; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
326 |
} else if (arg.startsWith(KEEP_OPTION_SHORT_PREFIX)) { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
327 |
options.keep = arg.substring(KEEP_OPTION_SHORT_PREFIX.length()); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
328 |
} else if (arg.equals("-h") || arg.equals("-?")) { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
329 |
options.help = true; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
330 |
} else if (arg.equals("-v")) { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
331 |
options.verbose = true; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
332 |
} else if (arg.equals("--jpackager-options")) { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
333 |
for (i = (i + 1); i < args.length; i++) { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
334 |
if (!options.isRuntimeImageSet) { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
335 |
if (args[i].equals(RUNTIME_IMAGE_OPTION)) { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
336 |
options.isRuntimeImageSet = true; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
337 |
} |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
338 |
} |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
339 |
options.jpackagerOptions.add(args[i]); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
340 |
} |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
341 |
} else { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
342 |
optionError(ERR_UNKNOWN_OPTION, arg); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
343 |
} |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
344 |
} |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
345 |
|
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
346 |
//options.display(); // For testing only |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
347 |
options.validate(); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
348 |
|
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
349 |
return options; |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
350 |
} |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
351 |
|
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
352 |
private static void optionErrorNoHelp(String msg) { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
353 |
System.out.println(msg); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
354 |
System.exit(1); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
355 |
} |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
356 |
|
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
357 |
private static void optionError(String msg) { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
358 |
System.out.println(msg); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
359 |
System.out.println(); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
360 |
showHelp(); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
361 |
System.exit(1); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
362 |
} |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
363 |
|
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
364 |
private static void optionError(String msg, String option) { |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
365 |
System.out.println(msg + option); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
366 |
System.out.println(); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
367 |
showHelp(); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
368 |
System.exit(1); |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
369 |
} |
eaca4369b068
8198472: Add support for creating bundles from JNLP files
herrick
parents:
diff
changeset
|
370 |
} |