1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package ru.akman.maven.plugins.jpackage;
18
19 import java.io.BufferedReader;
20 import java.io.File;
21 import java.io.IOException;
22 import java.nio.charset.Charset;
23 import java.nio.file.Files;
24 import java.util.Properties;
25 import org.apache.commons.lang3.StringUtils;
26
27
28
29
30 public class Launcher {
31
32
33
34
35 private String name;
36
37
38
39
40 private File file;
41
42
43
44
45 private String module;
46
47
48
49
50 private String mainjar;
51
52
53
54
55 private String mainclass;
56
57
58
59
60 private String arguments;
61
62
63
64
65 private String javaoptions;
66
67
68
69
70 private String appversion;
71
72
73
74
75 private File icon;
76
77
78
79
80 private String winconsole;
81
82
83
84
85
86
87 public String getName() {
88 return this.name;
89 }
90
91
92
93
94
95
96 public void setName(final String name) {
97 this.name = name;
98 }
99
100
101
102
103
104
105 public String getModule() {
106 return this.module;
107 }
108
109
110
111
112
113
114 public void setModule(final String module) {
115 this.module = module;
116 }
117
118
119
120
121
122
123 public String getMainJar() {
124 return this.mainjar;
125 }
126
127
128
129
130
131
132 public void setMainJar(final String mainjar) {
133 this.mainjar = mainjar;
134 }
135
136
137
138
139
140
141 public String getMainClass() {
142 return this.mainclass;
143 }
144
145
146
147
148
149
150 public void setMainClass(final String mainclass) {
151 this.mainclass = mainclass;
152 }
153
154
155
156
157
158
159 public String getArguments() {
160 return this.arguments;
161 }
162
163
164
165
166
167
168 public void setArguments(final String arguments) {
169 this.arguments = arguments;
170 }
171
172
173
174
175
176
177 public String getJavaOptions() {
178 return this.javaoptions;
179 }
180
181
182
183
184
185
186 public void setJavaOptions(final String javaoptions) {
187 this.javaoptions = javaoptions;
188 }
189
190
191
192
193
194
195 public String getAppVersion() {
196 return this.appversion;
197 }
198
199
200
201
202
203
204 public void setAppVersion(final String appversion) {
205 this.appversion = appversion;
206 }
207
208
209
210
211
212
213 public File getIcon() {
214 return this.icon;
215 }
216
217
218
219
220
221
222 public void setIcon(final File icon) {
223 this.icon = icon;
224 }
225
226
227
228
229
230
231 public boolean isWinConsole() {
232 return String.valueOf(true).equals(this.winconsole);
233 }
234
235
236
237
238
239
240 public void setWinConsole(final String winconsole) {
241 this.winconsole = winconsole;
242 }
243
244
245
246
247
248
249 public File getFile() {
250 return this.file;
251 }
252
253
254
255
256
257
258 public void setFile(final File file) {
259 this.file = file;
260 }
261
262
263
264
265
266
267
268
269
270
271 public Properties getProperties(final Charset charset) throws IOException {
272 final Properties props = new Properties();
273 if (file != null) {
274 try (BufferedReader br =
275 Files.newBufferedReader(file.toPath(), charset)) {
276 props.load(br);
277 }
278 }
279 if (!StringUtils.isBlank(module)) {
280 props.setProperty("module", module);
281 }
282 if (!StringUtils.isBlank(mainjar)) {
283 props.setProperty("main-jar", mainjar);
284 }
285 if (!StringUtils.isBlank(mainclass)) {
286 props.setProperty("main-class", mainclass);
287 }
288 if (!StringUtils.isBlank(arguments)) {
289 props.setProperty("arguments", arguments);
290 }
291 if (!StringUtils.isBlank(javaoptions)) {
292 props.setProperty("java-options", javaoptions);
293 }
294 if (!StringUtils.isBlank(appversion)) {
295 props.setProperty("app-version", appversion);
296 }
297 if (icon != null) {
298 props.setProperty("icon", icon.toString());
299 }
300 if (winconsole != null) {
301 props.setProperty("win-console", String.valueOf(isWinConsole()));
302 }
303 return props;
304 }
305
306 }