author | herrick |
Tue, 18 Dec 2018 15:10:45 -0500 | |
branch | JDK-8200758-branch |
changeset 57077 | 8f9cf6ad59f0 |
parent 57070 | 42783e8e73de |
child 57078 | db003bfc5bf7 |
permissions | -rw-r--r-- |
57038 | 1 |
/* |
2 |
* Copyright (c) 2015, 2018, 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 |
|
23 |
* questions. |
|
24 |
*/ |
|
25 |
||
57039 | 26 |
package jdk.jpackage.internal; |
57038 | 27 |
|
57039 | 28 |
import jdk.jpackage.internal.resources.WinResources; |
57038 | 29 |
|
30 |
import java.io.File; |
|
31 |
import java.io.FileOutputStream; |
|
32 |
import java.io.FileInputStream; |
|
33 |
import java.io.IOException; |
|
34 |
import java.io.InputStream; |
|
35 |
import java.io.OutputStream; |
|
36 |
import java.io.OutputStreamWriter; |
|
37 |
import java.io.UncheckedIOException; |
|
38 |
import java.io.Writer; |
|
39 |
import java.io.BufferedWriter; |
|
40 |
import java.io.FileWriter; |
|
41 |
import java.nio.file.Files; |
|
42 |
import java.nio.file.Path; |
|
43 |
import java.nio.file.attribute.PosixFilePermission; |
|
44 |
import java.text.MessageFormat; |
|
45 |
import java.util.HashMap; |
|
46 |
import java.util.List; |
|
47 |
import java.util.Map; |
|
48 |
import java.util.Objects; |
|
49 |
import java.util.ResourceBundle; |
|
50 |
import java.util.Set; |
|
51 |
import java.util.concurrent.atomic.AtomicReference; |
|
52 |
import java.util.regex.Pattern; |
|
53 |
import java.util.stream.Stream; |
|
57039 | 54 |
import jdk.jpackage.internal.Arguments; |
57038 | 55 |
|
57039 | 56 |
import static jdk.jpackage.internal.StandardBundlerParam.*; |
57038 | 57 |
|
58 |
public class WindowsAppImageBuilder extends AbstractAppImageBuilder { |
|
59 |
||
57059 | 60 |
private static final ResourceBundle I18N = ResourceBundle.getBundle( |
61 |
"jdk.jpackage.internal.resources.WinResources"); |
|
57038 | 62 |
|
63 |
private final static String EXECUTABLE_NAME = "WinLauncher.exe"; |
|
57064
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
57059
diff
changeset
|
64 |
private final static String LIBRARY_NAME = "applauncher.dll"; |
57038 | 65 |
private final static String REDIST_MSVCR = "vcruntimeVS_VER.dll"; |
66 |
private final static String REDIST_MSVCP = "msvcpVS_VER.dll"; |
|
67 |
||
68 |
private final static String TEMPLATE_APP_ICON ="javalogo_white_48.ico"; |
|
69 |
||
70 |
private static final String EXECUTABLE_PROPERTIES_TEMPLATE = |
|
57059 | 71 |
"WinLauncher.template"; |
57038 | 72 |
|
73 |
private final Path root; |
|
74 |
private final Path appDir; |
|
57077
8f9cf6ad59f0
8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents:
57070
diff
changeset
|
75 |
private final Path appModsDir; |
57038 | 76 |
private final Path runtimeDir; |
77 |
private final Path mdir; |
|
78 |
||
79 |
private final Map<String, ? super Object> params; |
|
80 |
||
81 |
public static final BundlerParamInfo<File> CONFIG_ROOT = |
|
82 |
new WindowsBundlerParam<>( |
|
83 |
I18N.getString("param.config-root.name"), |
|
84 |
I18N.getString("param.config-root.description"), |
|
85 |
"configRoot", |
|
86 |
File.class, |
|
87 |
params -> { |
|
88 |
File imagesRoot = |
|
89 |
new File(BUILD_ROOT.fetchFrom(params), "windows"); |
|
90 |
imagesRoot.mkdirs(); |
|
91 |
return imagesRoot; |
|
92 |
}, |
|
93 |
(s, p) -> null); |
|
94 |
||
95 |
public static final BundlerParamInfo<Boolean> REBRAND_EXECUTABLE = |
|
96 |
new WindowsBundlerParam<>( |
|
97 |
I18N.getString("param.rebrand-executable.name"), |
|
98 |
I18N.getString("param.rebrand-executable.description"), |
|
99 |
"win.launcher.rebrand", |
|
100 |
Boolean.class, |
|
101 |
params -> Boolean.TRUE, |
|
102 |
(s, p) -> Boolean.valueOf(s)); |
|
103 |
||
104 |
public static final BundlerParamInfo<File> ICON_ICO = |
|
105 |
new StandardBundlerParam<>( |
|
106 |
I18N.getString("param.icon-ico.name"), |
|
107 |
I18N.getString("param.icon-ico.description"), |
|
108 |
"icon.ico", |
|
109 |
File.class, |
|
110 |
params -> { |
|
111 |
File f = ICON.fetchFrom(params); |
|
112 |
if (f != null && !f.getName().toLowerCase().endsWith(".ico")) { |
|
113 |
Log.error(MessageFormat.format( |
|
114 |
I18N.getString("message.icon-not-ico"), f)); |
|
115 |
return null; |
|
116 |
} |
|
117 |
return f; |
|
118 |
}, |
|
119 |
(s, p) -> new File(s)); |
|
120 |
||
121 |
public static final StandardBundlerParam<Boolean> CONSOLE_HINT = |
|
122 |
new WindowsBundlerParam<>( |
|
123 |
I18N.getString("param.console-hint.name"), |
|
124 |
I18N.getString("param.console-hint.description"), |
|
125 |
Arguments.CLIOptions.WIN_CONSOLE_HINT.getId(), |
|
126 |
Boolean.class, |
|
127 |
params -> false, |
|
128 |
// valueOf(null) is false, |
|
129 |
// and we actually do want null in some cases |
|
130 |
(s, p) -> (s == null |
|
131 |
|| "null".equalsIgnoreCase(s)) ? true : Boolean.valueOf(s)); |
|
132 |
||
133 |
public WindowsAppImageBuilder(Map<String, Object> config, Path imageOutDir) |
|
134 |
throws IOException { |
|
135 |
super(config, |
|
136 |
imageOutDir.resolve(APP_NAME.fetchFrom(config) + "/runtime")); |
|
137 |
||
138 |
Objects.requireNonNull(imageOutDir); |
|
139 |
||
140 |
this.params = config; |
|
141 |
||
142 |
this.root = imageOutDir.resolve(APP_NAME.fetchFrom(params)); |
|
143 |
this.appDir = root.resolve("app"); |
|
57077
8f9cf6ad59f0
8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents:
57070
diff
changeset
|
144 |
this.appModsDir = appDir.resolve("mods"); |
57038 | 145 |
this.runtimeDir = root.resolve("runtime"); |
146 |
this.mdir = runtimeDir.resolve("lib"); |
|
147 |
Files.createDirectories(appDir); |
|
148 |
Files.createDirectories(runtimeDir); |
|
149 |
} |
|
150 |
||
151 |
public WindowsAppImageBuilder(String jreName, Path imageOutDir) |
|
152 |
throws IOException { |
|
153 |
super(null, imageOutDir.resolve(jreName)); |
|
154 |
||
155 |
Objects.requireNonNull(imageOutDir); |
|
156 |
||
157 |
this.params = null; |
|
158 |
this.root = imageOutDir.resolve(jreName); |
|
159 |
this.appDir = null; |
|
57077
8f9cf6ad59f0
8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents:
57070
diff
changeset
|
160 |
this.appModsDir = null; |
57038 | 161 |
this.runtimeDir = root; |
162 |
this.mdir = runtimeDir.resolve("lib"); |
|
163 |
Files.createDirectories(runtimeDir); |
|
164 |
} |
|
165 |
||
166 |
private Path destFile(String dir, String filename) { |
|
167 |
return runtimeDir.resolve(dir).resolve(filename); |
|
168 |
} |
|
169 |
||
170 |
private void writeEntry(InputStream in, Path dstFile) throws IOException { |
|
171 |
Files.createDirectories(dstFile.getParent()); |
|
172 |
Files.copy(in, dstFile); |
|
173 |
} |
|
174 |
||
175 |
private void writeSymEntry(Path dstFile, Path target) throws IOException { |
|
176 |
Files.createDirectories(dstFile.getParent()); |
|
177 |
Files.createLink(dstFile, target); |
|
178 |
} |
|
179 |
||
180 |
/** |
|
181 |
* chmod ugo+x file |
|
182 |
*/ |
|
183 |
private void setExecutable(Path file) { |
|
184 |
try { |
|
185 |
Set<PosixFilePermission> perms = |
|
186 |
Files.getPosixFilePermissions(file); |
|
187 |
perms.add(PosixFilePermission.OWNER_EXECUTE); |
|
188 |
perms.add(PosixFilePermission.GROUP_EXECUTE); |
|
189 |
perms.add(PosixFilePermission.OTHERS_EXECUTE); |
|
190 |
Files.setPosixFilePermissions(file, perms); |
|
191 |
} catch (IOException ioe) { |
|
192 |
throw new UncheckedIOException(ioe); |
|
193 |
} |
|
194 |
} |
|
195 |
||
196 |
private static void createUtf8File(File file, String content) |
|
197 |
throws IOException { |
|
198 |
try (OutputStream fout = new FileOutputStream(file); |
|
199 |
Writer output = new OutputStreamWriter(fout, "UTF-8")) { |
|
200 |
output.write(content); |
|
201 |
} |
|
202 |
} |
|
203 |
||
204 |
public static String getLauncherName(Map<String, ? super Object> p) { |
|
205 |
return APP_FS_NAME.fetchFrom(p) + ".exe"; |
|
206 |
} |
|
207 |
||
208 |
// Returns launcher resource name for launcher we need to use. |
|
57064
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
57059
diff
changeset
|
209 |
public static String getLauncherResourceName( |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
57059
diff
changeset
|
210 |
Map<String, ? super Object> p) { |
57038 | 211 |
if (CONSOLE_HINT.fetchFrom(p)) { |
57064
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
57059
diff
changeset
|
212 |
return "jpackageapplauncher.exe"; |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
57059
diff
changeset
|
213 |
} else { |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
57059
diff
changeset
|
214 |
return "jpackageapplauncherw.exe"; |
57038 | 215 |
} |
216 |
} |
|
217 |
||
218 |
public static String getLauncherCfgName(Map<String, ? super Object> p) { |
|
219 |
return "app/" + APP_FS_NAME.fetchFrom(p) +".cfg"; |
|
220 |
} |
|
221 |
||
222 |
private File getConfig_AppIcon(Map<String, ? super Object> params) { |
|
223 |
return new File(getConfigRoot(params), |
|
224 |
APP_FS_NAME.fetchFrom(params) + ".ico"); |
|
225 |
} |
|
226 |
||
227 |
private File getConfig_ExecutableProperties( |
|
228 |
Map<String, ? super Object> params) { |
|
229 |
return new File(getConfigRoot(params), |
|
230 |
APP_FS_NAME.fetchFrom(params) + ".properties"); |
|
231 |
} |
|
232 |
||
233 |
File getConfigRoot(Map<String, ? super Object> params) { |
|
234 |
return CONFIG_ROOT.fetchFrom(params); |
|
235 |
} |
|
236 |
||
237 |
protected void cleanupConfigFiles(Map<String, ? super Object> params) { |
|
238 |
if (Log.isDebug() || Log.isVerbose()) { |
|
239 |
return; |
|
240 |
} |
|
241 |
||
242 |
getConfig_AppIcon(params).delete(); |
|
243 |
getConfig_ExecutableProperties(params).delete(); |
|
244 |
} |
|
245 |
||
246 |
@Override |
|
57077
8f9cf6ad59f0
8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents:
57070
diff
changeset
|
247 |
public Path getAppDir() { |
8f9cf6ad59f0
8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents:
57070
diff
changeset
|
248 |
return appDir; |
8f9cf6ad59f0
8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents:
57070
diff
changeset
|
249 |
} |
8f9cf6ad59f0
8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents:
57070
diff
changeset
|
250 |
|
8f9cf6ad59f0
8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents:
57070
diff
changeset
|
251 |
@Override |
8f9cf6ad59f0
8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents:
57070
diff
changeset
|
252 |
public Path getAppModsDir() { |
8f9cf6ad59f0
8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents:
57070
diff
changeset
|
253 |
return appModsDir; |
8f9cf6ad59f0
8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents:
57070
diff
changeset
|
254 |
} |
8f9cf6ad59f0
8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents:
57070
diff
changeset
|
255 |
|
8f9cf6ad59f0
8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents:
57070
diff
changeset
|
256 |
@Override |
57038 | 257 |
public InputStream getResourceAsStream(String name) { |
258 |
return WinResources.class.getResourceAsStream(name); |
|
259 |
} |
|
260 |
||
261 |
@Override |
|
262 |
public void prepareApplicationFiles() throws IOException { |
|
263 |
Map<String, ? super Object> originalParams = new HashMap<>(params); |
|
264 |
File rootFile = root.toFile(); |
|
265 |
if (!rootFile.isDirectory() && !rootFile.mkdirs()) { |
|
266 |
throw new RuntimeException(MessageFormat.format(I18N.getString( |
|
267 |
"error.cannot-create-output-dir"), rootFile.getAbsolutePath())); |
|
268 |
} |
|
269 |
if (!rootFile.canWrite()) { |
|
270 |
throw new RuntimeException(MessageFormat.format( |
|
271 |
I18N.getString("error.cannot-write-to-output-dir"), |
|
272 |
rootFile.getAbsolutePath())); |
|
273 |
} |
|
274 |
try { |
|
275 |
// create the .exe launchers |
|
276 |
createLauncherForEntryPoint(params); |
|
277 |
||
278 |
// copy the jars |
|
279 |
copyApplication(params); |
|
280 |
||
281 |
// copy in the needed libraries |
|
57064
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
57059
diff
changeset
|
282 |
try (InputStream is_lib = getResourceAsStream(LIBRARY_NAME)) { |
57038 | 283 |
Files.copy(is_lib, root.resolve(LIBRARY_NAME)); |
284 |
} |
|
285 |
||
286 |
copyMSVCDLLs(); |
|
287 |
||
288 |
// create the secondary launchers, if any |
|
289 |
List<Map<String, ? super Object>> entryPoints = |
|
290 |
StandardBundlerParam.SECONDARY_LAUNCHERS.fetchFrom(params); |
|
291 |
for (Map<String, ? super Object> entryPoint : entryPoints) { |
|
292 |
Map<String, ? super Object> tmp = new HashMap<>(originalParams); |
|
293 |
tmp.putAll(entryPoint); |
|
294 |
createLauncherForEntryPoint(tmp); |
|
295 |
} |
|
296 |
} finally { |
|
297 |
cleanupConfigFiles(params); |
|
298 |
} |
|
299 |
} |
|
300 |
||
301 |
@Override |
|
57070 | 302 |
public void prepareJreFiles() throws IOException {} |
57038 | 303 |
|
304 |
private void copyMSVCDLLs() throws IOException { |
|
305 |
AtomicReference<IOException> ioe = new AtomicReference<>(); |
|
306 |
try (Stream<Path> files = Files.list(runtimeDir.resolve("bin"))) { |
|
307 |
files.filter(p -> Pattern.matches( |
|
308 |
"^(vcruntime|msvcp|msvcr|ucrtbase|api-ms-win-).*\\.dll$", |
|
309 |
p.toFile().getName().toLowerCase())) |
|
310 |
.forEach(p -> { |
|
311 |
try { |
|
312 |
Files.copy(p, root.resolve((p.toFile().getName()))); |
|
313 |
} catch (IOException e) { |
|
314 |
ioe.set(e); |
|
315 |
} |
|
316 |
}); |
|
317 |
} |
|
318 |
||
319 |
IOException e = ioe.get(); |
|
320 |
if (e != null) { |
|
321 |
throw e; |
|
322 |
} |
|
323 |
} |
|
324 |
||
325 |
// TODO: do we still need this? |
|
326 |
private boolean copyMSVCDLLs(String VS_VER) throws IOException { |
|
327 |
final InputStream REDIST_MSVCR_URL = |
|
328 |
WinResources.class.getResourceAsStream( |
|
329 |
REDIST_MSVCR.replaceAll("VS_VER", VS_VER)); |
|
330 |
final InputStream REDIST_MSVCP_URL = |
|
331 |
WinResources.class.getResourceAsStream( |
|
332 |
REDIST_MSVCP.replaceAll("VS_VER", VS_VER)); |
|
333 |
||
334 |
if (REDIST_MSVCR_URL != null && REDIST_MSVCP_URL != null) { |
|
335 |
Files.copy( |
|
336 |
REDIST_MSVCR_URL, |
|
337 |
root.resolve(REDIST_MSVCR.replaceAll("VS_VER", VS_VER))); |
|
338 |
Files.copy( |
|
339 |
REDIST_MSVCP_URL, |
|
340 |
root.resolve(REDIST_MSVCP.replaceAll("VS_VER", VS_VER))); |
|
341 |
return true; |
|
342 |
} |
|
343 |
||
344 |
return false; |
|
345 |
} |
|
346 |
||
347 |
private void validateValueAndPut( |
|
348 |
Map<String, String> data, String key, |
|
349 |
BundlerParamInfo<String> param, |
|
350 |
Map<String, ? super Object> params) { |
|
351 |
String value = param.fetchFrom(params); |
|
352 |
if (value.contains("\r") || value.contains("\n")) { |
|
353 |
Log.error("Configuration Parameter " + param.getID() |
|
354 |
+ " contains multiple lines of text, ignore it"); |
|
355 |
data.put(key, ""); |
|
356 |
return; |
|
357 |
} |
|
358 |
data.put(key, value); |
|
359 |
} |
|
360 |
||
361 |
protected void prepareExecutableProperties( |
|
362 |
Map<String, ? super Object> params) throws IOException { |
|
363 |
Map<String, String> data = new HashMap<>(); |
|
364 |
||
365 |
// mapping Java parameters in strings for version resource |
|
366 |
data.put("COMMENTS", ""); |
|
367 |
validateValueAndPut(data, "COMPANY_NAME", VENDOR, params); |
|
368 |
validateValueAndPut(data, "FILE_DESCRIPTION", DESCRIPTION, params); |
|
369 |
validateValueAndPut(data, "FILE_VERSION", VERSION, params); |
|
370 |
data.put("INTERNAL_NAME", getLauncherName(params)); |
|
371 |
validateValueAndPut(data, "LEGAL_COPYRIGHT", COPYRIGHT, params); |
|
372 |
data.put("LEGAL_TRADEMARK", ""); |
|
373 |
data.put("ORIGINAL_FILENAME", getLauncherName(params)); |
|
374 |
data.put("PRIVATE_BUILD", ""); |
|
375 |
validateValueAndPut(data, "PRODUCT_NAME", APP_NAME, params); |
|
376 |
validateValueAndPut(data, "PRODUCT_VERSION", VERSION, params); |
|
377 |
data.put("SPECIAL_BUILD", ""); |
|
378 |
||
379 |
Writer w = new BufferedWriter( |
|
380 |
new FileWriter(getConfig_ExecutableProperties(params))); |
|
381 |
String content = preprocessTextResource(BUNDLER_PREFIX |
|
382 |
+ getConfig_ExecutableProperties(params).getName(), |
|
383 |
I18N.getString("resource.executable-properties-template"), |
|
384 |
EXECUTABLE_PROPERTIES_TEMPLATE, data, |
|
385 |
VERBOSE.fetchFrom(params), |
|
386 |
DROP_IN_RESOURCES_ROOT.fetchFrom(params)); |
|
387 |
w.write(content); |
|
388 |
w.close(); |
|
389 |
} |
|
390 |
||
391 |
private void createLauncherForEntryPoint( |
|
392 |
Map<String, ? super Object> p) throws IOException { |
|
393 |
||
394 |
File launcherIcon = ICON_ICO.fetchFrom(p); |
|
395 |
File icon = launcherIcon != null ? |
|
396 |
launcherIcon : ICON_ICO.fetchFrom(params); |
|
397 |
File iconTarget = getConfig_AppIcon(p); |
|
398 |
||
399 |
InputStream in = locateResource( |
|
400 |
"package/windows/" + APP_NAME.fetchFrom(params) + ".ico", |
|
401 |
"icon", |
|
402 |
TEMPLATE_APP_ICON, |
|
403 |
icon, |
|
404 |
VERBOSE.fetchFrom(params), |
|
405 |
DROP_IN_RESOURCES_ROOT.fetchFrom(params)); |
|
406 |
Files.copy(in, iconTarget.toPath()); |
|
407 |
||
408 |
writeCfgFile(p, root.resolve( |
|
409 |
getLauncherCfgName(p)).toFile(), "$APPDIR\\runtime"); |
|
410 |
||
411 |
prepareExecutableProperties(p); |
|
412 |
||
413 |
// Copy executable root folder |
|
414 |
Path executableFile = root.resolve(getLauncherName(p)); |
|
415 |
try (InputStream is_launcher = |
|
416 |
getResourceAsStream(getLauncherResourceName(p))) { |
|
417 |
writeEntry(is_launcher, executableFile); |
|
418 |
} |
|
419 |
||
420 |
File launcher = executableFile.toFile(); |
|
421 |
launcher.setWritable(true, true); |
|
422 |
||
423 |
// Update branding of EXE file |
|
424 |
if (REBRAND_EXECUTABLE.fetchFrom(p)) { |
|
425 |
File tool = new File( |
|
57039 | 426 |
System.getProperty("java.home") + "\\bin\\jpackage.exe"); |
57038 | 427 |
|
428 |
// Run tool on launcher file to change the icon and the metadata. |
|
429 |
try { |
|
430 |
if (WindowsDefender.isThereAPotentialWindowsDefenderIssue()) { |
|
431 |
Log.error(MessageFormat.format(I18N.getString( |
|
432 |
"message.potential.windows.defender.issue"), |
|
433 |
WindowsDefender.getUserTempDirectory())); |
|
434 |
} |
|
435 |
||
436 |
launcher.setWritable(true); |
|
437 |
||
438 |
if (iconTarget.exists()) { |
|
439 |
ProcessBuilder pb = new ProcessBuilder( |
|
440 |
tool.getAbsolutePath(), |
|
441 |
"--icon-swap", |
|
442 |
iconTarget.getAbsolutePath(), |
|
443 |
launcher.getAbsolutePath()); |
|
444 |
IOUtils.exec(pb, false); |
|
445 |
} |
|
446 |
||
447 |
File executableProperties = getConfig_ExecutableProperties(p); |
|
448 |
||
449 |
if (executableProperties.exists()) { |
|
450 |
ProcessBuilder pb = new ProcessBuilder( |
|
451 |
tool.getAbsolutePath(), |
|
452 |
"--version-swap", |
|
453 |
executableProperties.getAbsolutePath(), |
|
454 |
launcher.getAbsolutePath()); |
|
455 |
IOUtils.exec(pb, false); |
|
456 |
} |
|
457 |
} |
|
458 |
finally { |
|
459 |
executableFile.toFile().setReadOnly(); |
|
460 |
} |
|
461 |
} |
|
462 |
||
463 |
Files.copy(iconTarget.toPath(), |
|
464 |
root.resolve(APP_NAME.fetchFrom(p) + ".ico")); |
|
465 |
} |
|
466 |
||
467 |
private void copyApplication(Map<String, ? super Object> params) |
|
468 |
throws IOException { |
|
469 |
List<RelativeFileSet> appResourcesList = |
|
470 |
APP_RESOURCES_LIST.fetchFrom(params); |
|
471 |
if (appResourcesList == null) { |
|
472 |
throw new RuntimeException("Null app resources?"); |
|
473 |
} |
|
474 |
for (RelativeFileSet appResources : appResourcesList) { |
|
475 |
if (appResources == null) { |
|
476 |
throw new RuntimeException("Null app resources?"); |
|
477 |
} |
|
478 |
File srcdir = appResources.getBaseDirectory(); |
|
479 |
for (String fname : appResources.getIncludedFiles()) { |
|
480 |
copyEntry(appDir, srcdir, fname); |
|
481 |
} |
|
482 |
} |
|
483 |
} |
|
484 |
||
485 |
} |