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