Skip to content

Commit 8a68789

Browse files
author
duke
committed
Automatic merge of jdk:master into master
2 parents 26a2e3f + ed05d57 commit 8a68789

34 files changed

+537
-514
lines changed

src/jdk.incubator.jpackage/linux/classes/jdk/incubator/jpackage/internal/DesktopIntegration.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,8 +435,8 @@ private void addFileAssociationIconFiles(ShellCommands shellCommands)
435435
File.separatorChar, '-') + IOUtils.getSuffix(
436436
assoc.data.iconPath));
437437

438-
IOUtils.copyFile(assoc.data.iconPath.toFile(),
439-
faIconFile.srcPath().toFile());
438+
IOUtils.copyFile(assoc.data.iconPath,
439+
faIconFile.srcPath());
440440

441441
shellCommands.addIcon(mimeType, faIconFile.installPath(),
442442
assoc.iconSize);

src/jdk.incubator.jpackage/linux/classes/jdk/incubator/jpackage/internal/LinuxAppImageBuilder.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
package jdk.incubator.jpackage.internal;
2727

28-
import java.io.File;
2928
import java.io.IOException;
3029
import java.io.InputStream;
3130
import java.nio.file.Files;
@@ -39,20 +38,21 @@
3938

4039
public class LinuxAppImageBuilder extends AbstractAppImageBuilder {
4140

42-
static final BundlerParamInfo<File> ICON_PNG =
41+
static final BundlerParamInfo<Path> ICON_PNG =
4342
new StandardBundlerParam<>(
4443
"icon.png",
45-
File.class,
44+
Path.class,
4645
params -> {
47-
File f = ICON.fetchFrom(params);
48-
if (f != null && !f.getName().toLowerCase().endsWith(".png")) {
46+
Path f = ICON.fetchFrom(params);
47+
if (f != null && f.getFileName() != null && !f.getFileName()
48+
.toString().toLowerCase().endsWith(".png")) {
4949
Log.error(MessageFormat.format(
5050
I18N.getString("message.icon-not-png"), f));
5151
return null;
5252
}
5353
return f;
5454
},
55-
(s, p) -> new File(s));
55+
(s, p) -> Path.of(s));
5656

5757
final static String DEFAULT_ICON = "java32.png";
5858

src/jdk.incubator.jpackage/linux/classes/jdk/incubator/jpackage/internal/LinuxDebBundler.java

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
package jdk.incubator.jpackage.internal;
2727

28-
import java.io.File;
2928
import java.io.IOException;
3029
import java.nio.file.FileVisitResult;
3130
import java.nio.file.Files;
@@ -178,13 +177,13 @@ protected List<ToolValidator> getToolValidators(
178177
}
179178

180179
@Override
181-
protected File buildPackageBundle(
180+
protected Path buildPackageBundle(
182181
Map<String, String> replacementData,
183-
Map<String, ? super Object> params, File outputParentDir) throws
182+
Map<String, ? super Object> params, Path outputParentDir) throws
184183
PackagerException, IOException {
185184

186185
prepareProjectConfig(replacementData, params);
187-
adjustPermissionsRecursive(createMetaPackage(params).sourceRoot().toFile());
186+
adjustPermissionsRecursive(createMetaPackage(params).sourceRoot());
188187
return buildDeb(params, outputParentDir);
189188
}
190189

@@ -309,12 +308,12 @@ protected List<ConfigException> verifyOutputBundle(
309308
*
310309
* This cannot be directly backport to 22u which is built with 1.6
311310
*/
312-
private void setPermissions(File file, String permissions) {
311+
private void setPermissions(Path file, String permissions) {
313312
Set<PosixFilePermission> filePermissions =
314313
PosixFilePermissions.fromString(permissions);
315314
try {
316-
if (file.exists()) {
317-
Files.setPosixFilePermissions(file.toPath(), filePermissions);
315+
if (Files.exists(file)) {
316+
Files.setPosixFilePermissions(file, filePermissions);
318317
}
319318
} catch (IOException ex) {
320319
Log.error(ex.getMessage());
@@ -335,16 +334,16 @@ public static boolean isDebian() {
335334
return false;
336335
}
337336

338-
private void adjustPermissionsRecursive(File dir) throws IOException {
339-
Files.walkFileTree(dir.toPath(), new SimpleFileVisitor<Path>() {
337+
private void adjustPermissionsRecursive(Path dir) throws IOException {
338+
Files.walkFileTree(dir, new SimpleFileVisitor<Path>() {
340339
@Override
341340
public FileVisitResult visitFile(Path file,
342341
BasicFileAttributes attrs)
343342
throws IOException {
344343
if (file.endsWith(".so") || !Files.isExecutable(file)) {
345-
setPermissions(file.toFile(), "rw-r--r--");
344+
setPermissions(file, "rw-r--r--");
346345
} else if (Files.isExecutable(file)) {
347-
setPermissions(file.toFile(), "rwxr-xr-x");
346+
setPermissions(file, "rwxr-xr-x");
348347
}
349348
return FileVisitResult.CONTINUE;
350349
}
@@ -353,7 +352,7 @@ public FileVisitResult visitFile(Path file,
353352
public FileVisitResult postVisitDirectory(Path dir, IOException e)
354353
throws IOException {
355354
if (e == null) {
356-
setPermissions(dir.toFile(), "rwxr-xr-x");
355+
setPermissions(dir, "rwxr-xr-x");
357356
return FileVisitResult.CONTINUE;
358357
} else {
359358
// directory iteration failed
@@ -383,7 +382,7 @@ void create(Map<String, String> data, Map<String, ? super Object> params)
383382
.setSubstitutionData(data)
384383
.saveToFile(dstFilePath);
385384
if (permissions != null) {
386-
setPermissions(dstFilePath.toFile(), permissions);
385+
setPermissions(dstFilePath, permissions);
387386
}
388387
}
389388

@@ -415,7 +414,7 @@ private void prepareProjectConfig(Map<String, String> data,
415414

416415
if (!StandardBundlerParam.isRuntimeInstaller(params)) {
417416
debianFiles.add(new DebianFile(
418-
getConfig_CopyrightFile(params).toPath(),
417+
getConfig_CopyrightFile(params),
419418
"resource.copyright-file"));
420419
}
421420

@@ -440,7 +439,7 @@ protected Map<String, String> createReplacementData(
440439
return data;
441440
}
442441

443-
private File getConfig_CopyrightFile(Map<String, ? super Object> params) {
442+
private Path getConfig_CopyrightFile(Map<String, ? super Object> params) {
444443
final String installDir = LINUX_INSTALL_DIR.fetchFrom(params);
445444
final String packageName = PACKAGE_NAME.fetchFrom(params);
446445

@@ -452,15 +451,15 @@ private File getConfig_CopyrightFile(Map<String, ? super Object> params) {
452451
}
453452

454453
return createMetaPackage(params).sourceRoot().resolve(
455-
Path.of("/").relativize(installPath)).toFile();
454+
Path.of("/").relativize(installPath));
456455
}
457456

458-
private File buildDeb(Map<String, ? super Object> params,
459-
File outdir) throws IOException {
460-
File outFile = new File(outdir,
457+
private Path buildDeb(Map<String, ? super Object> params,
458+
Path outdir) throws IOException {
459+
Path outFile = outdir.resolve(
461460
FULL_PACKAGE_NAME.fetchFrom(params)+".deb");
462461
Log.verbose(MessageFormat.format(I18N.getString(
463-
"message.outputting-to-location"), outFile.getAbsolutePath()));
462+
"message.outputting-to-location"), outFile.toAbsolutePath().toString()));
464463

465464
PlatformPackage thePackage = createMetaPackage(params);
466465

@@ -470,13 +469,13 @@ private File buildDeb(Map<String, ? super Object> params,
470469
cmdline.add("--verbose");
471470
}
472471
cmdline.addAll(List.of("-b", thePackage.sourceRoot().toString(),
473-
outFile.getAbsolutePath()));
472+
outFile.toAbsolutePath().toString()));
474473

475474
// run dpkg
476475
Executor.of(cmdline.toArray(String[]::new)).executeExpectSuccess();
477476

478477
Log.verbose(MessageFormat.format(I18N.getString(
479-
"message.output-to-location"), outFile.getAbsolutePath()));
478+
"message.output-to-location"), outFile.toAbsolutePath().toString()));
480479

481480
return outFile;
482481
}

src/jdk.incubator.jpackage/linux/classes/jdk/incubator/jpackage/internal/LinuxPackageBundler.java

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
*/
2525
package jdk.incubator.jpackage.internal;
2626

27-
import java.io.File;
2827
import java.io.IOException;
2928
import java.nio.file.InvalidPathException;
3029
import java.nio.file.Path;
@@ -104,29 +103,29 @@ final public String getBundleType() {
104103
}
105104

106105
@Override
107-
final public File execute(Map<String, ? super Object> params,
108-
File outputParentDir) throws PackagerException {
109-
IOUtils.writableOutputDir(outputParentDir.toPath());
106+
final public Path execute(Map<String, ? super Object> params,
107+
Path outputParentDir) throws PackagerException {
108+
IOUtils.writableOutputDir(outputParentDir);
110109

111110
PlatformPackage thePackage = createMetaPackage(params);
112111

113-
Function<File, ApplicationLayout> initAppImageLayout = imageRoot -> {
112+
Function<Path, ApplicationLayout> initAppImageLayout = imageRoot -> {
114113
ApplicationLayout layout = appImageLayout(params);
115114
layout.pathGroup().setPath(new Object(),
116115
AppImageFile.getPathInAppImage(Path.of("")));
117-
return layout.resolveAt(imageRoot.toPath());
116+
return layout.resolveAt(imageRoot);
118117
};
119118

120119
try {
121-
File appImage = StandardBundlerParam.getPredefinedAppImage(params);
120+
Path appImage = StandardBundlerParam.getPredefinedAppImage(params);
122121

123122
// we either have an application image or need to build one
124123
if (appImage != null) {
125124
initAppImageLayout.apply(appImage).copy(
126125
thePackage.sourceApplicationLayout());
127126
} else {
128127
final Path srcAppImageRoot = thePackage.sourceRoot().resolve("src");
129-
appImage = appImageBundler.execute(params, srcAppImageRoot.toFile());
128+
appImage = appImageBundler.execute(params, srcAppImageRoot);
130129
ApplicationLayout srcAppLayout = initAppImageLayout.apply(
131130
appImage);
132131
if (appImage.equals(PREDEFINED_RUNTIME_IMAGE.fetchFrom(params))) {
@@ -137,7 +136,7 @@ final public File execute(Map<String, ? super Object> params,
137136
// Application image is a newly created directory tree.
138137
// Move it.
139138
srcAppLayout.move(thePackage.sourceApplicationLayout());
140-
IOUtils.deleteRecursive(srcAppImageRoot.toFile());
139+
IOUtils.deleteRecursive(srcAppImageRoot);
141140
}
142141
}
143142

@@ -153,10 +152,10 @@ final public File execute(Map<String, ? super Object> params,
153152

154153
data.putAll(createReplacementData(params));
155154

156-
File packageBundle = buildPackageBundle(Collections.unmodifiableMap(
155+
Path packageBundle = buildPackageBundle(Collections.unmodifiableMap(
157156
data), params, outputParentDir);
158157

159-
verifyOutputBundle(params, packageBundle.toPath()).stream()
158+
verifyOutputBundle(params, packageBundle).stream()
160159
.filter(Objects::nonNull)
161160
.forEachOrdered(ex -> {
162161
Log.verbose(ex.getLocalizedMessage());
@@ -240,9 +239,9 @@ abstract protected void doValidate(Map<String, ? super Object> params)
240239
abstract protected Map<String, String> createReplacementData(
241240
Map<String, ? super Object> params) throws IOException;
242241

243-
abstract protected File buildPackageBundle(
242+
abstract protected Path buildPackageBundle(
244243
Map<String, String> replacementData,
245-
Map<String, ? super Object> params, File outputParentDir) throws
244+
Map<String, ? super Object> params, Path outputParentDir) throws
246245
PackagerException, IOException;
247246

248247
final protected PlatformPackage createMetaPackage(
@@ -266,7 +265,7 @@ public String name() {
266265

267266
@Override
268267
public Path sourceRoot() {
269-
return IMAGES_ROOT.fetchFrom(params).toPath().toAbsolutePath();
268+
return IMAGES_ROOT.fetchFrom(params).toAbsolutePath();
270269
}
271270

272271
@Override

src/jdk.incubator.jpackage/linux/classes/jdk/incubator/jpackage/internal/LinuxRpmBundler.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
package jdk.incubator.jpackage.internal;
2727

28-
import java.io.File;
2928
import java.io.IOException;
3029
import java.nio.file.Path;
3130
import java.text.MessageFormat;
@@ -147,9 +146,9 @@ protected List<ToolValidator> getToolValidators(
147146
}
148147

149148
@Override
150-
protected File buildPackageBundle(
149+
protected Path buildPackageBundle(
151150
Map<String, String> replacementData,
152-
Map<String, ? super Object> params, File outputParentDir) throws
151+
Map<String, ? super Object> params, Path outputParentDir) throws
153152
PackagerException, IOException {
154153

155154
Path specFile = specFile(params);
@@ -160,7 +159,7 @@ protected File buildPackageBundle(
160159
.setSubstitutionData(replacementData)
161160
.saveToFile(specFile);
162161

163-
return buildRPM(params, outputParentDir.toPath()).toFile();
162+
return buildRPM(params, outputParentDir);
164163
}
165164

166165
@Override
@@ -275,7 +274,7 @@ private String rpmArch() throws IOException {
275274
}
276275

277276
private Path specFile(Map<String, ? super Object> params) {
278-
return TEMP_ROOT.fetchFrom(params).toPath().resolve(Path.of("SPECS",
277+
return TEMP_ROOT.fetchFrom(params).resolve(Path.of("SPECS",
279278
PACKAGE_NAME.fetchFrom(params) + ".spec"));
280279
}
281280

@@ -302,7 +301,7 @@ private Path buildRPM(Map<String, ? super Object> params,
302301
"--define", String.format("%%_rpmdir %s", rpmFile.getParent()),
303302
// do not use other system directories to build as current user
304303
"--define", String.format("%%_topdir %s",
305-
TEMP_ROOT.fetchFrom(params).toPath().toAbsolutePath()),
304+
TEMP_ROOT.fetchFrom(params).toAbsolutePath()),
306305
"--define", String.format("%%_rpmfilename %s", rpmFile.getFileName())
307306
).executeExpectSuccess();
308307

0 commit comments

Comments
 (0)