author | herrick |
Wed, 16 Oct 2019 09:57:23 -0400 | |
branch | JDK-8200758-branch |
changeset 58647 | 2c43b89b1679 |
parent 58414 | a5f66aa04f68 |
child 58695 | 64adf683bc7b |
permissions | -rw-r--r-- |
57038 | 1 |
/* |
57106
ea870b9ce89a
8216492: Update copyright of all new jpackage fils to 2019
kcr
parents:
57103
diff
changeset
|
2 |
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. |
57038 | 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 |
|
28 |
import java.io.File; |
|
29 |
import java.io.FileOutputStream; |
|
30 |
import java.io.IOException; |
|
31 |
import java.io.InputStream; |
|
32 |
import java.io.OutputStream; |
|
33 |
import java.io.OutputStreamWriter; |
|
34 |
import java.io.UncheckedIOException; |
|
35 |
import java.io.Writer; |
|
36 |
import java.io.BufferedWriter; |
|
37 |
import java.io.FileWriter; |
|
57287
90fa9a095959
JDK-8221525: jpackage fails with non-ASCII characters in --copyright
herrick
parents:
57259
diff
changeset
|
38 |
import java.nio.charset.StandardCharsets; |
57038 | 39 |
import java.nio.file.Files; |
40 |
import java.nio.file.Path; |
|
57096
d06bec27f8c9
8215903: modify behavior of retaining temporary output dir
herrick
parents:
57091
diff
changeset
|
41 |
import java.nio.file.StandardCopyOption; |
57038 | 42 |
import java.nio.file.attribute.PosixFilePermission; |
43 |
import java.text.MessageFormat; |
|
44 |
import java.util.HashMap; |
|
45 |
import java.util.List; |
|
46 |
import java.util.Map; |
|
47 |
import java.util.Objects; |
|
48 |
import java.util.ResourceBundle; |
|
49 |
import java.util.Set; |
|
50 |
import java.util.concurrent.atomic.AtomicReference; |
|
51 |
import java.util.regex.Pattern; |
|
52 |
import java.util.stream.Stream; |
|
58647
2c43b89b1679
8231862: Decouple DesktopIntegration and LinuxPackageBundler classes
herrick
parents:
58414
diff
changeset
|
53 |
import static jdk.jpackage.internal.OverridableResource.createResource; |
57038 | 54 |
|
57039 | 55 |
import static jdk.jpackage.internal.StandardBundlerParam.*; |
57038 | 56 |
|
57 |
public class WindowsAppImageBuilder extends AbstractAppImageBuilder { |
|
58 |
||
57151
38d0b67617e3
8217317: Create jpackage native library for windows
herrick
parents:
57119
diff
changeset
|
59 |
static { |
38d0b67617e3
8217317: Create jpackage native library for windows
herrick
parents:
57119
diff
changeset
|
60 |
System.loadLibrary("jpackage"); |
38d0b67617e3
8217317: Create jpackage native library for windows
herrick
parents:
57119
diff
changeset
|
61 |
} |
38d0b67617e3
8217317: Create jpackage native library for windows
herrick
parents:
57119
diff
changeset
|
62 |
|
57059 | 63 |
private static final ResourceBundle I18N = ResourceBundle.getBundle( |
64 |
"jdk.jpackage.internal.resources.WinResources"); |
|
57038 | 65 |
|
57064
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
57059
diff
changeset
|
66 |
private final static String LIBRARY_NAME = "applauncher.dll"; |
57038 | 67 |
private final static String REDIST_MSVCR = "vcruntimeVS_VER.dll"; |
68 |
private final static String REDIST_MSVCP = "msvcpVS_VER.dll"; |
|
69 |
||
57908
9a005146bc1c
8230191: Replace javacup logo with duke everywhere in jpackage
herrick
parents:
57789
diff
changeset
|
70 |
private final static String TEMPLATE_APP_ICON ="java48.ico"; |
57038 | 71 |
|
72 |
private static final String EXECUTABLE_PROPERTIES_TEMPLATE = |
|
57059 | 73 |
"WinLauncher.template"; |
57038 | 74 |
|
75 |
private final Path root; |
|
76 |
private final Path appDir; |
|
57077
8f9cf6ad59f0
8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents:
57070
diff
changeset
|
77 |
private final Path appModsDir; |
57038 | 78 |
private final Path runtimeDir; |
79 |
private final Path mdir; |
|
57407 | 80 |
private final Path binDir; |
57038 | 81 |
|
82 |
public static final BundlerParamInfo<Boolean> REBRAND_EXECUTABLE = |
|
83 |
new WindowsBundlerParam<>( |
|
84 |
"win.launcher.rebrand", |
|
85 |
Boolean.class, |
|
86 |
params -> Boolean.TRUE, |
|
87 |
(s, p) -> Boolean.valueOf(s)); |
|
88 |
||
89 |
public static final BundlerParamInfo<File> ICON_ICO = |
|
90 |
new StandardBundlerParam<>( |
|
91 |
"icon.ico", |
|
92 |
File.class, |
|
93 |
params -> { |
|
94 |
File f = ICON.fetchFrom(params); |
|
95 |
if (f != null && !f.getName().toLowerCase().endsWith(".ico")) { |
|
96 |
Log.error(MessageFormat.format( |
|
97 |
I18N.getString("message.icon-not-ico"), f)); |
|
98 |
return null; |
|
99 |
} |
|
100 |
return f; |
|
101 |
}, |
|
102 |
(s, p) -> new File(s)); |
|
103 |
||
104 |
public static final StandardBundlerParam<Boolean> CONSOLE_HINT = |
|
105 |
new WindowsBundlerParam<>( |
|
106 |
Arguments.CLIOptions.WIN_CONSOLE_HINT.getId(), |
|
107 |
Boolean.class, |
|
108 |
params -> false, |
|
109 |
// valueOf(null) is false, |
|
110 |
// and we actually do want null in some cases |
|
111 |
(s, p) -> (s == null |
|
112 |
|| "null".equalsIgnoreCase(s)) ? true : Boolean.valueOf(s)); |
|
113 |
||
57789 | 114 |
public WindowsAppImageBuilder(Map<String, Object> params, Path imageOutDir) |
57038 | 115 |
throws IOException { |
57789 | 116 |
super(params, |
117 |
imageOutDir.resolve(APP_NAME.fetchFrom(params) + "/runtime")); |
|
57038 | 118 |
|
119 |
Objects.requireNonNull(imageOutDir); |
|
120 |
||
121 |
this.root = imageOutDir.resolve(APP_NAME.fetchFrom(params)); |
|
122 |
this.appDir = root.resolve("app"); |
|
57077
8f9cf6ad59f0
8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents:
57070
diff
changeset
|
123 |
this.appModsDir = appDir.resolve("mods"); |
57038 | 124 |
this.runtimeDir = root.resolve("runtime"); |
125 |
this.mdir = runtimeDir.resolve("lib"); |
|
57740 | 126 |
this.binDir = root; |
57038 | 127 |
Files.createDirectories(appDir); |
128 |
Files.createDirectories(runtimeDir); |
|
129 |
} |
|
130 |
||
131 |
private void writeEntry(InputStream in, Path dstFile) throws IOException { |
|
132 |
Files.createDirectories(dstFile.getParent()); |
|
133 |
Files.copy(in, dstFile); |
|
134 |
} |
|
135 |
||
57438
4a31db8d42bd
8226599: use code coverage results to remove dead code
herrick
parents:
57407
diff
changeset
|
136 |
private static String getLauncherName(Map<String, ? super Object> params) { |
57396
3944e4c2f779
8223586: remove jpackage dead code and other cleanup
herrick
parents:
57287
diff
changeset
|
137 |
return APP_NAME.fetchFrom(params) + ".exe"; |
57038 | 138 |
} |
139 |
||
140 |
// 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
|
141 |
public static String getLauncherResourceName( |
57396
3944e4c2f779
8223586: remove jpackage dead code and other cleanup
herrick
parents:
57287
diff
changeset
|
142 |
Map<String, ? super Object> params) { |
3944e4c2f779
8223586: remove jpackage dead code and other cleanup
herrick
parents:
57287
diff
changeset
|
143 |
if (CONSOLE_HINT.fetchFrom(params)) { |
57064
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
57059
diff
changeset
|
144 |
return "jpackageapplauncher.exe"; |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
57059
diff
changeset
|
145 |
} else { |
a7fdadf67a92
8214899: rename papplauncher and it's library and move src to appropriate places
herrick
parents:
57059
diff
changeset
|
146 |
return "jpackageapplauncherw.exe"; |
57038 | 147 |
} |
148 |
} |
|
149 |
||
57396
3944e4c2f779
8223586: remove jpackage dead code and other cleanup
herrick
parents:
57287
diff
changeset
|
150 |
public static String getLauncherCfgName( |
3944e4c2f779
8223586: remove jpackage dead code and other cleanup
herrick
parents:
57287
diff
changeset
|
151 |
Map<String, ? super Object> params) { |
3944e4c2f779
8223586: remove jpackage dead code and other cleanup
herrick
parents:
57287
diff
changeset
|
152 |
return "app/" + APP_NAME.fetchFrom(params) +".cfg"; |
57038 | 153 |
} |
154 |
||
155 |
private File getConfig_AppIcon(Map<String, ? super Object> params) { |
|
156 |
return new File(getConfigRoot(params), |
|
57119 | 157 |
APP_NAME.fetchFrom(params) + ".ico"); |
57038 | 158 |
} |
159 |
||
160 |
private File getConfig_ExecutableProperties( |
|
161 |
Map<String, ? super Object> params) { |
|
162 |
return new File(getConfigRoot(params), |
|
57119 | 163 |
APP_NAME.fetchFrom(params) + ".properties"); |
57038 | 164 |
} |
165 |
||
166 |
File getConfigRoot(Map<String, ? super Object> params) { |
|
167 |
return CONFIG_ROOT.fetchFrom(params); |
|
168 |
} |
|
169 |
||
170 |
@Override |
|
57077
8f9cf6ad59f0
8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents:
57070
diff
changeset
|
171 |
public Path getAppDir() { |
8f9cf6ad59f0
8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents:
57070
diff
changeset
|
172 |
return appDir; |
8f9cf6ad59f0
8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents:
57070
diff
changeset
|
173 |
} |
8f9cf6ad59f0
8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents:
57070
diff
changeset
|
174 |
|
8f9cf6ad59f0
8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents:
57070
diff
changeset
|
175 |
@Override |
8f9cf6ad59f0
8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents:
57070
diff
changeset
|
176 |
public Path getAppModsDir() { |
8f9cf6ad59f0
8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents:
57070
diff
changeset
|
177 |
return appModsDir; |
8f9cf6ad59f0
8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents:
57070
diff
changeset
|
178 |
} |
8f9cf6ad59f0
8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents:
57070
diff
changeset
|
179 |
|
8f9cf6ad59f0
8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents:
57070
diff
changeset
|
180 |
@Override |
57789 | 181 |
public void prepareApplicationFiles(Map<String, ? super Object> params) |
182 |
throws IOException { |
|
57038 | 183 |
Map<String, ? super Object> originalParams = new HashMap<>(params); |
57407 | 184 |
|
185 |
try { |
|
186 |
IOUtils.writableOutputDir(root); |
|
187 |
IOUtils.writableOutputDir(binDir); |
|
188 |
} catch (PackagerException pe) { |
|
189 |
throw new RuntimeException(pe); |
|
57038 | 190 |
} |
58414
a5f66aa04f68
8230920 : jpackage problems when -input dir contains any files with "cfg" extension.
herrick
parents:
58302
diff
changeset
|
191 |
AppImageFile.save(root, params); |
57407 | 192 |
|
57096
d06bec27f8c9
8215903: modify behavior of retaining temporary output dir
herrick
parents:
57091
diff
changeset
|
193 |
// create the .exe launchers |
d06bec27f8c9
8215903: modify behavior of retaining temporary output dir
herrick
parents:
57091
diff
changeset
|
194 |
createLauncherForEntryPoint(params); |
57038 | 195 |
|
57096
d06bec27f8c9
8215903: modify behavior of retaining temporary output dir
herrick
parents:
57091
diff
changeset
|
196 |
// copy the jars |
d06bec27f8c9
8215903: modify behavior of retaining temporary output dir
herrick
parents:
57091
diff
changeset
|
197 |
copyApplication(params); |
57038 | 198 |
|
57096
d06bec27f8c9
8215903: modify behavior of retaining temporary output dir
herrick
parents:
57091
diff
changeset
|
199 |
// copy in the needed libraries |
d06bec27f8c9
8215903: modify behavior of retaining temporary output dir
herrick
parents:
57091
diff
changeset
|
200 |
try (InputStream is_lib = getResourceAsStream(LIBRARY_NAME)) { |
57407 | 201 |
Files.copy(is_lib, binDir.resolve(LIBRARY_NAME)); |
57096
d06bec27f8c9
8215903: modify behavior of retaining temporary output dir
herrick
parents:
57091
diff
changeset
|
202 |
} |
d06bec27f8c9
8215903: modify behavior of retaining temporary output dir
herrick
parents:
57091
diff
changeset
|
203 |
|
d06bec27f8c9
8215903: modify behavior of retaining temporary output dir
herrick
parents:
57091
diff
changeset
|
204 |
copyMSVCDLLs(); |
57038 | 205 |
|
57256 | 206 |
// create the additional launcher(s), if any |
57096
d06bec27f8c9
8215903: modify behavior of retaining temporary output dir
herrick
parents:
57091
diff
changeset
|
207 |
List<Map<String, ? super Object>> entryPoints = |
57256 | 208 |
StandardBundlerParam.ADD_LAUNCHERS.fetchFrom(params); |
57096
d06bec27f8c9
8215903: modify behavior of retaining temporary output dir
herrick
parents:
57091
diff
changeset
|
209 |
for (Map<String, ? super Object> entryPoint : entryPoints) { |
57259
a84c657c713d
8171959: add-launcher is not working when normal jar is used for first launcher and module is used for second launcher
herrick
parents:
57256
diff
changeset
|
210 |
createLauncherForEntryPoint( |
a84c657c713d
8171959: add-launcher is not working when normal jar is used for first launcher and module is used for second launcher
herrick
parents:
57256
diff
changeset
|
211 |
AddLauncherArguments.merge(originalParams, entryPoint)); |
57038 | 212 |
} |
213 |
} |
|
214 |
||
215 |
@Override |
|
57789 | 216 |
public void prepareJreFiles(Map<String, ? super Object> params) |
217 |
throws IOException {} |
|
57038 | 218 |
|
219 |
private void copyMSVCDLLs() throws IOException { |
|
220 |
AtomicReference<IOException> ioe = new AtomicReference<>(); |
|
221 |
try (Stream<Path> files = Files.list(runtimeDir.resolve("bin"))) { |
|
222 |
files.filter(p -> Pattern.matches( |
|
223 |
"^(vcruntime|msvcp|msvcr|ucrtbase|api-ms-win-).*\\.dll$", |
|
224 |
p.toFile().getName().toLowerCase())) |
|
225 |
.forEach(p -> { |
|
226 |
try { |
|
57407 | 227 |
Files.copy(p, binDir.resolve((p.toFile().getName()))); |
57038 | 228 |
} catch (IOException e) { |
229 |
ioe.set(e); |
|
230 |
} |
|
231 |
}); |
|
232 |
} |
|
233 |
||
234 |
IOException e = ioe.get(); |
|
235 |
if (e != null) { |
|
236 |
throw e; |
|
237 |
} |
|
238 |
} |
|
239 |
||
240 |
private void validateValueAndPut( |
|
241 |
Map<String, String> data, String key, |
|
242 |
BundlerParamInfo<String> param, |
|
243 |
Map<String, ? super Object> params) { |
|
244 |
String value = param.fetchFrom(params); |
|
245 |
if (value.contains("\r") || value.contains("\n")) { |
|
246 |
Log.error("Configuration Parameter " + param.getID() |
|
247 |
+ " contains multiple lines of text, ignore it"); |
|
248 |
data.put(key, ""); |
|
249 |
return; |
|
250 |
} |
|
251 |
data.put(key, value); |
|
252 |
} |
|
253 |
||
254 |
protected void prepareExecutableProperties( |
|
255 |
Map<String, ? super Object> params) throws IOException { |
|
57789 | 256 |
|
57038 | 257 |
Map<String, String> data = new HashMap<>(); |
258 |
||
259 |
// mapping Java parameters in strings for version resource |
|
260 |
validateValueAndPut(data, "COMPANY_NAME", VENDOR, params); |
|
261 |
validateValueAndPut(data, "FILE_DESCRIPTION", DESCRIPTION, params); |
|
262 |
validateValueAndPut(data, "FILE_VERSION", VERSION, params); |
|
263 |
data.put("INTERNAL_NAME", getLauncherName(params)); |
|
264 |
validateValueAndPut(data, "LEGAL_COPYRIGHT", COPYRIGHT, params); |
|
265 |
data.put("ORIGINAL_FILENAME", getLauncherName(params)); |
|
266 |
validateValueAndPut(data, "PRODUCT_NAME", APP_NAME, params); |
|
267 |
validateValueAndPut(data, "PRODUCT_VERSION", VERSION, params); |
|
268 |
||
58647
2c43b89b1679
8231862: Decouple DesktopIntegration and LinuxPackageBundler classes
herrick
parents:
58414
diff
changeset
|
269 |
createResource(EXECUTABLE_PROPERTIES_TEMPLATE, params) |
2c43b89b1679
8231862: Decouple DesktopIntegration and LinuxPackageBundler classes
herrick
parents:
58414
diff
changeset
|
270 |
.setCategory(I18N.getString("resource.executable-properties-template")) |
2c43b89b1679
8231862: Decouple DesktopIntegration and LinuxPackageBundler classes
herrick
parents:
58414
diff
changeset
|
271 |
.setSubstitutionData(data) |
2c43b89b1679
8231862: Decouple DesktopIntegration and LinuxPackageBundler classes
herrick
parents:
58414
diff
changeset
|
272 |
.saveToFile(getConfig_ExecutableProperties(params)); |
57038 | 273 |
} |
274 |
||
275 |
private void createLauncherForEntryPoint( |
|
57396
3944e4c2f779
8223586: remove jpackage dead code and other cleanup
herrick
parents:
57287
diff
changeset
|
276 |
Map<String, ? super Object> params) throws IOException { |
57038 | 277 |
|
57396
3944e4c2f779
8223586: remove jpackage dead code and other cleanup
herrick
parents:
57287
diff
changeset
|
278 |
File iconTarget = getConfig_AppIcon(params); |
57038 | 279 |
|
58647
2c43b89b1679
8231862: Decouple DesktopIntegration and LinuxPackageBundler classes
herrick
parents:
58414
diff
changeset
|
280 |
createResource(TEMPLATE_APP_ICON, params) |
2c43b89b1679
8231862: Decouple DesktopIntegration and LinuxPackageBundler classes
herrick
parents:
58414
diff
changeset
|
281 |
.setCategory("icon") |
2c43b89b1679
8231862: Decouple DesktopIntegration and LinuxPackageBundler classes
herrick
parents:
58414
diff
changeset
|
282 |
.setExternal(ICON_ICO.fetchFrom(params)) |
2c43b89b1679
8231862: Decouple DesktopIntegration and LinuxPackageBundler classes
herrick
parents:
58414
diff
changeset
|
283 |
.saveToFile(iconTarget); |
57038 | 284 |
|
57396
3944e4c2f779
8223586: remove jpackage dead code and other cleanup
herrick
parents:
57287
diff
changeset
|
285 |
writeCfgFile(params, root.resolve( |
57450
82c78b40b39d
8227058: Regressions related to no longer setting user.dir
herrick
parents:
57446
diff
changeset
|
286 |
getLauncherCfgName(params)).toFile()); |
57038 | 287 |
|
57396
3944e4c2f779
8223586: remove jpackage dead code and other cleanup
herrick
parents:
57287
diff
changeset
|
288 |
prepareExecutableProperties(params); |
57038 | 289 |
|
57407 | 290 |
// Copy executable to bin folder |
291 |
Path executableFile = binDir.resolve(getLauncherName(params)); |
|
292 |
||
57038 | 293 |
try (InputStream is_launcher = |
57396
3944e4c2f779
8223586: remove jpackage dead code and other cleanup
herrick
parents:
57287
diff
changeset
|
294 |
getResourceAsStream(getLauncherResourceName(params))) { |
57038 | 295 |
writeEntry(is_launcher, executableFile); |
296 |
} |
|
297 |
||
298 |
File launcher = executableFile.toFile(); |
|
299 |
launcher.setWritable(true, true); |
|
300 |
||
301 |
// Update branding of EXE file |
|
57396
3944e4c2f779
8223586: remove jpackage dead code and other cleanup
herrick
parents:
57287
diff
changeset
|
302 |
if (REBRAND_EXECUTABLE.fetchFrom(params)) { |
57038 | 303 |
try { |
57151
38d0b67617e3
8217317: Create jpackage native library for windows
herrick
parents:
57119
diff
changeset
|
304 |
String tempDirectory = WindowsDefender.getUserTempDirectory(); |
38d0b67617e3
8217317: Create jpackage native library for windows
herrick
parents:
57119
diff
changeset
|
305 |
if (Arguments.CLIOptions.context().userProvidedBuildRoot) { |
57396
3944e4c2f779
8223586: remove jpackage dead code and other cleanup
herrick
parents:
57287
diff
changeset
|
306 |
tempDirectory = |
3944e4c2f779
8223586: remove jpackage dead code and other cleanup
herrick
parents:
57287
diff
changeset
|
307 |
TEMP_ROOT.fetchFrom(params).getAbsolutePath(); |
57151
38d0b67617e3
8217317: Create jpackage native library for windows
herrick
parents:
57119
diff
changeset
|
308 |
} |
38d0b67617e3
8217317: Create jpackage native library for windows
herrick
parents:
57119
diff
changeset
|
309 |
if (WindowsDefender.isThereAPotentialWindowsDefenderIssue( |
38d0b67617e3
8217317: Create jpackage native library for windows
herrick
parents:
57119
diff
changeset
|
310 |
tempDirectory)) { |
57038 | 311 |
Log.error(MessageFormat.format(I18N.getString( |
312 |
"message.potential.windows.defender.issue"), |
|
57151
38d0b67617e3
8217317: Create jpackage native library for windows
herrick
parents:
57119
diff
changeset
|
313 |
tempDirectory)); |
57038 | 314 |
} |
315 |
||
316 |
launcher.setWritable(true); |
|
317 |
||
318 |
if (iconTarget.exists()) { |
|
57151
38d0b67617e3
8217317: Create jpackage native library for windows
herrick
parents:
57119
diff
changeset
|
319 |
iconSwap(iconTarget.getAbsolutePath(), |
57038 | 320 |
launcher.getAbsolutePath()); |
321 |
} |
|
322 |
||
57396
3944e4c2f779
8223586: remove jpackage dead code and other cleanup
herrick
parents:
57287
diff
changeset
|
323 |
File executableProperties = |
3944e4c2f779
8223586: remove jpackage dead code and other cleanup
herrick
parents:
57287
diff
changeset
|
324 |
getConfig_ExecutableProperties(params); |
57038 | 325 |
|
326 |
if (executableProperties.exists()) { |
|
57215
62db1c695d13
8218681: Windows exe's generated by jpackage have wrong info
herrick
parents:
57151
diff
changeset
|
327 |
if (versionSwap(executableProperties.getAbsolutePath(), |
62db1c695d13
8218681: Windows exe's generated by jpackage have wrong info
herrick
parents:
57151
diff
changeset
|
328 |
launcher.getAbsolutePath()) != 0) { |
62db1c695d13
8218681: Windows exe's generated by jpackage have wrong info
herrick
parents:
57151
diff
changeset
|
329 |
throw new RuntimeException(MessageFormat.format( |
62db1c695d13
8218681: Windows exe's generated by jpackage have wrong info
herrick
parents:
57151
diff
changeset
|
330 |
I18N.getString("error.version-swap"), |
62db1c695d13
8218681: Windows exe's generated by jpackage have wrong info
herrick
parents:
57151
diff
changeset
|
331 |
executableProperties.getAbsolutePath())); |
62db1c695d13
8218681: Windows exe's generated by jpackage have wrong info
herrick
parents:
57151
diff
changeset
|
332 |
} |
57038 | 333 |
} |
57151
38d0b67617e3
8217317: Create jpackage native library for windows
herrick
parents:
57119
diff
changeset
|
334 |
} finally { |
57438
4a31db8d42bd
8226599: use code coverage results to remove dead code
herrick
parents:
57407
diff
changeset
|
335 |
executableFile.toFile().setExecutable(true); |
57038 | 336 |
executableFile.toFile().setReadOnly(); |
337 |
} |
|
338 |
} |
|
339 |
||
340 |
Files.copy(iconTarget.toPath(), |
|
57407 | 341 |
binDir.resolve(APP_NAME.fetchFrom(params) + ".ico")); |
57038 | 342 |
} |
343 |
||
344 |
private void copyApplication(Map<String, ? super Object> params) |
|
345 |
throws IOException { |
|
346 |
List<RelativeFileSet> appResourcesList = |
|
347 |
APP_RESOURCES_LIST.fetchFrom(params); |
|
348 |
if (appResourcesList == null) { |
|
349 |
throw new RuntimeException("Null app resources?"); |
|
350 |
} |
|
351 |
for (RelativeFileSet appResources : appResourcesList) { |
|
352 |
if (appResources == null) { |
|
353 |
throw new RuntimeException("Null app resources?"); |
|
354 |
} |
|
355 |
File srcdir = appResources.getBaseDirectory(); |
|
356 |
for (String fname : appResources.getIncludedFiles()) { |
|
357 |
copyEntry(appDir, srcdir, fname); |
|
358 |
} |
|
359 |
} |
|
360 |
} |
|
361 |
||
57151
38d0b67617e3
8217317: Create jpackage native library for windows
herrick
parents:
57119
diff
changeset
|
362 |
private static native int iconSwap(String iconTarget, String launcher); |
38d0b67617e3
8217317: Create jpackage native library for windows
herrick
parents:
57119
diff
changeset
|
363 |
|
57909
c7de06ed4b54
8229979: jpackage cleanup src files, help text, and javadoc
herrick
parents:
57908
diff
changeset
|
364 |
private static native int versionSwap(String executableProperties, |
c7de06ed4b54
8229979: jpackage cleanup src files, help text, and javadoc
herrick
parents:
57908
diff
changeset
|
365 |
String launcher); |
57151
38d0b67617e3
8217317: Create jpackage native library for windows
herrick
parents:
57119
diff
changeset
|
366 |
|
57038 | 367 |
} |