8344415: Restruct jpackage utility classes
Reviewed-by: almatvee
This commit is contained in:
parent
a28e4d839c
commit
fea5f2b145
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -54,6 +54,8 @@ import static jdk.jpackage.internal.StandardBundlerParam.FILE_ASSOCIATIONS;
|
|||||||
import static jdk.jpackage.internal.StandardBundlerParam.ICON;
|
import static jdk.jpackage.internal.StandardBundlerParam.ICON;
|
||||||
import static jdk.jpackage.internal.StandardBundlerParam.PREDEFINED_APP_IMAGE;
|
import static jdk.jpackage.internal.StandardBundlerParam.PREDEFINED_APP_IMAGE;
|
||||||
import static jdk.jpackage.internal.StandardBundlerParam.SHORTCUT_HINT;
|
import static jdk.jpackage.internal.StandardBundlerParam.SHORTCUT_HINT;
|
||||||
|
import jdk.jpackage.internal.util.PathUtils;
|
||||||
|
import jdk.jpackage.internal.util.XmlUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper to create files for desktop integration.
|
* Helper to create files for desktop integration.
|
||||||
@ -119,7 +121,7 @@ final class DesktopIntegration extends ShellCustomAction {
|
|||||||
if (withDesktopFile) {
|
if (withDesktopFile) {
|
||||||
desktopFile = new DesktopFile(desktopFileName);
|
desktopFile = new DesktopFile(desktopFileName);
|
||||||
iconFile = new DesktopFile(escapedAppFileName
|
iconFile = new DesktopFile(escapedAppFileName
|
||||||
+ IOUtils.getSuffix(Path.of(DEFAULT_ICON)));
|
+ PathUtils.getSuffix(Path.of(DEFAULT_ICON)));
|
||||||
|
|
||||||
if (curIconResource == null) {
|
if (curIconResource == null) {
|
||||||
// Create default icon.
|
// Create default icon.
|
||||||
@ -420,7 +422,7 @@ final class DesktopIntegration extends ShellCustomAction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void createFileAssociationsMimeInfoFile() throws IOException {
|
private void createFileAssociationsMimeInfoFile() throws IOException {
|
||||||
IOUtils.createXml(mimeInfoFile.srcPath(), xml -> {
|
XmlUtils.createXml(mimeInfoFile.srcPath(), xml -> {
|
||||||
xml.writeStartElement("mime-info");
|
xml.writeStartElement("mime-info");
|
||||||
xml.writeDefaultNamespace(
|
xml.writeDefaultNamespace(
|
||||||
"http://www.freedesktop.org/standards/shared-mime-info");
|
"http://www.freedesktop.org/standards/shared-mime-info");
|
||||||
@ -451,7 +453,7 @@ final class DesktopIntegration extends ShellCustomAction {
|
|||||||
|
|
||||||
// Create icon name for mime type from mime type.
|
// Create icon name for mime type from mime type.
|
||||||
DesktopFile faIconFile = new DesktopFile(mimeType.replace(
|
DesktopFile faIconFile = new DesktopFile(mimeType.replace(
|
||||||
File.separatorChar, '-') + IOUtils.getSuffix(
|
File.separatorChar, '-') + PathUtils.getSuffix(
|
||||||
assoc.data.iconPath));
|
assoc.data.iconPath));
|
||||||
|
|
||||||
IOUtils.copyFile(assoc.data.iconPath,
|
IOUtils.copyFile(assoc.data.iconPath,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -35,6 +35,7 @@ import java.util.Map;
|
|||||||
import static jdk.jpackage.internal.StandardBundlerParam.APP_NAME;
|
import static jdk.jpackage.internal.StandardBundlerParam.APP_NAME;
|
||||||
import static jdk.jpackage.internal.StandardBundlerParam.ICON;
|
import static jdk.jpackage.internal.StandardBundlerParam.ICON;
|
||||||
import static jdk.jpackage.internal.StandardBundlerParam.ADD_LAUNCHERS;
|
import static jdk.jpackage.internal.StandardBundlerParam.ADD_LAUNCHERS;
|
||||||
|
import jdk.jpackage.internal.util.PathUtils;
|
||||||
|
|
||||||
public class LinuxAppImageBuilder extends AbstractAppImageBuilder {
|
public class LinuxAppImageBuilder extends AbstractAppImageBuilder {
|
||||||
|
|
||||||
@ -127,7 +128,7 @@ public class LinuxAppImageBuilder extends AbstractAppImageBuilder {
|
|||||||
mainParams);
|
mainParams);
|
||||||
if (iconResource != null) {
|
if (iconResource != null) {
|
||||||
Path iconTarget = appLayout.destktopIntegrationDirectory().resolve(
|
Path iconTarget = appLayout.destktopIntegrationDirectory().resolve(
|
||||||
APP_NAME.fetchFrom(params) + IOUtils.getSuffix(Path.of(
|
APP_NAME.fetchFrom(params) + PathUtils.getSuffix(Path.of(
|
||||||
DEFAULT_ICON)));
|
DEFAULT_ICON)));
|
||||||
iconResource.saveToFile(iconTarget);
|
iconResource.saveToFile(iconTarget);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -44,6 +44,7 @@ import static jdk.jpackage.internal.StandardBundlerParam.VERSION;
|
|||||||
import static jdk.jpackage.internal.StandardBundlerParam.VENDOR;
|
import static jdk.jpackage.internal.StandardBundlerParam.VENDOR;
|
||||||
import static jdk.jpackage.internal.StandardBundlerParam.DESCRIPTION;
|
import static jdk.jpackage.internal.StandardBundlerParam.DESCRIPTION;
|
||||||
import static jdk.jpackage.internal.StandardBundlerParam.INSTALL_DIR;
|
import static jdk.jpackage.internal.StandardBundlerParam.INSTALL_DIR;
|
||||||
|
import jdk.jpackage.internal.util.FileUtils;
|
||||||
|
|
||||||
abstract class LinuxPackageBundler extends AbstractBundler {
|
abstract class LinuxPackageBundler extends AbstractBundler {
|
||||||
|
|
||||||
@ -144,7 +145,7 @@ abstract class LinuxPackageBundler extends AbstractBundler {
|
|||||||
// Application image is a newly created directory tree.
|
// Application image is a newly created directory tree.
|
||||||
// Move it.
|
// Move it.
|
||||||
srcAppLayout.move(thePackage.sourceApplicationLayout());
|
srcAppLayout.move(thePackage.sourceApplicationLayout());
|
||||||
IOUtils.deleteRecursive(srcAppImageRoot);
|
FileUtils.deleteRecursive(srcAppImageRoot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -25,25 +25,20 @@
|
|||||||
|
|
||||||
package jdk.jpackage.internal;
|
package jdk.jpackage.internal;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintStream;
|
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.LinkOption;
|
import java.nio.file.LinkOption;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
import static jdk.jpackage.internal.StandardBundlerParam.APP_NAME;
|
import static jdk.jpackage.internal.StandardBundlerParam.APP_NAME;
|
||||||
import static jdk.jpackage.internal.StandardBundlerParam.INSTALLER_NAME;
|
import static jdk.jpackage.internal.StandardBundlerParam.INSTALLER_NAME;
|
||||||
import static jdk.jpackage.internal.StandardBundlerParam.INSTALL_DIR;
|
import static jdk.jpackage.internal.StandardBundlerParam.INSTALL_DIR;
|
||||||
import static jdk.jpackage.internal.StandardBundlerParam.PREDEFINED_APP_IMAGE;
|
import static jdk.jpackage.internal.StandardBundlerParam.PREDEFINED_APP_IMAGE;
|
||||||
import static jdk.jpackage.internal.StandardBundlerParam.VERSION;
|
import static jdk.jpackage.internal.StandardBundlerParam.VERSION;
|
||||||
import static jdk.jpackage.internal.StandardBundlerParam.SIGN_BUNDLE;
|
import static jdk.jpackage.internal.StandardBundlerParam.SIGN_BUNDLE;
|
||||||
|
import jdk.jpackage.internal.util.FileUtils;
|
||||||
|
|
||||||
public abstract class MacBaseInstallerBundler extends AbstractBundler {
|
public abstract class MacBaseInstallerBundler extends AbstractBundler {
|
||||||
|
|
||||||
@ -187,7 +182,7 @@ public abstract class MacBaseInstallerBundler extends AbstractBundler {
|
|||||||
StandardBundlerParam.getPredefinedAppImage(params);
|
StandardBundlerParam.getPredefinedAppImage(params);
|
||||||
if (predefinedImage != null) {
|
if (predefinedImage != null) {
|
||||||
appDir = appImageRoot.resolve(APP_NAME.fetchFrom(params) + ".app");
|
appDir = appImageRoot.resolve(APP_NAME.fetchFrom(params) + ".app");
|
||||||
IOUtils.copyRecursive(predefinedImage, appDir,
|
FileUtils.copyRecursive(predefinedImage, appDir,
|
||||||
LinkOption.NOFOLLOW_LINKS);
|
LinkOption.NOFOLLOW_LINKS);
|
||||||
|
|
||||||
// Create PackageFile if predefined app image is not signed
|
// Create PackageFile if predefined app image is not signed
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -48,6 +48,7 @@ import static jdk.jpackage.internal.StandardBundlerParam.LICENSE_FILE;
|
|||||||
import static jdk.jpackage.internal.StandardBundlerParam.TEMP_ROOT;
|
import static jdk.jpackage.internal.StandardBundlerParam.TEMP_ROOT;
|
||||||
import static jdk.jpackage.internal.StandardBundlerParam.VERBOSE;
|
import static jdk.jpackage.internal.StandardBundlerParam.VERBOSE;
|
||||||
import static jdk.jpackage.internal.StandardBundlerParam.DMG_CONTENT;
|
import static jdk.jpackage.internal.StandardBundlerParam.DMG_CONTENT;
|
||||||
|
import jdk.jpackage.internal.util.FileUtils;
|
||||||
|
|
||||||
public class MacDmgBundler extends MacBaseInstallerBundler {
|
public class MacDmgBundler extends MacBaseInstallerBundler {
|
||||||
|
|
||||||
@ -294,7 +295,7 @@ public class MacDmgBundler extends MacBaseInstallerBundler {
|
|||||||
MAC_CF_BUNDLE_IDENTIFIER.fetchFrom(params));
|
MAC_CF_BUNDLE_IDENTIFIER.fetchFrom(params));
|
||||||
Path dest = root.resolve("Contents/Home");
|
Path dest = root.resolve("Contents/Home");
|
||||||
|
|
||||||
IOUtils.copyRecursive(source, dest);
|
FileUtils.copyRecursive(source, dest);
|
||||||
|
|
||||||
srcFolder = newRoot;
|
srcFolder = newRoot;
|
||||||
}
|
}
|
||||||
@ -319,7 +320,7 @@ public class MacDmgBundler extends MacBaseInstallerBundler {
|
|||||||
List <String> dmgContent = DMG_CONTENT.fetchFrom(params);
|
List <String> dmgContent = DMG_CONTENT.fetchFrom(params);
|
||||||
for (String content : dmgContent) {
|
for (String content : dmgContent) {
|
||||||
Path path = Path.of(content);
|
Path path = Path.of(content);
|
||||||
IOUtils.copyRecursive(path, srcFolder.resolve(path.getFileName()));
|
FileUtils.copyRecursive(path, srcFolder.resolve(path.getFileName()));
|
||||||
}
|
}
|
||||||
// create temp image
|
// create temp image
|
||||||
ProcessBuilder pb = new ProcessBuilder(
|
ProcessBuilder pb = new ProcessBuilder(
|
||||||
@ -381,9 +382,9 @@ public class MacDmgBundler extends MacBaseInstallerBundler {
|
|||||||
Path destPath = mountedRoot
|
Path destPath = mountedRoot
|
||||||
.resolve(srcFolder.getFileName());
|
.resolve(srcFolder.getFileName());
|
||||||
Files.createDirectory(destPath);
|
Files.createDirectory(destPath);
|
||||||
IOUtils.copyRecursive(srcFolder, destPath);
|
FileUtils.copyRecursive(srcFolder, destPath);
|
||||||
} else {
|
} else {
|
||||||
IOUtils.copyRecursive(srcFolder, mountedRoot);
|
FileUtils.copyRecursive(srcFolder, mountedRoot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -33,6 +33,7 @@ import java.util.function.Predicate;
|
|||||||
import static jdk.jpackage.internal.MacAppImageBuilder.MAC_CF_BUNDLE_IDENTIFIER;
|
import static jdk.jpackage.internal.MacAppImageBuilder.MAC_CF_BUNDLE_IDENTIFIER;
|
||||||
import static jdk.jpackage.internal.OverridableResource.createResource;
|
import static jdk.jpackage.internal.OverridableResource.createResource;
|
||||||
import static jdk.jpackage.internal.StandardBundlerParam.APP_NAME;
|
import static jdk.jpackage.internal.StandardBundlerParam.APP_NAME;
|
||||||
|
import jdk.jpackage.internal.util.PathUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper to install launchers as services using "launchd".
|
* Helper to install launchers as services using "launchd".
|
||||||
@ -95,7 +96,7 @@ public final class MacLaunchersAsServices extends UnixLaunchersAsServices {
|
|||||||
|
|
||||||
// It is recommended to set value of "label" property in launchd
|
// It is recommended to set value of "label" property in launchd
|
||||||
// .plist file equal to the name of this .plist file without the suffix.
|
// .plist file equal to the name of this .plist file without the suffix.
|
||||||
String label = IOUtils.replaceSuffix(plistFilename.getFileName(), "").toString();
|
String label = PathUtils.replaceSuffix(plistFilename.getFileName(), "").toString();
|
||||||
|
|
||||||
getResource()
|
getResource()
|
||||||
.setPublicName(plistFilename)
|
.setPublicName(plistFilename)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -62,6 +62,8 @@ import static jdk.jpackage.internal.StandardBundlerParam.APP_STORE;
|
|||||||
import static jdk.jpackage.internal.MacAppImageBuilder.MAC_CF_BUNDLE_IDENTIFIER;
|
import static jdk.jpackage.internal.MacAppImageBuilder.MAC_CF_BUNDLE_IDENTIFIER;
|
||||||
import static jdk.jpackage.internal.OverridableResource.createResource;
|
import static jdk.jpackage.internal.OverridableResource.createResource;
|
||||||
import static jdk.jpackage.internal.StandardBundlerParam.RESOURCE_DIR;
|
import static jdk.jpackage.internal.StandardBundlerParam.RESOURCE_DIR;
|
||||||
|
import jdk.jpackage.internal.util.FileUtils;
|
||||||
|
import jdk.jpackage.internal.util.XmlUtils;
|
||||||
|
|
||||||
public class MacPkgBundler extends MacBaseInstallerBundler {
|
public class MacPkgBundler extends MacBaseInstallerBundler {
|
||||||
|
|
||||||
@ -267,7 +269,7 @@ public class MacPkgBundler extends MacBaseInstallerBundler {
|
|||||||
Log.verbose(MessageFormat.format(I18N.getString(
|
Log.verbose(MessageFormat.format(I18N.getString(
|
||||||
"message.preparing-distribution-dist"), f.toAbsolutePath().toString()));
|
"message.preparing-distribution-dist"), f.toAbsolutePath().toString()));
|
||||||
|
|
||||||
IOUtils.createXml(f, xml -> {
|
XmlUtils.createXml(f, xml -> {
|
||||||
xml.writeStartElement("installer-gui-script");
|
xml.writeStartElement("installer-gui-script");
|
||||||
xml.writeAttribute("minSpecVersion", "1");
|
xml.writeAttribute("minSpecVersion", "1");
|
||||||
|
|
||||||
@ -452,7 +454,7 @@ public class MacPkgBundler extends MacBaseInstallerBundler {
|
|||||||
source = appLocation;
|
source = appLocation;
|
||||||
dest = newRoot.resolve(appLocation.getFileName());
|
dest = newRoot.resolve(appLocation.getFileName());
|
||||||
}
|
}
|
||||||
IOUtils.copyRecursive(source, dest);
|
FileUtils.copyRecursive(source, dest);
|
||||||
|
|
||||||
return newRoot.toString();
|
return newRoot.toString();
|
||||||
}
|
}
|
||||||
|
@ -32,8 +32,6 @@ import java.nio.file.Path;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
import static jdk.jpackage.internal.OverridableResource.createResource;
|
import static jdk.jpackage.internal.OverridableResource.createResource;
|
||||||
import static jdk.jpackage.internal.StandardBundlerParam.APP_NAME;
|
import static jdk.jpackage.internal.StandardBundlerParam.APP_NAME;
|
||||||
import static jdk.jpackage.internal.StandardBundlerParam.ICON;
|
import static jdk.jpackage.internal.StandardBundlerParam.ICON;
|
||||||
@ -42,6 +40,8 @@ import static jdk.jpackage.internal.StandardBundlerParam.APP_CONTENT;
|
|||||||
import static jdk.jpackage.internal.StandardBundlerParam.OUTPUT_DIR;
|
import static jdk.jpackage.internal.StandardBundlerParam.OUTPUT_DIR;
|
||||||
import static jdk.jpackage.internal.StandardBundlerParam.TEMP_ROOT;
|
import static jdk.jpackage.internal.StandardBundlerParam.TEMP_ROOT;
|
||||||
import jdk.jpackage.internal.resources.ResourceLocator;
|
import jdk.jpackage.internal.resources.ResourceLocator;
|
||||||
|
import jdk.jpackage.internal.util.FileUtils;
|
||||||
|
import jdk.jpackage.internal.util.PathUtils;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* AbstractAppImageBuilder
|
* AbstractAppImageBuilder
|
||||||
@ -92,7 +92,7 @@ public abstract class AbstractAppImageBuilder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IOUtils.copyRecursive(inputPath,
|
FileUtils.copyRecursive(inputPath,
|
||||||
appLayout.appDirectory().toAbsolutePath(), excludes);
|
appLayout.appDirectory().toAbsolutePath(), excludes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ public abstract class AbstractAppImageBuilder {
|
|||||||
|
|
||||||
List<String> items = APP_CONTENT.fetchFrom(params);
|
List<String> items = APP_CONTENT.fetchFrom(params);
|
||||||
for (String item : items) {
|
for (String item : items) {
|
||||||
IOUtils.copyRecursive(Path.of(item),
|
FileUtils.copyRecursive(Path.of(item),
|
||||||
appLayout.contentDirectory().resolve(Path.of(item).getFileName()));
|
appLayout.contentDirectory().resolve(Path.of(item).getFileName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -115,7 +115,7 @@ public abstract class AbstractAppImageBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final String resourcePublicName = APP_NAME.fetchFrom(params)
|
final String resourcePublicName = APP_NAME.fetchFrom(params)
|
||||||
+ IOUtils.getSuffix(Path.of(defaultIconName));
|
+ PathUtils.getSuffix(Path.of(defaultIconName));
|
||||||
|
|
||||||
IconType iconType = getLauncherIconType(params);
|
IconType iconType = getLauncherIconType(params);
|
||||||
if (iconType == IconType.NoIcon) {
|
if (iconType == IconType.NoIcon) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -28,6 +28,7 @@ package jdk.jpackage.internal;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import jdk.jpackage.internal.util.FileUtils;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -55,7 +56,7 @@ abstract class AbstractBundler implements Bundler {
|
|||||||
@Override
|
@Override
|
||||||
public void cleanup(Map<String, ? super Object> params) {
|
public void cleanup(Map<String, ? super Object> params) {
|
||||||
try {
|
try {
|
||||||
IOUtils.deleteRecursive(
|
FileUtils.deleteRecursive(
|
||||||
StandardBundlerParam.TEMP_ROOT.fetchFrom(params));
|
StandardBundlerParam.TEMP_ROOT.fetchFrom(params));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.verbose(e.getMessage());
|
Log.verbose(e.getMessage());
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -59,6 +59,7 @@ import static jdk.jpackage.internal.StandardBundlerParam.SHORTCUT_HINT;
|
|||||||
import static jdk.jpackage.internal.StandardBundlerParam.MENU_HINT;
|
import static jdk.jpackage.internal.StandardBundlerParam.MENU_HINT;
|
||||||
import static jdk.jpackage.internal.StandardBundlerParam.SIGN_BUNDLE;
|
import static jdk.jpackage.internal.StandardBundlerParam.SIGN_BUNDLE;
|
||||||
import static jdk.jpackage.internal.StandardBundlerParam.APP_STORE;
|
import static jdk.jpackage.internal.StandardBundlerParam.APP_STORE;
|
||||||
|
import jdk.jpackage.internal.util.XmlUtils;
|
||||||
|
|
||||||
public final class AppImageFile {
|
public final class AppImageFile {
|
||||||
|
|
||||||
@ -247,7 +248,7 @@ public final class AppImageFile {
|
|||||||
addLauncherInfoSave = appImage.getAddLaunchers();
|
addLauncherInfoSave = appImage.getAddLaunchers();
|
||||||
}
|
}
|
||||||
|
|
||||||
IOUtils.createXml(getPathInAppImage(appImageDir), xml -> {
|
XmlUtils.createXml(getPathInAppImage(appImageDir), xml -> {
|
||||||
xml.writeStartElement("jpackage-state");
|
xml.writeStartElement("jpackage-state");
|
||||||
xml.writeAttribute("version", getVersion());
|
xml.writeAttribute("version", getVersion());
|
||||||
xml.writeAttribute("platform", getPlatform());
|
xml.writeAttribute("platform", getPlatform());
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -25,41 +25,15 @@
|
|||||||
|
|
||||||
package jdk.jpackage.internal;
|
package jdk.jpackage.internal;
|
||||||
|
|
||||||
import jdk.internal.util.OperatingSystem;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.io.Writer;
|
|
||||||
import java.lang.reflect.InvocationHandler;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.lang.reflect.Proxy;
|
|
||||||
import java.nio.file.FileVisitResult;
|
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.CopyOption;
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.SimpleFileVisitor;
|
|
||||||
import java.nio.file.StandardCopyOption;
|
import java.nio.file.StandardCopyOption;
|
||||||
import java.nio.file.attribute.BasicFileAttributes;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
|
||||||
import javax.xml.parsers.DocumentBuilder;
|
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
|
||||||
import javax.xml.stream.XMLOutputFactory;
|
|
||||||
import javax.xml.stream.XMLStreamException;
|
|
||||||
import javax.xml.stream.XMLStreamWriter;
|
|
||||||
import javax.xml.transform.Result;
|
|
||||||
import javax.xml.transform.Source;
|
|
||||||
import javax.xml.transform.TransformerException;
|
|
||||||
import javax.xml.transform.TransformerFactory;
|
|
||||||
import javax.xml.transform.stax.StAXResult;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IOUtils
|
* IOUtils
|
||||||
@ -68,107 +42,6 @@ import javax.xml.transform.stax.StAXResult;
|
|||||||
*/
|
*/
|
||||||
public class IOUtils {
|
public class IOUtils {
|
||||||
|
|
||||||
public static void deleteRecursive(Path directory) throws IOException {
|
|
||||||
final AtomicReference<IOException> exception = new AtomicReference<>();
|
|
||||||
|
|
||||||
if (!Files.exists(directory)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Files.walkFileTree(directory, new SimpleFileVisitor<Path>() {
|
|
||||||
@Override
|
|
||||||
public FileVisitResult visitFile(Path file,
|
|
||||||
BasicFileAttributes attr) throws IOException {
|
|
||||||
if (OperatingSystem.isWindows()) {
|
|
||||||
Files.setAttribute(file, "dos:readonly", false);
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
Files.delete(file);
|
|
||||||
} catch (IOException ex) {
|
|
||||||
exception.compareAndSet(null, ex);
|
|
||||||
}
|
|
||||||
return FileVisitResult.CONTINUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public FileVisitResult preVisitDirectory(Path dir,
|
|
||||||
BasicFileAttributes attr) throws IOException {
|
|
||||||
if (OperatingSystem.isWindows()) {
|
|
||||||
Files.setAttribute(dir, "dos:readonly", false);
|
|
||||||
}
|
|
||||||
return FileVisitResult.CONTINUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public FileVisitResult postVisitDirectory(Path dir, IOException e)
|
|
||||||
throws IOException {
|
|
||||||
try {
|
|
||||||
Files.delete(dir);
|
|
||||||
} catch (IOException ex) {
|
|
||||||
exception.compareAndSet(null, ex);
|
|
||||||
}
|
|
||||||
return FileVisitResult.CONTINUE;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (exception.get() != null) {
|
|
||||||
throw exception.get();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void copyRecursive(Path src, Path dest, CopyOption... options)
|
|
||||||
throws IOException {
|
|
||||||
copyRecursive(src, dest, List.of(), options);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void copyRecursive(Path src, Path dest,
|
|
||||||
final List<Path> excludes, CopyOption... options)
|
|
||||||
throws IOException {
|
|
||||||
|
|
||||||
List<CopyAction> copyActions = new ArrayList<>();
|
|
||||||
|
|
||||||
Files.walkFileTree(src, new SimpleFileVisitor<Path>() {
|
|
||||||
@Override
|
|
||||||
public FileVisitResult preVisitDirectory(final Path dir,
|
|
||||||
final BasicFileAttributes attrs) {
|
|
||||||
if (isPathMatch(dir, excludes)) {
|
|
||||||
return FileVisitResult.SKIP_SUBTREE;
|
|
||||||
} else {
|
|
||||||
copyActions.add(new CopyAction(null, dest.resolve(src.
|
|
||||||
relativize(dir))));
|
|
||||||
return FileVisitResult.CONTINUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public FileVisitResult visitFile(final Path file,
|
|
||||||
final BasicFileAttributes attrs) {
|
|
||||||
if (!isPathMatch(file, excludes)) {
|
|
||||||
copyActions.add(new CopyAction(file, dest.resolve(src.
|
|
||||||
relativize(file))));
|
|
||||||
}
|
|
||||||
return FileVisitResult.CONTINUE;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
for (var copyAction : copyActions) {
|
|
||||||
copyAction.apply(options);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static record CopyAction(Path src, Path dest) {
|
|
||||||
void apply(CopyOption... options) throws IOException {
|
|
||||||
if (src == null) {
|
|
||||||
Files.createDirectories(dest);
|
|
||||||
} else {
|
|
||||||
Files.copy(src, dest, options);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean isPathMatch(Path what, List<Path> paths) {
|
|
||||||
return paths.stream().anyMatch(what::endsWith);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void copyFile(Path sourceFile, Path destFile)
|
public static void copyFile(Path sourceFile, Path destFile)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
Files.createDirectories(getParent(destFile));
|
Files.createDirectories(getParent(destFile));
|
||||||
@ -314,90 +187,6 @@ public class IOUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Path replaceSuffix(Path path, String suffix) {
|
|
||||||
Path parent = path.getParent();
|
|
||||||
String filename = getFileName(path).toString().replaceAll("\\.[^.]*$", "")
|
|
||||||
+ Optional.ofNullable(suffix).orElse("");
|
|
||||||
return parent != null ? parent.resolve(filename) : Path.of(filename);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Path addSuffix(Path path, String suffix) {
|
|
||||||
Path parent = path.getParent();
|
|
||||||
String filename = getFileName(path).toString() + suffix;
|
|
||||||
return parent != null ? parent.resolve(filename) : Path.of(filename);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getSuffix(Path path) {
|
|
||||||
String filename = replaceSuffix(getFileName(path), null).toString();
|
|
||||||
return getFileName(path).toString().substring(filename.length());
|
|
||||||
}
|
|
||||||
|
|
||||||
@FunctionalInterface
|
|
||||||
public static interface XmlConsumer {
|
|
||||||
void accept(XMLStreamWriter xml) throws IOException, XMLStreamException;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void createXml(Path dstFile, XmlConsumer xmlConsumer) throws
|
|
||||||
IOException {
|
|
||||||
XMLOutputFactory xmlFactory = XMLOutputFactory.newInstance();
|
|
||||||
Files.createDirectories(getParent(dstFile));
|
|
||||||
try (Writer w = Files.newBufferedWriter(dstFile)) {
|
|
||||||
// Wrap with pretty print proxy
|
|
||||||
XMLStreamWriter xml = (XMLStreamWriter) Proxy.newProxyInstance(
|
|
||||||
XMLStreamWriter.class.getClassLoader(), new Class<?>[]{
|
|
||||||
XMLStreamWriter.class}, new PrettyPrintHandler(
|
|
||||||
xmlFactory.createXMLStreamWriter(w)));
|
|
||||||
|
|
||||||
xml.writeStartDocument();
|
|
||||||
xmlConsumer.accept(xml);
|
|
||||||
xml.writeEndDocument();
|
|
||||||
xml.flush();
|
|
||||||
xml.close();
|
|
||||||
} catch (XMLStreamException ex) {
|
|
||||||
throw new IOException(ex);
|
|
||||||
} catch (IOException ex) {
|
|
||||||
throw ex;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void mergeXmls(XMLStreamWriter xml, Collection<Source> sources)
|
|
||||||
throws XMLStreamException, IOException {
|
|
||||||
xml = (XMLStreamWriter) Proxy.newProxyInstance(
|
|
||||||
XMLStreamWriter.class.getClassLoader(), new Class<?>[]{
|
|
||||||
XMLStreamWriter.class}, new SkipDocumentHandler(xml));
|
|
||||||
|
|
||||||
try {
|
|
||||||
TransformerFactory tf = TransformerFactory.newInstance();
|
|
||||||
Result result = new StAXResult(xml);
|
|
||||||
for (var src : sources) {
|
|
||||||
tf.newTransformer().transform(src, result);
|
|
||||||
}
|
|
||||||
} catch (TransformerException ex) {
|
|
||||||
// Should never happen
|
|
||||||
throw new RuntimeException(ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static DocumentBuilderFactory initDocumentBuilderFactory() {
|
|
||||||
DocumentBuilderFactory dbf = DocumentBuilderFactory.newDefaultInstance();
|
|
||||||
try {
|
|
||||||
dbf.setFeature(
|
|
||||||
"http://apache.org/xml/features/nonvalidating/load-external-dtd",
|
|
||||||
false);
|
|
||||||
} catch (ParserConfigurationException ex) {
|
|
||||||
throw new IllegalStateException(ex);
|
|
||||||
}
|
|
||||||
return dbf;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static DocumentBuilder initDocumentBuilder() {
|
|
||||||
try {
|
|
||||||
return initDocumentBuilderFactory().newDocumentBuilder();
|
|
||||||
} catch (ParserConfigurationException ex) {
|
|
||||||
throw new IllegalStateException(ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Path getParent(Path p) {
|
public static Path getParent(Path p) {
|
||||||
Path parent = p.getParent();
|
Path parent = p.getParent();
|
||||||
if (parent == null) {
|
if (parent == null) {
|
||||||
@ -430,85 +219,4 @@ public class IOUtils {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class PrettyPrintHandler implements InvocationHandler {
|
|
||||||
|
|
||||||
PrettyPrintHandler(XMLStreamWriter target) {
|
|
||||||
this.target = target;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object invoke(Object proxy, Method method, Object[] args) throws
|
|
||||||
Throwable {
|
|
||||||
switch (method.getName()) {
|
|
||||||
case "writeStartElement":
|
|
||||||
// update state of parent node
|
|
||||||
if (depth > 0) {
|
|
||||||
hasChildElement.put(depth - 1, true);
|
|
||||||
}
|
|
||||||
// reset state of current node
|
|
||||||
hasChildElement.put(depth, false);
|
|
||||||
// indent for current depth
|
|
||||||
target.writeCharacters(EOL);
|
|
||||||
target.writeCharacters(repeat(depth, INDENT));
|
|
||||||
depth++;
|
|
||||||
break;
|
|
||||||
case "writeEndElement":
|
|
||||||
depth--;
|
|
||||||
if (hasChildElement.get(depth) == true) {
|
|
||||||
target.writeCharacters(EOL);
|
|
||||||
target.writeCharacters(repeat(depth, INDENT));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "writeProcessingInstruction":
|
|
||||||
case "writeEmptyElement":
|
|
||||||
// update state of parent node
|
|
||||||
if (depth > 0) {
|
|
||||||
hasChildElement.put(depth - 1, true);
|
|
||||||
}
|
|
||||||
// indent for current depth
|
|
||||||
target.writeCharacters(EOL);
|
|
||||||
target.writeCharacters(repeat(depth, INDENT));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
method.invoke(target, args);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String repeat(int d, String s) {
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
while (d-- > 0) {
|
|
||||||
sb.append(s);
|
|
||||||
}
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private final XMLStreamWriter target;
|
|
||||||
private int depth = 0;
|
|
||||||
private final Map<Integer, Boolean> hasChildElement = new HashMap<>();
|
|
||||||
private static final String INDENT = " ";
|
|
||||||
private static final String EOL = "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class SkipDocumentHandler implements InvocationHandler {
|
|
||||||
|
|
||||||
SkipDocumentHandler(XMLStreamWriter target) {
|
|
||||||
this.target = target;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object invoke(Object proxy, Method method, Object[] args) throws
|
|
||||||
Throwable {
|
|
||||||
switch (method.getName()) {
|
|
||||||
case "writeStartDocument", "writeEndDocument" -> {
|
|
||||||
}
|
|
||||||
default -> method.invoke(target, args);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private final XMLStreamWriter target;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -35,6 +35,7 @@ import java.util.Map;
|
|||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
import jdk.jpackage.internal.util.FileUtils;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -232,7 +233,7 @@ final class PathGroup {
|
|||||||
for (var entry: entries) {
|
for (var entry: entries) {
|
||||||
Path srcFile = entry.getKey();
|
Path srcFile = entry.getKey();
|
||||||
if (Files.isDirectory(srcFile)) {
|
if (Files.isDirectory(srcFile)) {
|
||||||
IOUtils.deleteRecursive(srcFile);
|
FileUtils.deleteRecursive(srcFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,7 @@ import java.util.Set;
|
|||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
import jdk.jpackage.internal.util.FileUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* StandardBundlerParam
|
* StandardBundlerParam
|
||||||
@ -604,7 +605,7 @@ class StandardBundlerParam<T> extends BundlerParamInfo<T> {
|
|||||||
|
|
||||||
// copy whole runtime, need to skip jmods and src.zip
|
// copy whole runtime, need to skip jmods and src.zip
|
||||||
final List<Path> excludes = Arrays.asList(Path.of("jmods"), Path.of("src.zip"));
|
final List<Path> excludes = Arrays.asList(Path.of("jmods"), Path.of("src.zip"));
|
||||||
IOUtils.copyRecursive(topImage, appLayout.runtimeHomeDirectory(),
|
FileUtils.copyRecursive(topImage, appLayout.runtimeHomeDirectory(),
|
||||||
excludes, LinkOption.NOFOLLOW_LINKS);
|
excludes, LinkOption.NOFOLLOW_LINKS);
|
||||||
|
|
||||||
// if module-path given - copy modules to appDir/mods
|
// if module-path given - copy modules to appDir/mods
|
||||||
@ -616,7 +617,7 @@ class StandardBundlerParam<T> extends BundlerParamInfo<T> {
|
|||||||
for (Path mp : modulePath) {
|
for (Path mp : modulePath) {
|
||||||
if (!defaultModulePath.contains(mp)) {
|
if (!defaultModulePath.contains(mp)) {
|
||||||
Files.createDirectories(dest);
|
Files.createDirectories(dest);
|
||||||
IOUtils.copyRecursive(mp, dest);
|
FileUtils.copyRecursive(mp, dest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,155 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation. Oracle designates this
|
||||||
|
* particular file as subject to the "Classpath" exception as provided
|
||||||
|
* by Oracle in the LICENSE file that accompanied this code.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
package jdk.jpackage.internal.util;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.CopyOption;
|
||||||
|
import java.nio.file.FileVisitResult;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.SimpleFileVisitor;
|
||||||
|
import java.nio.file.attribute.BasicFileAttributes;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import jdk.internal.util.OperatingSystem;
|
||||||
|
import jdk.jpackage.internal.util.function.ExceptionBox;
|
||||||
|
import jdk.jpackage.internal.util.function.ThrowingConsumer;
|
||||||
|
|
||||||
|
public final class FileUtils {
|
||||||
|
|
||||||
|
public static void deleteRecursive(Path directory) throws IOException {
|
||||||
|
if (!Files.exists(directory)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var callback = new RecursiveDeleter();
|
||||||
|
|
||||||
|
Files.walkFileTree(directory, callback);
|
||||||
|
|
||||||
|
if (callback.ex != null) {
|
||||||
|
throw callback.ex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void copyRecursive(Path src, Path dest, CopyOption... options)
|
||||||
|
throws IOException {
|
||||||
|
copyRecursive(src, dest, List.of(), options);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void copyRecursive(Path src, Path dest,
|
||||||
|
final List<Path> excludes, CopyOption... options)
|
||||||
|
throws IOException {
|
||||||
|
|
||||||
|
List<CopyAction> copyActions = new ArrayList<>();
|
||||||
|
|
||||||
|
Files.walkFileTree(src, new SimpleFileVisitor<Path>() {
|
||||||
|
@Override
|
||||||
|
public FileVisitResult preVisitDirectory(final Path dir,
|
||||||
|
final BasicFileAttributes attrs) {
|
||||||
|
if (isPathMatch(dir, excludes)) {
|
||||||
|
return FileVisitResult.SKIP_SUBTREE;
|
||||||
|
} else {
|
||||||
|
copyActions.add(new CopyAction(null, dest.resolve(src.
|
||||||
|
relativize(dir))));
|
||||||
|
return FileVisitResult.CONTINUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FileVisitResult visitFile(final Path file,
|
||||||
|
final BasicFileAttributes attrs) {
|
||||||
|
if (!isPathMatch(file, excludes)) {
|
||||||
|
copyActions.add(new CopyAction(file, dest.resolve(src.
|
||||||
|
relativize(file))));
|
||||||
|
}
|
||||||
|
return FileVisitResult.CONTINUE;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
for (var copyAction : copyActions) {
|
||||||
|
copyAction.apply(options);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isPathMatch(Path what, List<Path> paths) {
|
||||||
|
return paths.stream().anyMatch(what::endsWith);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static record CopyAction(Path src, Path dest) {
|
||||||
|
|
||||||
|
void apply(CopyOption... options) throws IOException {
|
||||||
|
if (src == null) {
|
||||||
|
Files.createDirectories(dest);
|
||||||
|
} else {
|
||||||
|
Files.copy(src, dest, options);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class RecursiveDeleter extends SimpleFileVisitor<Path> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FileVisitResult visitFile(Path file,
|
||||||
|
BasicFileAttributes attr) throws IOException {
|
||||||
|
adjustAttributes(file);
|
||||||
|
runActionOnPath(Files::delete, file);
|
||||||
|
return FileVisitResult.CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FileVisitResult preVisitDirectory(Path dir,
|
||||||
|
BasicFileAttributes attr) throws IOException {
|
||||||
|
adjustAttributes(dir);
|
||||||
|
return FileVisitResult.CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FileVisitResult postVisitDirectory(Path dir, IOException e)
|
||||||
|
throws IOException {
|
||||||
|
runActionOnPath(Files::delete, dir);
|
||||||
|
return FileVisitResult.CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void adjustAttributes(Path path) throws IOException {
|
||||||
|
if (OperatingSystem.isWindows()) {
|
||||||
|
Files.setAttribute(path, "dos:readonly", false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void runActionOnPath(ThrowingConsumer<Path> action, Path path) {
|
||||||
|
try {
|
||||||
|
action.accept(path);
|
||||||
|
} catch (IOException ex) {
|
||||||
|
if (this.ex == null) {
|
||||||
|
this.ex = ex;
|
||||||
|
}
|
||||||
|
} catch (Throwable t) {
|
||||||
|
throw ExceptionBox.rethrowUnchecked(t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private IOException ex;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation. Oracle designates this
|
||||||
|
* particular file as subject to the "Classpath" exception as provided
|
||||||
|
* by Oracle in the LICENSE file that accompanied this code.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
package jdk.jpackage.internal.util;
|
||||||
|
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.Optional;
|
||||||
|
import jdk.jpackage.internal.IOUtils;
|
||||||
|
|
||||||
|
public final class PathUtils {
|
||||||
|
|
||||||
|
public static String getSuffix(Path path) {
|
||||||
|
String filename = replaceSuffix(IOUtils.getFileName(path), null).toString();
|
||||||
|
return IOUtils.getFileName(path).toString().substring(filename.length());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Path addSuffix(Path path, String suffix) {
|
||||||
|
Path parent = path.getParent();
|
||||||
|
String filename = IOUtils.getFileName(path).toString() + suffix;
|
||||||
|
return parent != null ? parent.resolve(filename) : Path.of(filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Path replaceSuffix(Path path, String suffix) {
|
||||||
|
Path parent = path.getParent();
|
||||||
|
String filename = IOUtils.getFileName(path).toString().replaceAll("\\.[^.]*$",
|
||||||
|
"") + Optional.ofNullable(suffix).orElse("");
|
||||||
|
return parent != null ? parent.resolve(filename) : Path.of(filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Path resolveNullablePath(Path base, Path path) {
|
||||||
|
return Optional.ofNullable(path).map(base::resolve).orElse(null);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,89 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
package jdk.jpackage.internal.util;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationHandler;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import javax.xml.stream.XMLStreamWriter;
|
||||||
|
|
||||||
|
final class PrettyPrintHandler implements InvocationHandler {
|
||||||
|
|
||||||
|
public PrettyPrintHandler(XMLStreamWriter target) {
|
||||||
|
this.target = target;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
|
||||||
|
switch (method.getName()) {
|
||||||
|
case "writeStartElement":
|
||||||
|
// update state of parent node
|
||||||
|
if (depth > 0) {
|
||||||
|
hasChildElement.put(depth - 1, true);
|
||||||
|
}
|
||||||
|
// reset state of current node
|
||||||
|
hasChildElement.put(depth, false);
|
||||||
|
// indent for current depth
|
||||||
|
target.writeCharacters(EOL);
|
||||||
|
target.writeCharacters(repeat(depth, INDENT));
|
||||||
|
depth++;
|
||||||
|
break;
|
||||||
|
case "writeEndElement":
|
||||||
|
depth--;
|
||||||
|
if (hasChildElement.get(depth) == true) {
|
||||||
|
target.writeCharacters(EOL);
|
||||||
|
target.writeCharacters(repeat(depth, INDENT));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "writeProcessingInstruction":
|
||||||
|
case "writeEmptyElement":
|
||||||
|
// update state of parent node
|
||||||
|
if (depth > 0) {
|
||||||
|
hasChildElement.put(depth - 1, true);
|
||||||
|
}
|
||||||
|
// indent for current depth
|
||||||
|
target.writeCharacters(EOL);
|
||||||
|
target.writeCharacters(repeat(depth, INDENT));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
method.invoke(target, args);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String repeat(int d, String s) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
while (d-- > 0) {
|
||||||
|
sb.append(s);
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private final XMLStreamWriter target;
|
||||||
|
private int depth = 0;
|
||||||
|
private final Map<Integer, Boolean> hasChildElement = new HashMap<>();
|
||||||
|
private static final String INDENT = " ";
|
||||||
|
private static final String EOL = "\n";
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation. Oracle designates this
|
||||||
|
* particular file as subject to the "Classpath" exception as provided
|
||||||
|
* by Oracle in the LICENSE file that accompanied this code.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
package jdk.jpackage.internal.util;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationHandler;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import javax.xml.stream.XMLStreamWriter;
|
||||||
|
|
||||||
|
final class SkipDocumentHandler implements InvocationHandler {
|
||||||
|
|
||||||
|
public SkipDocumentHandler(XMLStreamWriter target) {
|
||||||
|
this.target = target;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
|
||||||
|
switch (method.getName()) {
|
||||||
|
case "writeStartDocument", "writeEndDocument" -> {
|
||||||
|
}
|
||||||
|
default -> method.invoke(target, args);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private final XMLStreamWriter target;
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
package jdk.jpackage.internal.util;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import javax.xml.stream.XMLStreamException;
|
||||||
|
import javax.xml.stream.XMLStreamWriter;
|
||||||
|
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface XmlConsumer {
|
||||||
|
|
||||||
|
void accept(XMLStreamWriter xml) throws IOException, XMLStreamException;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,103 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
package jdk.jpackage.internal.util;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.Writer;
|
||||||
|
import java.lang.reflect.Proxy;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.Collection;
|
||||||
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
import javax.xml.stream.XMLOutputFactory;
|
||||||
|
import javax.xml.stream.XMLStreamException;
|
||||||
|
import javax.xml.stream.XMLStreamWriter;
|
||||||
|
import javax.xml.transform.Result;
|
||||||
|
import javax.xml.transform.Source;
|
||||||
|
import javax.xml.transform.TransformerException;
|
||||||
|
import javax.xml.transform.TransformerFactory;
|
||||||
|
import javax.xml.transform.stax.StAXResult;
|
||||||
|
import jdk.jpackage.internal.IOUtils;
|
||||||
|
|
||||||
|
|
||||||
|
public final class XmlUtils {
|
||||||
|
|
||||||
|
public static void createXml(Path dstFile, XmlConsumer xmlConsumer) throws
|
||||||
|
IOException {
|
||||||
|
XMLOutputFactory xmlFactory = XMLOutputFactory.newInstance();
|
||||||
|
Files.createDirectories(IOUtils.getParent(dstFile));
|
||||||
|
try (Writer w = Files.newBufferedWriter(dstFile)) {
|
||||||
|
// Wrap with pretty print proxy
|
||||||
|
XMLStreamWriter xml = (XMLStreamWriter) Proxy.newProxyInstance(XMLStreamWriter.class.getClassLoader(),
|
||||||
|
new Class<?>[]{XMLStreamWriter.class},
|
||||||
|
new PrettyPrintHandler(xmlFactory.createXMLStreamWriter(w)));
|
||||||
|
xml.writeStartDocument();
|
||||||
|
xmlConsumer.accept(xml);
|
||||||
|
xml.writeEndDocument();
|
||||||
|
xml.flush();
|
||||||
|
xml.close();
|
||||||
|
} catch (XMLStreamException ex) {
|
||||||
|
throw new IOException(ex);
|
||||||
|
} catch (IOException ex) {
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void mergeXmls(XMLStreamWriter xml, Collection<Source> sources)
|
||||||
|
throws XMLStreamException, IOException {
|
||||||
|
xml = (XMLStreamWriter) Proxy.newProxyInstance(XMLStreamWriter.class.getClassLoader(),
|
||||||
|
new Class<?>[]{XMLStreamWriter.class},
|
||||||
|
new SkipDocumentHandler(xml));
|
||||||
|
try {
|
||||||
|
TransformerFactory tf = TransformerFactory.newInstance();
|
||||||
|
Result result = new StAXResult(xml);
|
||||||
|
for (Source src : sources) {
|
||||||
|
tf.newTransformer().transform(src, result);
|
||||||
|
}
|
||||||
|
} catch (TransformerException ex) {
|
||||||
|
// Should never happen
|
||||||
|
throw new RuntimeException(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DocumentBuilder initDocumentBuilder() {
|
||||||
|
try {
|
||||||
|
return initDocumentBuilderFactory().newDocumentBuilder();
|
||||||
|
} catch (ParserConfigurationException ex) {
|
||||||
|
throw new IllegalStateException(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DocumentBuilderFactory initDocumentBuilderFactory() {
|
||||||
|
DocumentBuilderFactory dbf = DocumentBuilderFactory.newDefaultInstance();
|
||||||
|
try {
|
||||||
|
dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd",
|
||||||
|
false);
|
||||||
|
} catch (ParserConfigurationException ex) {
|
||||||
|
throw new IllegalStateException(ex);
|
||||||
|
}
|
||||||
|
return dbf;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
package jdk.jpackage.internal.util.function;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
|
||||||
|
public class ExceptionBox extends RuntimeException {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public static RuntimeException rethrowUnchecked(Throwable throwable) {
|
||||||
|
if (throwable instanceof RuntimeException err) {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (throwable instanceof Error err) {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (throwable instanceof InvocationTargetException err) {
|
||||||
|
throw rethrowUnchecked(err.getCause());
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new ExceptionBox(throwable);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ExceptionBox(Throwable throwable) {
|
||||||
|
super(throwable);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
package jdk.jpackage.internal.util.function;
|
||||||
|
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
|
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface ThrowingBiConsumer<T, U> {
|
||||||
|
|
||||||
|
void accept(T t, U u) throws Throwable;
|
||||||
|
|
||||||
|
public static <T, U> BiConsumer<T, U> toBiConsumer(
|
||||||
|
ThrowingBiConsumer<T, U> v) {
|
||||||
|
return (t, u) -> {
|
||||||
|
try {
|
||||||
|
v.accept(t, u);
|
||||||
|
} catch (Throwable ex) {
|
||||||
|
throw ExceptionBox.rethrowUnchecked(ex);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
package jdk.jpackage.internal.util.function;
|
||||||
|
|
||||||
|
import java.util.function.BiFunction;
|
||||||
|
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface ThrowingBiFunction<T, U, R> {
|
||||||
|
|
||||||
|
R apply(T t, U u) throws Throwable;
|
||||||
|
|
||||||
|
public static <T, U, R> BiFunction<T, U, R> toBiFunction(
|
||||||
|
ThrowingBiFunction<T, U, R> v) {
|
||||||
|
return (t, u) -> {
|
||||||
|
try {
|
||||||
|
return v.apply(t, u);
|
||||||
|
} catch (Throwable ex) {
|
||||||
|
throw ExceptionBox.rethrowUnchecked(ex);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
package jdk.jpackage.internal.util.function;
|
||||||
|
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface ThrowingConsumer<T> {
|
||||||
|
|
||||||
|
void accept(T t) throws Throwable;
|
||||||
|
|
||||||
|
public static <T> Consumer<T> toConsumer(ThrowingConsumer<T> v) {
|
||||||
|
return o -> {
|
||||||
|
try {
|
||||||
|
v.accept(o);
|
||||||
|
} catch (Throwable ex) {
|
||||||
|
throw ExceptionBox.rethrowUnchecked(ex);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
package jdk.jpackage.internal.util.function;
|
||||||
|
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface ThrowingFunction<T, R> {
|
||||||
|
|
||||||
|
R apply(T t) throws Throwable;
|
||||||
|
|
||||||
|
public static <T, R> Function<T, R> toFunction(ThrowingFunction<T, R> v) {
|
||||||
|
return t -> {
|
||||||
|
try {
|
||||||
|
return v.apply(t);
|
||||||
|
} catch (Throwable ex) {
|
||||||
|
throw ExceptionBox.rethrowUnchecked(ex);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
package jdk.jpackage.internal.util.function;
|
||||||
|
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface ThrowingRunnable {
|
||||||
|
|
||||||
|
void run() throws Throwable;
|
||||||
|
|
||||||
|
public static Runnable toRunnable(ThrowingRunnable v) {
|
||||||
|
return () -> {
|
||||||
|
try {
|
||||||
|
v.run();
|
||||||
|
} catch (Throwable ex) {
|
||||||
|
throw ExceptionBox.rethrowUnchecked(ex);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
package jdk.jpackage.internal.util.function;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface ThrowingSupplier<T> {
|
||||||
|
|
||||||
|
T get() throws Throwable;
|
||||||
|
|
||||||
|
public static <T> Supplier<T> toSupplier(ThrowingSupplier<T> v) {
|
||||||
|
return () -> {
|
||||||
|
try {
|
||||||
|
return v.get();
|
||||||
|
} catch (Throwable ex) {
|
||||||
|
throw ExceptionBox.rethrowUnchecked(ex);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
package jdk.jpackage.internal.util.function;
|
||||||
|
|
||||||
|
import java.util.function.UnaryOperator;
|
||||||
|
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface ThrowingUnaryOperator<T> {
|
||||||
|
|
||||||
|
T apply(T t) throws Throwable;
|
||||||
|
|
||||||
|
public static <T> UnaryOperator<T> toUnaryOperator(
|
||||||
|
ThrowingUnaryOperator<T> v) {
|
||||||
|
return t -> {
|
||||||
|
try {
|
||||||
|
return v.apply(t);
|
||||||
|
} catch (Throwable ex) {
|
||||||
|
throw ExceptionBox.rethrowUnchecked(ex);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -30,6 +30,7 @@ import java.nio.file.Files;
|
|||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import jdk.jpackage.internal.util.PathUtils;
|
||||||
|
|
||||||
@SuppressWarnings("restricted")
|
@SuppressWarnings("restricted")
|
||||||
public class WinExeBundler extends AbstractBundler {
|
public class WinExeBundler extends AbstractBundler {
|
||||||
@ -127,7 +128,7 @@ public class WinExeBundler extends AbstractBundler {
|
|||||||
outdir.toAbsolutePath().toString()));
|
outdir.toAbsolutePath().toString()));
|
||||||
|
|
||||||
// Copy template msi wrapper next to msi file
|
// Copy template msi wrapper next to msi file
|
||||||
final Path exePath = IOUtils.replaceSuffix(msi, ".exe");
|
final Path exePath = PathUtils.replaceSuffix(msi, ".exe");
|
||||||
try (InputStream is = OverridableResource.readDefault(EXE_WRAPPER_NAME)) {
|
try (InputStream is = OverridableResource.readDefault(EXE_WRAPPER_NAME)) {
|
||||||
Files.copy(is, exePath);
|
Files.copy(is, exePath);
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,6 @@ import java.nio.file.Path;
|
|||||||
import java.nio.file.PathMatcher;
|
import java.nio.file.PathMatcher;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
@ -67,7 +66,7 @@ import static jdk.jpackage.internal.StandardBundlerParam.RESOURCE_DIR;
|
|||||||
import static jdk.jpackage.internal.StandardBundlerParam.TEMP_ROOT;
|
import static jdk.jpackage.internal.StandardBundlerParam.TEMP_ROOT;
|
||||||
import static jdk.jpackage.internal.StandardBundlerParam.VENDOR;
|
import static jdk.jpackage.internal.StandardBundlerParam.VENDOR;
|
||||||
import static jdk.jpackage.internal.StandardBundlerParam.VERSION;
|
import static jdk.jpackage.internal.StandardBundlerParam.VERSION;
|
||||||
import jdk.jpackage.internal.WixToolset.WixToolsetType;
|
import jdk.jpackage.internal.util.FileUtils;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.NodeList;
|
import org.w3c.dom.NodeList;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
@ -367,7 +366,7 @@ public class WinMsiBundler extends AbstractBundler {
|
|||||||
if (appImage != null) {
|
if (appImage != null) {
|
||||||
appDir = MSI_IMAGE_DIR.fetchFrom(params).resolve(appName);
|
appDir = MSI_IMAGE_DIR.fetchFrom(params).resolve(appName);
|
||||||
// copy everything from appImage dir into appDir/name
|
// copy everything from appImage dir into appDir/name
|
||||||
IOUtils.copyRecursive(appImage, appDir);
|
FileUtils.copyRecursive(appImage, appDir);
|
||||||
} else {
|
} else {
|
||||||
appDir = appImageBundler.execute(params, MSI_IMAGE_DIR.fetchFrom(
|
appDir = appImageBundler.execute(params, MSI_IMAGE_DIR.fetchFrom(
|
||||||
params));
|
params));
|
||||||
|
@ -42,7 +42,6 @@ import java.util.Objects;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -56,7 +55,7 @@ import javax.xml.xpath.XPathConstants;
|
|||||||
import javax.xml.xpath.XPathExpressionException;
|
import javax.xml.xpath.XPathExpressionException;
|
||||||
import javax.xml.xpath.XPathFactory;
|
import javax.xml.xpath.XPathFactory;
|
||||||
import jdk.jpackage.internal.AppImageFile.LauncherInfo;
|
import jdk.jpackage.internal.AppImageFile.LauncherInfo;
|
||||||
import jdk.jpackage.internal.IOUtils.XmlConsumer;
|
import jdk.jpackage.internal.util.XmlConsumer;
|
||||||
import static jdk.jpackage.internal.StandardBundlerParam.APP_NAME;
|
import static jdk.jpackage.internal.StandardBundlerParam.APP_NAME;
|
||||||
import static jdk.jpackage.internal.StandardBundlerParam.INSTALL_DIR;
|
import static jdk.jpackage.internal.StandardBundlerParam.INSTALL_DIR;
|
||||||
import static jdk.jpackage.internal.StandardBundlerParam.VENDOR;
|
import static jdk.jpackage.internal.StandardBundlerParam.VENDOR;
|
||||||
@ -65,6 +64,8 @@ import static jdk.jpackage.internal.WinMsiBundler.MSI_SYSTEM_WIDE;
|
|||||||
import static jdk.jpackage.internal.WinMsiBundler.SERVICE_INSTALLER;
|
import static jdk.jpackage.internal.WinMsiBundler.SERVICE_INSTALLER;
|
||||||
import static jdk.jpackage.internal.WinMsiBundler.WIN_APP_IMAGE;
|
import static jdk.jpackage.internal.WinMsiBundler.WIN_APP_IMAGE;
|
||||||
import jdk.jpackage.internal.WixToolset.WixToolsetType;
|
import jdk.jpackage.internal.WixToolset.WixToolsetType;
|
||||||
|
import jdk.jpackage.internal.util.PathUtils;
|
||||||
|
import jdk.jpackage.internal.util.XmlUtils;
|
||||||
import org.w3c.dom.NodeList;
|
import org.w3c.dom.NodeList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -202,7 +203,7 @@ class WixAppImageFragmentBuilder extends WixFragmentBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static Path addExeSuffixToPath(Path path) {
|
private static Path addExeSuffixToPath(Path path) {
|
||||||
return IOUtils.addSuffix(path, ".exe");
|
return PathUtils.addSuffix(path, ".exe");
|
||||||
}
|
}
|
||||||
|
|
||||||
private Path getInstalledFaIcoPath(FileAssociation fa) {
|
private Path getInstalledFaIcoPath(FileAssociation fa) {
|
||||||
@ -524,7 +525,7 @@ class WixAppImageFragmentBuilder extends WixFragmentBuilder {
|
|||||||
throw throwInvalidPathException(launcherPath);
|
throw throwInvalidPathException(launcherPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
String launcherBasename = IOUtils.replaceSuffix(
|
String launcherBasename = PathUtils.replaceSuffix(
|
||||||
IOUtils.getFileName(launcherPath), "").toString();
|
IOUtils.getFileName(launcherPath), "").toString();
|
||||||
|
|
||||||
Path shortcutPath = folder.getPath(this).resolve(launcherBasename);
|
Path shortcutPath = folder.getPath(this).resolve(launcherBasename);
|
||||||
@ -774,7 +775,7 @@ class WixAppImageFragmentBuilder extends WixFragmentBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var buffer = new DOMResult(IOUtils.initDocumentBuilder().newDocument());
|
var buffer = new DOMResult(XmlUtils.initDocumentBuilder().newDocument());
|
||||||
var bufferWriter = XMLOutputFactory.newInstance().createXMLStreamWriter(
|
var bufferWriter = XMLOutputFactory.newInstance().createXMLStreamWriter(
|
||||||
buffer);
|
buffer);
|
||||||
|
|
||||||
|
@ -37,13 +37,14 @@ import java.util.Optional;
|
|||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import javax.xml.stream.XMLStreamWriter;
|
import javax.xml.stream.XMLStreamWriter;
|
||||||
import jdk.jpackage.internal.IOUtils.XmlConsumer;
|
import jdk.jpackage.internal.util.XmlConsumer;
|
||||||
import jdk.jpackage.internal.OverridableResource.Source;
|
import jdk.jpackage.internal.OverridableResource.Source;
|
||||||
import static jdk.jpackage.internal.StandardBundlerParam.CONFIG_ROOT;
|
import static jdk.jpackage.internal.StandardBundlerParam.CONFIG_ROOT;
|
||||||
import jdk.internal.util.Architecture;
|
import jdk.internal.util.Architecture;
|
||||||
import static jdk.jpackage.internal.OverridableResource.createResource;
|
import static jdk.jpackage.internal.OverridableResource.createResource;
|
||||||
import jdk.jpackage.internal.WixSourceConverter.ResourceGroup;
|
import jdk.jpackage.internal.WixSourceConverter.ResourceGroup;
|
||||||
import jdk.jpackage.internal.WixToolset.WixToolsetType;
|
import jdk.jpackage.internal.WixToolset.WixToolsetType;
|
||||||
|
import jdk.jpackage.internal.util.XmlUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates WiX fragment.
|
* Creates WiX fragment.
|
||||||
@ -159,7 +160,7 @@ abstract class WixFragmentBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void createWixSource(Path file, XmlConsumer xmlConsumer) throws IOException {
|
private void createWixSource(Path file, XmlConsumer xmlConsumer) throws IOException {
|
||||||
IOUtils.createXml(file, xml -> {
|
XmlUtils.createXml(file, xml -> {
|
||||||
xml.writeStartElement("Wix");
|
xml.writeStartElement("Wix");
|
||||||
for (var ns : getWixNamespaces().entrySet()) {
|
for (var ns : getWixNamespaces().entrySet()) {
|
||||||
switch (ns.getKey()) {
|
switch (ns.getKey()) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -39,6 +39,7 @@ import javax.xml.xpath.XPathConstants;
|
|||||||
import javax.xml.xpath.XPathExpressionException;
|
import javax.xml.xpath.XPathExpressionException;
|
||||||
import javax.xml.xpath.XPathFactory;
|
import javax.xml.xpath.XPathFactory;
|
||||||
import static jdk.jpackage.internal.OverridableResource.createResource;
|
import static jdk.jpackage.internal.OverridableResource.createResource;
|
||||||
|
import jdk.jpackage.internal.util.XmlUtils;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
import org.w3c.dom.NodeList;
|
import org.w3c.dom.NodeList;
|
||||||
@ -95,7 +96,7 @@ class WixLauncherAsService extends LauncherAsService {
|
|||||||
resource.saveToStream(buffer);
|
resource.saveToStream(buffer);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Document doc = IOUtils.initDocumentBuilder().parse(
|
Document doc = XmlUtils.initDocumentBuilder().parse(
|
||||||
new ByteArrayInputStream(buffer.toByteArray()));
|
new ByteArrayInputStream(buffer.toByteArray()));
|
||||||
|
|
||||||
XPath xPath = XPathFactory.newInstance().newXPath();
|
XPath xPath = XPathFactory.newInstance().newXPath();
|
||||||
@ -109,7 +110,7 @@ class WixLauncherAsService extends LauncherAsService {
|
|||||||
sources.add(new DOMSource(n));
|
sources.add(new DOMSource(n));
|
||||||
}
|
}
|
||||||
|
|
||||||
IOUtils.mergeXmls(xml, sources);
|
XmlUtils.mergeXmls(xml, sources);
|
||||||
|
|
||||||
} catch (SAXException ex) {
|
} catch (SAXException ex) {
|
||||||
throw new IOException(ex);
|
throw new IOException(ex);
|
||||||
|
@ -36,6 +36,7 @@ import java.util.Optional;
|
|||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
import jdk.jpackage.internal.util.PathUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* WiX pipeline. Compiles and links WiX sources.
|
* WiX pipeline. Compiles and links WiX sources.
|
||||||
@ -180,7 +181,7 @@ public class WixPipeline {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Path compileWix3(WixSource wixSource) throws IOException {
|
private Path compileWix3(WixSource wixSource) throws IOException {
|
||||||
Path wixObj = wixObjDir.toAbsolutePath().resolve(IOUtils.replaceSuffix(
|
Path wixObj = wixObjDir.toAbsolutePath().resolve(PathUtils.replaceSuffix(
|
||||||
IOUtils.getFileName(wixSource.source), ".wixobj"));
|
IOUtils.getFileName(wixSource.source), ".wixobj"));
|
||||||
|
|
||||||
List<String> cmdline = new ArrayList<>(List.of(
|
List<String> cmdline = new ArrayList<>(List.of(
|
||||||
|
@ -52,6 +52,7 @@ import javax.xml.transform.dom.DOMSource;
|
|||||||
import javax.xml.transform.stax.StAXResult;
|
import javax.xml.transform.stax.StAXResult;
|
||||||
import javax.xml.transform.stream.StreamSource;
|
import javax.xml.transform.stream.StreamSource;
|
||||||
import jdk.jpackage.internal.WixToolset.WixToolsetType;
|
import jdk.jpackage.internal.WixToolset.WixToolsetType;
|
||||||
|
import jdk.jpackage.internal.util.XmlUtils;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
@ -98,7 +99,7 @@ final class WixSourceConverter {
|
|||||||
|
|
||||||
Document inputXmlDom;
|
Document inputXmlDom;
|
||||||
try {
|
try {
|
||||||
inputXmlDom = IOUtils.initDocumentBuilder().parse(new ByteArrayInputStream(buf));
|
inputXmlDom = XmlUtils.initDocumentBuilder().parse(new ByteArrayInputStream(buf));
|
||||||
} catch (SAXException ex) {
|
} catch (SAXException ex) {
|
||||||
// Malformed XML, don't run converter, save as is.
|
// Malformed XML, don't run converter, save as is.
|
||||||
resource.saveToFile(resourceSaveAsFile);
|
resource.saveToFile(resourceSaveAsFile);
|
||||||
|
@ -41,6 +41,7 @@ import java.util.function.Function;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
import jdk.jpackage.internal.WixToolset.WixToolsetType;
|
import jdk.jpackage.internal.WixToolset.WixToolsetType;
|
||||||
|
import jdk.jpackage.internal.util.PathUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* WiX tool.
|
* WiX tool.
|
||||||
@ -51,7 +52,7 @@ public enum WixTool {
|
|||||||
Wix4("wix", DottedVersion.lazy("4.0.4"));
|
Wix4("wix", DottedVersion.lazy("4.0.4"));
|
||||||
|
|
||||||
WixTool(String commandName, DottedVersion minimalVersion) {
|
WixTool(String commandName, DottedVersion minimalVersion) {
|
||||||
this.toolFileName = IOUtils.addSuffix(Path.of(commandName), ".exe");
|
this.toolFileName = PathUtils.addSuffix(Path.of(commandName), ".exe");
|
||||||
this.minimalVersion = minimalVersion;
|
this.minimalVersion = minimalVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -39,7 +39,7 @@ import java.util.function.Supplier;
|
|||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
import javax.xml.stream.XMLStreamException;
|
import javax.xml.stream.XMLStreamException;
|
||||||
import javax.xml.stream.XMLStreamWriter;
|
import javax.xml.stream.XMLStreamWriter;
|
||||||
import jdk.jpackage.internal.IOUtils.XmlConsumer;
|
import jdk.jpackage.internal.util.XmlConsumer;
|
||||||
import static jdk.jpackage.internal.OverridableResource.createResource;
|
import static jdk.jpackage.internal.OverridableResource.createResource;
|
||||||
import static jdk.jpackage.internal.StandardBundlerParam.LICENSE_FILE;
|
import static jdk.jpackage.internal.StandardBundlerParam.LICENSE_FILE;
|
||||||
import jdk.jpackage.internal.WixAppImageFragmentBuilder.ShortcutsFolder;
|
import jdk.jpackage.internal.WixAppImageFragmentBuilder.ShortcutsFolder;
|
||||||
|
@ -12,4 +12,6 @@ maxOutputSize=2000000
|
|||||||
exclusiveAccess.dirs=share windows
|
exclusiveAccess.dirs=share windows
|
||||||
|
|
||||||
modules=jdk.jpackage/jdk.jpackage.internal:+open \
|
modules=jdk.jpackage/jdk.jpackage.internal:+open \
|
||||||
|
jdk.jpackage/jdk.jpackage.internal.util \
|
||||||
|
jdk.jpackage/jdk.jpackage.internal.util.function \
|
||||||
java.base/jdk.internal.util
|
java.base/jdk.internal.util
|
||||||
|
@ -40,7 +40,7 @@ import jdk.jpackage.test.Annotations.Parameter;
|
|||||||
import jdk.jpackage.test.Annotations.ParameterSupplier;
|
import jdk.jpackage.test.Annotations.ParameterSupplier;
|
||||||
import jdk.jpackage.test.Annotations.Parameters;
|
import jdk.jpackage.test.Annotations.Parameters;
|
||||||
import jdk.jpackage.test.Annotations.Test;
|
import jdk.jpackage.test.Annotations.Test;
|
||||||
import static jdk.jpackage.test.Functional.ThrowingSupplier.toSupplier;
|
import static jdk.jpackage.internal.util.function.ThrowingSupplier.toSupplier;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
|
@ -37,9 +37,9 @@ import java.util.Objects;
|
|||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
import jdk.jpackage.test.Annotations.Parameters;
|
import jdk.jpackage.test.Annotations.Parameters;
|
||||||
import jdk.jpackage.test.Annotations.Test;
|
import jdk.jpackage.test.Annotations.Test;
|
||||||
import jdk.jpackage.test.Functional.ThrowingRunnable;
|
import jdk.jpackage.internal.util.function.ThrowingRunnable;
|
||||||
import static jdk.jpackage.test.Functional.ThrowingRunnable.toRunnable;
|
import static jdk.jpackage.internal.util.function.ThrowingRunnable.toRunnable;
|
||||||
import static jdk.jpackage.test.Functional.ThrowingSupplier.toSupplier;
|
import static jdk.jpackage.internal.util.function.ThrowingSupplier.toSupplier;
|
||||||
|
|
||||||
public class TKitTest {
|
public class TKitTest {
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -37,8 +37,9 @@ import java.util.regex.Matcher;
|
|||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
import jdk.jpackage.test.Functional.ThrowingBiConsumer;
|
import static jdk.jpackage.internal.util.function.ExceptionBox.rethrowUnchecked;
|
||||||
import static jdk.jpackage.test.Functional.ThrowingFunction.toFunction;
|
import jdk.jpackage.internal.util.function.ThrowingBiConsumer;
|
||||||
|
import static jdk.jpackage.internal.util.function.ThrowingFunction.toFunction;
|
||||||
|
|
||||||
public class AdditionalLauncher {
|
public class AdditionalLauncher {
|
||||||
|
|
||||||
@ -48,12 +49,12 @@ public class AdditionalLauncher {
|
|||||||
setPersistenceHandler(null);
|
setPersistenceHandler(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
final public AdditionalLauncher setDefaultArguments(String... v) {
|
public final AdditionalLauncher setDefaultArguments(String... v) {
|
||||||
defaultArguments = new ArrayList<>(List.of(v));
|
defaultArguments = new ArrayList<>(List.of(v));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
final public AdditionalLauncher addDefaultArguments(String... v) {
|
public final AdditionalLauncher addDefaultArguments(String... v) {
|
||||||
if (defaultArguments == null) {
|
if (defaultArguments == null) {
|
||||||
return setDefaultArguments(v);
|
return setDefaultArguments(v);
|
||||||
}
|
}
|
||||||
@ -62,12 +63,12 @@ public class AdditionalLauncher {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
final public AdditionalLauncher setJavaOptions(String... v) {
|
public final AdditionalLauncher setJavaOptions(String... v) {
|
||||||
javaOptions = new ArrayList<>(List.of(v));
|
javaOptions = new ArrayList<>(List.of(v));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
final public AdditionalLauncher addJavaOptions(String... v) {
|
public final AdditionalLauncher addJavaOptions(String... v) {
|
||||||
if (javaOptions == null) {
|
if (javaOptions == null) {
|
||||||
return setJavaOptions(v);
|
return setJavaOptions(v);
|
||||||
}
|
}
|
||||||
@ -76,27 +77,27 @@ public class AdditionalLauncher {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
final public AdditionalLauncher setVerifyUninstalled(boolean value) {
|
public final AdditionalLauncher setVerifyUninstalled(boolean value) {
|
||||||
verifyUninstalled = value;
|
verifyUninstalled = value;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
final public AdditionalLauncher setLauncherAsService() {
|
public final AdditionalLauncher setLauncherAsService() {
|
||||||
return addRawProperties(LAUNCHER_AS_SERVICE);
|
return addRawProperties(LAUNCHER_AS_SERVICE);
|
||||||
}
|
}
|
||||||
|
|
||||||
final public AdditionalLauncher addRawProperties(
|
public final AdditionalLauncher addRawProperties(
|
||||||
Map.Entry<String, String>... v) {
|
Map.Entry<String, String>... v) {
|
||||||
return addRawProperties(List.of(v));
|
return addRawProperties(List.of(v));
|
||||||
}
|
}
|
||||||
|
|
||||||
final public AdditionalLauncher addRawProperties(
|
public final AdditionalLauncher addRawProperties(
|
||||||
Collection<Map.Entry<String, String>> v) {
|
Collection<Map.Entry<String, String>> v) {
|
||||||
rawProperties.addAll(v);
|
rawProperties.addAll(v);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
final public String getRawPropertyValue(
|
public final String getRawPropertyValue(
|
||||||
String key, Supplier<String> getDefault) {
|
String key, Supplier<String> getDefault) {
|
||||||
return rawProperties.stream()
|
return rawProperties.stream()
|
||||||
.filter(item -> item.getKey().equals(key))
|
.filter(item -> item.getKey().equals(key))
|
||||||
@ -108,13 +109,13 @@ public class AdditionalLauncher {
|
|||||||
"--description", unused -> cmd.name()));
|
"--description", unused -> cmd.name()));
|
||||||
}
|
}
|
||||||
|
|
||||||
final public AdditionalLauncher setShortcuts(boolean menu, boolean shortcut) {
|
public final AdditionalLauncher setShortcuts(boolean menu, boolean shortcut) {
|
||||||
withMenuShortcut = menu;
|
withMenuShortcut = menu;
|
||||||
withShortcut = shortcut;
|
withShortcut = shortcut;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
final public AdditionalLauncher setIcon(Path iconPath) {
|
public final AdditionalLauncher setIcon(Path iconPath) {
|
||||||
if (iconPath == NO_ICON) {
|
if (iconPath == NO_ICON) {
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
}
|
}
|
||||||
@ -123,12 +124,12 @@ public class AdditionalLauncher {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
final public AdditionalLauncher setNoIcon() {
|
public final AdditionalLauncher setNoIcon() {
|
||||||
icon = NO_ICON;
|
icon = NO_ICON;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
final public AdditionalLauncher setPersistenceHandler(
|
public final AdditionalLauncher setPersistenceHandler(
|
||||||
ThrowingBiConsumer<Path, List<Map.Entry<String, String>>> handler) {
|
ThrowingBiConsumer<Path, List<Map.Entry<String, String>>> handler) {
|
||||||
if (handler != null) {
|
if (handler != null) {
|
||||||
createFileHandler = ThrowingBiConsumer.toBiConsumer(handler);
|
createFileHandler = ThrowingBiConsumer.toBiConsumer(handler);
|
||||||
@ -138,12 +139,12 @@ public class AdditionalLauncher {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
final public void applyTo(JPackageCommand cmd) {
|
public final void applyTo(JPackageCommand cmd) {
|
||||||
cmd.addPrerequisiteAction(this::initialize);
|
cmd.addPrerequisiteAction(this::initialize);
|
||||||
cmd.addVerifyAction(this::verify);
|
cmd.addVerifyAction(this::verify);
|
||||||
}
|
}
|
||||||
|
|
||||||
final public void applyTo(PackageTest test) {
|
public final void applyTo(PackageTest test) {
|
||||||
test.addInitializer(this::initialize);
|
test.addInitializer(this::initialize);
|
||||||
test.addInstallVerifier(this::verify);
|
test.addInstallVerifier(this::verify);
|
||||||
if (verifyUninstalled) {
|
if (verifyUninstalled) {
|
||||||
@ -151,7 +152,7 @@ public class AdditionalLauncher {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final public void verifyRemovedInUpgrade(PackageTest test) {
|
public final void verifyRemovedInUpgrade(PackageTest test) {
|
||||||
test.addInstallVerifier(this::verifyUninstalled);
|
test.addInstallVerifier(this::verifyUninstalled);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,7 +190,7 @@ public class AdditionalLauncher {
|
|||||||
propsFile = TKit.createTempFile(propsFile);
|
propsFile = TKit.createTempFile(propsFile);
|
||||||
TKit.deleteIfExists(propsFile);
|
TKit.deleteIfExists(propsFile);
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
Functional.rethrowUnchecked(ex);
|
rethrowUnchecked(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -446,7 +447,7 @@ public class AdditionalLauncher {
|
|||||||
private Boolean withMenuShortcut;
|
private Boolean withMenuShortcut;
|
||||||
private Boolean withShortcut;
|
private Boolean withShortcut;
|
||||||
|
|
||||||
private final static Path NO_ICON = Path.of("");
|
private static final Path NO_ICON = Path.of("");
|
||||||
private final static Map.Entry<String, String> LAUNCHER_AS_SERVICE = Map.entry(
|
private static final Map.Entry<String, String> LAUNCHER_AS_SERVICE = Map.entry(
|
||||||
"launcher-as-service", "true");
|
"launcher-as-service", "true");
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -42,7 +42,7 @@ import java.util.regex.Pattern;
|
|||||||
import java.util.spi.ToolProvider;
|
import java.util.spi.ToolProvider;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
import jdk.jpackage.test.Functional.ThrowingSupplier;
|
import jdk.jpackage.internal.util.function.ThrowingSupplier;
|
||||||
|
|
||||||
public final class Executor extends CommandArguments<Executor> {
|
public final class Executor extends CommandArguments<Executor> {
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -32,10 +32,10 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import jdk.jpackage.internal.IOUtils;
|
import jdk.jpackage.internal.util.PathUtils;
|
||||||
|
|
||||||
|
|
||||||
final public class FileAssociations {
|
public final class FileAssociations {
|
||||||
public FileAssociations(String faSuffixName) {
|
public FileAssociations(String faSuffixName) {
|
||||||
suffixName = faSuffixName;
|
suffixName = faSuffixName;
|
||||||
setFilename("fa");
|
setFilename("fa");
|
||||||
@ -79,7 +79,7 @@ final public class FileAssociations {
|
|||||||
if (icon == null) {
|
if (icon == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return Path.of(getMime().replace('/', '-') + IOUtils.getSuffix(icon));
|
return Path.of(getMime().replace('/', '-') + PathUtils.getSuffix(icon));
|
||||||
}
|
}
|
||||||
|
|
||||||
Path getPropertiesFile() {
|
Path getPropertiesFile() {
|
||||||
@ -243,7 +243,7 @@ final public class FileAssociations {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Path file;
|
private Path file;
|
||||||
final private String suffixName;
|
private final String suffixName;
|
||||||
private String description;
|
private String description;
|
||||||
private Path icon;
|
private Path icon;
|
||||||
private Collection<TestRun> testRuns;
|
private Collection<TestRun> testRuns;
|
||||||
|
@ -31,84 +31,6 @@ import java.util.function.Supplier;
|
|||||||
|
|
||||||
|
|
||||||
public class Functional {
|
public class Functional {
|
||||||
@FunctionalInterface
|
|
||||||
public interface ThrowingConsumer<T> {
|
|
||||||
void accept(T t) throws Throwable;
|
|
||||||
|
|
||||||
public static <T> Consumer<T> toConsumer(ThrowingConsumer<T> v) {
|
|
||||||
return o -> {
|
|
||||||
try {
|
|
||||||
v.accept(o);
|
|
||||||
} catch (Throwable ex) {
|
|
||||||
rethrowUnchecked(ex);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@FunctionalInterface
|
|
||||||
public interface ThrowingBiConsumer<T, U> {
|
|
||||||
void accept(T t, U u) throws Throwable;
|
|
||||||
|
|
||||||
public static <T, U> BiConsumer<T, U> toBiConsumer(ThrowingBiConsumer<T, U> v) {
|
|
||||||
return (t, u) -> {
|
|
||||||
try {
|
|
||||||
v.accept(t, u);
|
|
||||||
} catch (Throwable ex) {
|
|
||||||
rethrowUnchecked(ex);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@FunctionalInterface
|
|
||||||
public interface ThrowingSupplier<T> {
|
|
||||||
T get() throws Throwable;
|
|
||||||
|
|
||||||
public static <T> Supplier<T> toSupplier(ThrowingSupplier<T> v) {
|
|
||||||
return () -> {
|
|
||||||
try {
|
|
||||||
return v.get();
|
|
||||||
} catch (Throwable ex) {
|
|
||||||
rethrowUnchecked(ex);
|
|
||||||
}
|
|
||||||
// Unreachable
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@FunctionalInterface
|
|
||||||
public interface ThrowingFunction<T, R> {
|
|
||||||
R apply(T t) throws Throwable;
|
|
||||||
|
|
||||||
public static <T, R> Function<T, R> toFunction(ThrowingFunction<T, R> v) {
|
|
||||||
return (t) -> {
|
|
||||||
try {
|
|
||||||
return v.apply(t);
|
|
||||||
} catch (Throwable ex) {
|
|
||||||
rethrowUnchecked(ex);
|
|
||||||
}
|
|
||||||
// Unreachable
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@FunctionalInterface
|
|
||||||
public interface ThrowingRunnable {
|
|
||||||
void run() throws Throwable;
|
|
||||||
|
|
||||||
public static Runnable toRunnable(ThrowingRunnable v) {
|
|
||||||
return () -> {
|
|
||||||
try {
|
|
||||||
v.run();
|
|
||||||
} catch (Throwable ex) {
|
|
||||||
rethrowUnchecked(ex);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> Supplier<T> identity(Supplier<T> v) {
|
public static <T> Supplier<T> identity(Supplier<T> v) {
|
||||||
return v;
|
return v;
|
||||||
@ -141,28 +63,4 @@ public class Functional {
|
|||||||
public static <T> Predicate<T> identityPredicate(Predicate<T> v) {
|
public static <T> Predicate<T> identityPredicate(Predicate<T> v) {
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ExceptionBox extends RuntimeException {
|
|
||||||
public ExceptionBox(Throwable throwable) {
|
|
||||||
super(throwable);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public static RuntimeException rethrowUnchecked(Throwable throwable) throws
|
|
||||||
ExceptionBox {
|
|
||||||
if (throwable instanceof RuntimeException err) {
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (throwable instanceof Error err) {
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (throwable instanceof InvocationTargetException err) {
|
|
||||||
throw rethrowUnchecked(err.getCause());
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new ExceptionBox(throwable);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -40,9 +40,9 @@ import java.util.regex.Pattern;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipFile;
|
import java.util.zip.ZipFile;
|
||||||
import jdk.jpackage.test.Functional.ThrowingConsumer;
|
import jdk.jpackage.internal.util.function.ThrowingConsumer;
|
||||||
import jdk.jpackage.test.Functional.ThrowingFunction;
|
import jdk.jpackage.internal.util.function.ThrowingFunction;
|
||||||
import jdk.jpackage.test.Functional.ThrowingSupplier;
|
import jdk.jpackage.internal.util.function.ThrowingSupplier;
|
||||||
|
|
||||||
public final class HelloApp {
|
public final class HelloApp {
|
||||||
|
|
||||||
|
@ -45,15 +45,15 @@ import java.util.regex.Matcher;
|
|||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
import jdk.jpackage.internal.IOUtils;
|
|
||||||
import jdk.jpackage.internal.AppImageFile;
|
import jdk.jpackage.internal.AppImageFile;
|
||||||
import jdk.jpackage.internal.ApplicationLayout;
|
import jdk.jpackage.internal.ApplicationLayout;
|
||||||
import jdk.jpackage.internal.PackageFile;
|
import jdk.jpackage.internal.PackageFile;
|
||||||
|
import jdk.jpackage.internal.util.XmlUtils;
|
||||||
import static jdk.jpackage.test.AdditionalLauncher.forEachAdditionalLauncher;
|
import static jdk.jpackage.test.AdditionalLauncher.forEachAdditionalLauncher;
|
||||||
import jdk.jpackage.test.Functional.ThrowingConsumer;
|
import jdk.jpackage.internal.util.function.ThrowingConsumer;
|
||||||
import jdk.jpackage.test.Functional.ThrowingFunction;
|
import jdk.jpackage.internal.util.function.ThrowingFunction;
|
||||||
import jdk.jpackage.test.Functional.ThrowingRunnable;
|
import jdk.jpackage.internal.util.function.ThrowingRunnable;
|
||||||
import jdk.jpackage.test.Functional.ThrowingSupplier;
|
import jdk.jpackage.internal.util.function.ThrowingSupplier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* jpackage command line with prerequisite actions. Prerequisite actions can be
|
* jpackage command line with prerequisite actions. Prerequisite actions can be
|
||||||
@ -315,7 +315,7 @@ public final class JPackageCommand extends CommandArguments<JPackageCommand> {
|
|||||||
"Error: --app-image expected");
|
"Error: --app-image expected");
|
||||||
}));
|
}));
|
||||||
|
|
||||||
IOUtils.createXml(jpackageXMLFile, xml -> {
|
XmlUtils.createXml(jpackageXMLFile, xml -> {
|
||||||
xml.writeStartElement("jpackage-state");
|
xml.writeStartElement("jpackage-state");
|
||||||
xml.writeAttribute("version", AppImageFile.getVersion());
|
xml.writeAttribute("version", AppImageFile.getVersion());
|
||||||
xml.writeAttribute("platform", AppImageFile.getPlatform());
|
xml.writeAttribute("platform", AppImageFile.getPlatform());
|
||||||
|
@ -35,8 +35,10 @@ import java.util.function.Consumer;
|
|||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
import jdk.jpackage.internal.IOUtils;
|
import jdk.jpackage.internal.util.PathUtils;
|
||||||
import static jdk.jpackage.test.Functional.ThrowingConsumer.toConsumer;
|
import jdk.jpackage.internal.util.function.ThrowingBiConsumer;
|
||||||
|
import static jdk.jpackage.internal.util.function.ThrowingConsumer.toConsumer;
|
||||||
|
import jdk.jpackage.internal.util.function.ThrowingRunnable;
|
||||||
import static jdk.jpackage.test.PackageType.LINUX;
|
import static jdk.jpackage.test.PackageType.LINUX;
|
||||||
import static jdk.jpackage.test.PackageType.MAC_PKG;
|
import static jdk.jpackage.test.PackageType.MAC_PKG;
|
||||||
import static jdk.jpackage.test.PackageType.WINDOWS;
|
import static jdk.jpackage.test.PackageType.WINDOWS;
|
||||||
@ -187,7 +189,7 @@ public final class LauncherAsServiceVerifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
AdditionalLauncher.forEachAdditionalLauncher(cmd,
|
AdditionalLauncher.forEachAdditionalLauncher(cmd,
|
||||||
Functional.ThrowingBiConsumer.toBiConsumer(
|
ThrowingBiConsumer.toBiConsumer(
|
||||||
(launcherName, propFilePath) -> {
|
(launcherName, propFilePath) -> {
|
||||||
if (Files.readAllLines(propFilePath).stream().anyMatch(
|
if (Files.readAllLines(propFilePath).stream().anyMatch(
|
||||||
line -> {
|
line -> {
|
||||||
@ -335,14 +337,14 @@ public final class LauncherAsServiceVerifier {
|
|||||||
TKit.assertEquals(installedLauncherPath.toString(), args.get(0),
|
TKit.assertEquals(installedLauncherPath.toString(), args.get(0),
|
||||||
"Check path to launcher in 'ProgramArguments' property in the property file");
|
"Check path to launcher in 'ProgramArguments' property in the property file");
|
||||||
|
|
||||||
var expectedLabel = IOUtils.replaceSuffix(servicePlistFile.getFileName(), "").toString();
|
var expectedLabel = PathUtils.replaceSuffix(servicePlistFile.getFileName(), "").toString();
|
||||||
TKit.assertEquals(expectedLabel, servicePlist.queryValue("Label"),
|
TKit.assertEquals(expectedLabel, servicePlist.queryValue("Label"),
|
||||||
"Check value of 'Label' property in the property file");
|
"Check value of 'Label' property in the property file");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void delayInstallVerify() {
|
private static void delayInstallVerify() {
|
||||||
// Sleep a bit to let system launch the service
|
// Sleep a bit to let system launch the service
|
||||||
Functional.ThrowingRunnable.toRunnable(() -> Thread.sleep(5 * 1000)).run();
|
ThrowingRunnable.toRunnable(() -> Thread.sleep(5 * 1000)).run();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Path appOutputFilePathInitialize() {
|
private Path appOutputFilePathInitialize() {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -31,6 +31,7 @@ import java.nio.file.Files;
|
|||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
|
import static jdk.jpackage.internal.util.function.ExceptionBox.rethrowUnchecked;
|
||||||
|
|
||||||
public final class LauncherIconVerifier {
|
public final class LauncherIconVerifier {
|
||||||
public LauncherIconVerifier() {
|
public LauncherIconVerifier() {
|
||||||
@ -176,7 +177,7 @@ public final class LauncherIconVerifier {
|
|||||||
iconSwapWrapper.setAccessible(true);
|
iconSwapWrapper.setAccessible(true);
|
||||||
} catch (ClassNotFoundException | NoSuchMethodException
|
} catch (ClassNotFoundException | NoSuchMethodException
|
||||||
| SecurityException ex) {
|
| SecurityException ex) {
|
||||||
throw Functional.rethrowUnchecked(ex);
|
throw rethrowUnchecked(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -254,14 +255,14 @@ public final class LauncherIconVerifier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IllegalAccessException | InvocationTargetException ex) {
|
} catch (IllegalAccessException | InvocationTargetException ex) {
|
||||||
throw Functional.rethrowUnchecked(ex);
|
throw rethrowUnchecked(ex);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
launcherPath.toFile().setWritable(false, true);
|
launcherPath.toFile().setWritable(false, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final static WinIconVerifier instance = new WinIconVerifier();
|
static final WinIconVerifier instance = new WinIconVerifier();
|
||||||
|
|
||||||
private final Class executableRebranderClass;
|
private final Class executableRebranderClass;
|
||||||
private final Method lockResource;
|
private final Method lockResource;
|
||||||
|
@ -41,8 +41,8 @@ import java.util.regex.Pattern;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
import jdk.jpackage.internal.ApplicationLayout;
|
import jdk.jpackage.internal.ApplicationLayout;
|
||||||
import jdk.jpackage.internal.IOUtils;
|
import jdk.jpackage.internal.util.PathUtils;
|
||||||
import jdk.jpackage.test.Functional.ThrowingConsumer;
|
import jdk.jpackage.internal.util.function.ThrowingConsumer;
|
||||||
import jdk.jpackage.test.PackageTest.PackageHandlers;
|
import jdk.jpackage.test.PackageTest.PackageHandlers;
|
||||||
|
|
||||||
|
|
||||||
@ -578,7 +578,7 @@ public final class LinuxHelper {
|
|||||||
|
|
||||||
private static void verifyIconInScriptlet(Scriptlet scriptletType,
|
private static void verifyIconInScriptlet(Scriptlet scriptletType,
|
||||||
List<String> scriptletBody, Path iconPathInPackage) {
|
List<String> scriptletBody, Path iconPathInPackage) {
|
||||||
final String dashMime = IOUtils.replaceSuffix(
|
final String dashMime = PathUtils.replaceSuffix(
|
||||||
iconPathInPackage.getFileName(), null).toString();
|
iconPathInPackage.getFileName(), null).toString();
|
||||||
final String xdgCmdName = "xdg-icon-resource";
|
final String xdgCmdName = "xdg-icon-resource";
|
||||||
|
|
||||||
|
@ -43,11 +43,11 @@ import javax.xml.parsers.ParserConfigurationException;
|
|||||||
import javax.xml.xpath.XPath;
|
import javax.xml.xpath.XPath;
|
||||||
import javax.xml.xpath.XPathConstants;
|
import javax.xml.xpath.XPathConstants;
|
||||||
import javax.xml.xpath.XPathFactory;
|
import javax.xml.xpath.XPathFactory;
|
||||||
import jdk.jpackage.internal.IOUtils;
|
import jdk.jpackage.internal.util.function.ThrowingConsumer;
|
||||||
import jdk.jpackage.test.Functional.ThrowingConsumer;
|
import jdk.jpackage.internal.util.function.ThrowingSupplier;
|
||||||
import jdk.jpackage.test.Functional.ThrowingSupplier;
|
|
||||||
import jdk.jpackage.test.PackageTest.PackageHandlers;
|
import jdk.jpackage.test.PackageTest.PackageHandlers;
|
||||||
import jdk.jpackage.internal.RetryExecutor;
|
import jdk.jpackage.internal.RetryExecutor;
|
||||||
|
import jdk.jpackage.internal.util.PathUtils;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
import org.w3c.dom.NodeList;
|
import org.w3c.dom.NodeList;
|
||||||
|
|
||||||
@ -212,7 +212,7 @@ public final class MacHelper {
|
|||||||
// Unpack all ".pkg" files from $dataDir folder in $unpackDir folder
|
// Unpack all ".pkg" files from $dataDir folder in $unpackDir folder
|
||||||
try (var dataListing = Files.list(dataDir)) {
|
try (var dataListing = Files.list(dataDir)) {
|
||||||
dataListing.filter(file -> {
|
dataListing.filter(file -> {
|
||||||
return ".pkg".equals(IOUtils.getSuffix(file.getFileName()));
|
return ".pkg".equals(PathUtils.getSuffix(file.getFileName()));
|
||||||
}).forEach(ThrowingConsumer.toConsumer(pkgDir -> {
|
}).forEach(ThrowingConsumer.toConsumer(pkgDir -> {
|
||||||
// Installation root of the package is stored in
|
// Installation root of the package is stored in
|
||||||
// /pkg-info@install-location attribute in $pkgDir/PackageInfo xml file
|
// /pkg-info@install-location attribute in $pkgDir/PackageInfo xml file
|
||||||
|
@ -37,7 +37,7 @@ import java.util.Optional;
|
|||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.stream.IntStream;
|
import java.util.stream.IntStream;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
import jdk.jpackage.test.Functional.ThrowingConsumer;
|
import jdk.jpackage.internal.util.function.ThrowingConsumer;
|
||||||
import jdk.jpackage.test.TestInstance.TestDesc;
|
import jdk.jpackage.test.TestInstance.TestDesc;
|
||||||
|
|
||||||
class MethodCall implements ThrowingConsumer {
|
class MethodCall implements ThrowingConsumer {
|
||||||
|
@ -46,13 +46,13 @@ import java.util.stream.Collectors;
|
|||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
import java.util.stream.StreamSupport;
|
import java.util.stream.StreamSupport;
|
||||||
import jdk.jpackage.internal.ApplicationLayout;
|
import jdk.jpackage.internal.ApplicationLayout;
|
||||||
import jdk.jpackage.test.Functional.ThrowingBiConsumer;
|
import jdk.jpackage.internal.util.function.ThrowingBiConsumer;
|
||||||
import static jdk.jpackage.test.Functional.ThrowingBiConsumer.toBiConsumer;
|
import static jdk.jpackage.internal.util.function.ThrowingBiConsumer.toBiConsumer;
|
||||||
import jdk.jpackage.test.Functional.ThrowingConsumer;
|
import jdk.jpackage.internal.util.function.ThrowingConsumer;
|
||||||
import static jdk.jpackage.test.Functional.ThrowingConsumer.toConsumer;
|
import static jdk.jpackage.internal.util.function.ThrowingConsumer.toConsumer;
|
||||||
import jdk.jpackage.test.Functional.ThrowingRunnable;
|
import jdk.jpackage.internal.util.function.ThrowingRunnable;
|
||||||
import static jdk.jpackage.test.Functional.ThrowingSupplier.toSupplier;
|
import static jdk.jpackage.internal.util.function.ThrowingSupplier.toSupplier;
|
||||||
import static jdk.jpackage.test.Functional.rethrowUnchecked;
|
import static jdk.jpackage.internal.util.function.ExceptionBox.rethrowUnchecked;
|
||||||
import static jdk.jpackage.test.PackageType.LINUX;
|
import static jdk.jpackage.test.PackageType.LINUX;
|
||||||
import static jdk.jpackage.test.PackageType.LINUX_DEB;
|
import static jdk.jpackage.test.PackageType.LINUX_DEB;
|
||||||
import static jdk.jpackage.test.PackageType.LINUX_RPM;
|
import static jdk.jpackage.test.PackageType.LINUX_RPM;
|
||||||
|
@ -32,6 +32,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
import jdk.jpackage.internal.Log;
|
import jdk.jpackage.internal.Log;
|
||||||
|
import static jdk.jpackage.internal.util.function.ExceptionBox.rethrowUnchecked;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* jpackage type traits.
|
* jpackage type traits.
|
||||||
@ -103,7 +104,7 @@ public enum PackageType {
|
|||||||
} catch (ClassNotFoundException | IllegalAccessException ex) {
|
} catch (ClassNotFoundException | IllegalAccessException ex) {
|
||||||
} catch (InstantiationException | NoSuchMethodException
|
} catch (InstantiationException | NoSuchMethodException
|
||||||
| InvocationTargetException ex) {
|
| InvocationTargetException ex) {
|
||||||
Functional.rethrowUnchecked(ex);
|
rethrowUnchecked(ex);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -127,7 +128,7 @@ public enum PackageType {
|
|||||||
thread.run();
|
thread.run();
|
||||||
thread.join();
|
thread.join();
|
||||||
} catch (InterruptedException ex) {
|
} catch (InterruptedException ex) {
|
||||||
Functional.rethrowUnchecked(ex);
|
rethrowUnchecked(ex);
|
||||||
}
|
}
|
||||||
return reply.get();
|
return reply.get();
|
||||||
}
|
}
|
||||||
@ -136,15 +137,15 @@ public enum PackageType {
|
|||||||
private final String suffix;
|
private final String suffix;
|
||||||
private final boolean supported;
|
private final boolean supported;
|
||||||
|
|
||||||
public final static Set<PackageType> LINUX = Set.of(LINUX_DEB, LINUX_RPM);
|
public static final Set<PackageType> LINUX = Set.of(LINUX_DEB, LINUX_RPM);
|
||||||
public final static Set<PackageType> WINDOWS = Set.of(WIN_EXE, WIN_MSI);
|
public static final Set<PackageType> WINDOWS = Set.of(WIN_EXE, WIN_MSI);
|
||||||
public final static Set<PackageType> MAC = Set.of(MAC_PKG, MAC_DMG);
|
public static final Set<PackageType> MAC = Set.of(MAC_PKG, MAC_DMG);
|
||||||
public final static Set<PackageType> NATIVE = Stream.concat(
|
public static final Set<PackageType> NATIVE = Stream.concat(
|
||||||
Stream.concat(LINUX.stream(), WINDOWS.stream()),
|
Stream.concat(LINUX.stream(), WINDOWS.stream()),
|
||||||
MAC.stream()).collect(Collectors.toUnmodifiableSet());
|
MAC.stream()).collect(Collectors.toUnmodifiableSet());
|
||||||
|
|
||||||
private final static class Inner {
|
private static final class Inner {
|
||||||
private final static Set<String> DISABLED_PACKAGERS = Optional.ofNullable(
|
private static final Set<String> DISABLED_PACKAGERS = Optional.ofNullable(
|
||||||
TKit.tokenizeConfigProperty("disabledPackagers")).orElse(
|
TKit.tokenizeConfigProperty("disabledPackagers")).orElse(
|
||||||
TKit.isLinuxAPT() ? Set.of("rpm") : Collections.emptySet());
|
TKit.isLinuxAPT() ? Set.of("rpm") : Collections.emptySet());
|
||||||
}
|
}
|
||||||
|
@ -61,10 +61,10 @@ import java.util.stream.Collectors;
|
|||||||
import static java.util.stream.Collectors.toSet;
|
import static java.util.stream.Collectors.toSet;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
import jdk.internal.util.OperatingSystem;
|
import jdk.internal.util.OperatingSystem;
|
||||||
import jdk.jpackage.test.Functional.ExceptionBox;
|
import jdk.jpackage.internal.util.function.ExceptionBox;
|
||||||
import jdk.jpackage.test.Functional.ThrowingConsumer;
|
import jdk.jpackage.internal.util.function.ThrowingConsumer;
|
||||||
import jdk.jpackage.test.Functional.ThrowingRunnable;
|
import jdk.jpackage.internal.util.function.ThrowingRunnable;
|
||||||
import jdk.jpackage.test.Functional.ThrowingSupplier;
|
import jdk.jpackage.internal.util.function.ThrowingSupplier;
|
||||||
|
|
||||||
public final class TKit {
|
public final class TKit {
|
||||||
|
|
||||||
|
@ -40,9 +40,9 @@ import java.util.stream.Stream;
|
|||||||
import jdk.jpackage.test.Annotations.AfterEach;
|
import jdk.jpackage.test.Annotations.AfterEach;
|
||||||
import jdk.jpackage.test.Annotations.BeforeEach;
|
import jdk.jpackage.test.Annotations.BeforeEach;
|
||||||
import jdk.jpackage.test.Annotations.Test;
|
import jdk.jpackage.test.Annotations.Test;
|
||||||
import jdk.jpackage.test.Functional.ThrowingConsumer;
|
import jdk.jpackage.internal.util.function.ThrowingConsumer;
|
||||||
import static jdk.jpackage.test.Functional.ThrowingConsumer.toConsumer;
|
import static jdk.jpackage.internal.util.function.ThrowingConsumer.toConsumer;
|
||||||
import jdk.jpackage.test.Functional.ThrowingFunction;
|
import jdk.jpackage.internal.util.function.ThrowingFunction;
|
||||||
import jdk.jpackage.test.TestMethodSupplier.InvalidAnnotationException;
|
import jdk.jpackage.test.TestMethodSupplier.InvalidAnnotationException;
|
||||||
import static jdk.jpackage.test.TestMethodSupplier.MethodQuery.fromQualifiedMethodName;
|
import static jdk.jpackage.test.TestMethodSupplier.MethodQuery.fromQualifiedMethodName;
|
||||||
|
|
||||||
|
@ -40,9 +40,10 @@ import java.util.function.Predicate;
|
|||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
import jdk.jpackage.test.Functional.ThrowingConsumer;
|
import jdk.jpackage.internal.util.function.ThrowingConsumer;
|
||||||
import jdk.jpackage.test.Functional.ThrowingFunction;
|
import jdk.jpackage.internal.util.function.ThrowingFunction;
|
||||||
import jdk.jpackage.test.Functional.ThrowingRunnable;
|
import jdk.jpackage.internal.util.function.ThrowingRunnable;
|
||||||
|
import jdk.jpackage.internal.util.function.ThrowingSupplier;
|
||||||
|
|
||||||
final class TestInstance implements ThrowingRunnable {
|
final class TestInstance implements ThrowingRunnable {
|
||||||
|
|
||||||
@ -258,7 +259,7 @@ final class TestInstance implements ThrowingRunnable {
|
|||||||
StackTraceElement st[] = Thread.currentThread().getStackTrace();
|
StackTraceElement st[] = Thread.currentThread().getStackTrace();
|
||||||
for (StackTraceElement ste : st) {
|
for (StackTraceElement ste : st) {
|
||||||
if ("main".equals(ste.getMethodName())) {
|
if ("main".equals(ste.getMethodName())) {
|
||||||
return Functional.ThrowingSupplier.toSupplier(() -> Class.forName(
|
return ThrowingSupplier.toSupplier(() -> Class.forName(
|
||||||
ste.getClassName())).get();
|
ste.getClassName())).get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,8 +49,8 @@ import jdk.jpackage.test.Annotations.ParameterSupplier;
|
|||||||
import jdk.jpackage.test.Annotations.ParameterSupplierGroup;
|
import jdk.jpackage.test.Annotations.ParameterSupplierGroup;
|
||||||
import jdk.jpackage.test.Annotations.Parameters;
|
import jdk.jpackage.test.Annotations.Parameters;
|
||||||
import jdk.jpackage.test.Annotations.Test;
|
import jdk.jpackage.test.Annotations.Test;
|
||||||
import static jdk.jpackage.test.Functional.ThrowingFunction.toFunction;
|
import static jdk.jpackage.internal.util.function.ThrowingFunction.toFunction;
|
||||||
import static jdk.jpackage.test.Functional.ThrowingSupplier.toSupplier;
|
import static jdk.jpackage.internal.util.function.ThrowingSupplier.toSupplier;
|
||||||
import static jdk.jpackage.test.MethodCall.mapArgs;
|
import static jdk.jpackage.test.MethodCall.mapArgs;
|
||||||
|
|
||||||
final class TestMethodSupplier {
|
final class TestMethodSupplier {
|
||||||
|
@ -36,7 +36,7 @@ import java.util.regex.Matcher;
|
|||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
import jdk.jpackage.test.Functional.ThrowingRunnable;
|
import jdk.jpackage.internal.util.function.ThrowingRunnable;
|
||||||
import jdk.jpackage.test.PackageTest.PackageHandlers;
|
import jdk.jpackage.test.PackageTest.PackageHandlers;
|
||||||
|
|
||||||
public class WindowsHelper {
|
public class WindowsHelper {
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import jdk.jpackage.test.Annotations.Test;
|
import jdk.jpackage.test.Annotations.Test;
|
||||||
import jdk.jpackage.test.Functional.ThrowingConsumer;
|
import jdk.jpackage.internal.util.function.ThrowingConsumer;
|
||||||
import jdk.jpackage.test.JPackageCommand;
|
import jdk.jpackage.test.JPackageCommand;
|
||||||
import jdk.jpackage.test.PackageTest;
|
import jdk.jpackage.test.PackageTest;
|
||||||
import jdk.jpackage.test.PackageType;
|
import jdk.jpackage.test.PackageType;
|
||||||
|
@ -33,8 +33,8 @@ import java.util.Collection;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import static java.util.stream.Collectors.joining;
|
import static java.util.stream.Collectors.joining;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
import jdk.jpackage.internal.IOUtils;
|
import jdk.jpackage.internal.util.FileUtils;
|
||||||
import jdk.jpackage.test.Functional.ThrowingFunction;
|
import jdk.jpackage.internal.util.function.ThrowingFunction;
|
||||||
import jdk.jpackage.test.JPackageCommand;
|
import jdk.jpackage.test.JPackageCommand;
|
||||||
|
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ public class AppContentTest {
|
|||||||
// In particular, random files should be placed in "Contents/Resources" folder
|
// In particular, random files should be placed in "Contents/Resources" folder
|
||||||
// otherwise "codesign" will fail to sign.
|
// otherwise "codesign" will fail to sign.
|
||||||
// Need to prepare arguments for `--app-content` accordingly.
|
// Need to prepare arguments for `--app-content` accordingly.
|
||||||
private final static boolean copyInResources = TKit.isOSX();
|
private static final boolean copyInResources = TKit.isOSX();
|
||||||
|
|
||||||
private final List<String> testPathArgs;
|
private final List<String> testPathArgs;
|
||||||
|
|
||||||
@ -148,7 +148,7 @@ public class AppContentTest {
|
|||||||
var srcPath = TKit.TEST_SRC_ROOT.resolve(appContentPath);
|
var srcPath = TKit.TEST_SRC_ROOT.resolve(appContentPath);
|
||||||
var dstPath = appContentArg.resolve(srcPath.getFileName());
|
var dstPath = appContentArg.resolve(srcPath.getFileName());
|
||||||
Files.createDirectories(dstPath.getParent());
|
Files.createDirectories(dstPath.getParent());
|
||||||
IOUtils.copyRecursive(srcPath, dstPath);
|
FileUtils.copyRecursive(srcPath, dstPath);
|
||||||
return appContentArg;
|
return appContentArg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ import jdk.jpackage.test.Executor;
|
|||||||
import jdk.jpackage.test.JavaTool;
|
import jdk.jpackage.test.JavaTool;
|
||||||
import jdk.jpackage.test.Annotations.Test;
|
import jdk.jpackage.test.Annotations.Test;
|
||||||
import jdk.jpackage.test.Annotations.Parameter;
|
import jdk.jpackage.test.Annotations.Parameter;
|
||||||
import jdk.jpackage.test.Functional.ThrowingConsumer;
|
import jdk.jpackage.internal.util.function.ThrowingConsumer;
|
||||||
import static jdk.jpackage.test.RunnablePackageTest.Action.CREATE_AND_UNPACK;
|
import static jdk.jpackage.test.RunnablePackageTest.Action.CREATE_AND_UNPACK;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -41,8 +41,8 @@ import jdk.jpackage.test.PackageTest;
|
|||||||
import jdk.jpackage.test.Executor;
|
import jdk.jpackage.test.Executor;
|
||||||
import jdk.jpackage.test.LinuxHelper;
|
import jdk.jpackage.test.LinuxHelper;
|
||||||
import jdk.jpackage.test.AdditionalLauncher;
|
import jdk.jpackage.test.AdditionalLauncher;
|
||||||
import jdk.jpackage.test.Functional.ThrowingConsumer;
|
import jdk.jpackage.internal.util.function.ThrowingConsumer;
|
||||||
import jdk.jpackage.test.Functional.ThrowingBiConsumer;
|
import jdk.jpackage.internal.util.function.ThrowingBiConsumer;
|
||||||
import jdk.jpackage.test.Annotations.Parameters;
|
import jdk.jpackage.test.Annotations.Parameters;
|
||||||
import jdk.jpackage.test.Annotations.Test;
|
import jdk.jpackage.test.Annotations.Test;
|
||||||
|
|
||||||
@ -428,7 +428,7 @@ public class IconTest {
|
|||||||
private final Path cmdlineIcon;
|
private final Path cmdlineIcon;
|
||||||
private final Path resourceDirIcon;
|
private final Path resourceDirIcon;
|
||||||
|
|
||||||
private final static Set<Launcher> PRIMARY = Set.of(Main, Additional);
|
private static final Set<Launcher> PRIMARY = Set.of(Main, Additional);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final boolean appImage;
|
private final boolean appImage;
|
||||||
@ -440,7 +440,7 @@ public class IconTest {
|
|||||||
+ TKit.ICON_SUFFIX));
|
+ TKit.ICON_SUFFIX));
|
||||||
}
|
}
|
||||||
|
|
||||||
private final static Path[] ICONS = Stream.of("icon", "icon2", "icon3",
|
private static final Path[] ICONS = Stream.of("icon", "icon2", "icon3",
|
||||||
"icon4")
|
"icon4")
|
||||||
.map(IconTest::iconPath)
|
.map(IconTest::iconPath)
|
||||||
.collect(Collectors.toList()).toArray(Path[]::new);
|
.collect(Collectors.toList()).toArray(Path[]::new);
|
||||||
|
@ -36,7 +36,7 @@ import jdk.jpackage.internal.ApplicationLayout;
|
|||||||
import jdk.jpackage.internal.PackageFile;
|
import jdk.jpackage.internal.PackageFile;
|
||||||
import jdk.jpackage.test.Annotations.Parameters;
|
import jdk.jpackage.test.Annotations.Parameters;
|
||||||
import jdk.jpackage.test.Annotations.Test;
|
import jdk.jpackage.test.Annotations.Test;
|
||||||
import jdk.jpackage.test.Functional.ThrowingConsumer;
|
import jdk.jpackage.internal.util.function.ThrowingConsumer;
|
||||||
import jdk.jpackage.test.JPackageCommand;
|
import jdk.jpackage.test.JPackageCommand;
|
||||||
import jdk.jpackage.test.JPackageCommand.AppLayoutAssert;
|
import jdk.jpackage.test.JPackageCommand.AppLayoutAssert;
|
||||||
import jdk.jpackage.test.PackageTest;
|
import jdk.jpackage.test.PackageTest;
|
||||||
|
@ -44,7 +44,7 @@ import jdk.jpackage.test.JavaTool;
|
|||||||
import jdk.jpackage.test.Annotations.Parameters;
|
import jdk.jpackage.test.Annotations.Parameters;
|
||||||
import jdk.jpackage.test.Annotations.Test;
|
import jdk.jpackage.test.Annotations.Test;
|
||||||
import jdk.jpackage.test.CfgFile;
|
import jdk.jpackage.test.CfgFile;
|
||||||
import jdk.jpackage.test.Functional.ThrowingConsumer;
|
import jdk.jpackage.internal.util.function.ThrowingConsumer;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ import java.util.Optional;
|
|||||||
import jdk.jpackage.test.AdditionalLauncher;
|
import jdk.jpackage.test.AdditionalLauncher;
|
||||||
import jdk.jpackage.test.PackageTest;
|
import jdk.jpackage.test.PackageTest;
|
||||||
import jdk.jpackage.test.Annotations.Test;
|
import jdk.jpackage.test.Annotations.Test;
|
||||||
import jdk.jpackage.test.Functional.ThrowingConsumer;
|
import jdk.jpackage.internal.util.function.ThrowingConsumer;
|
||||||
import jdk.jpackage.test.HelloApp;
|
import jdk.jpackage.test.HelloApp;
|
||||||
import jdk.jpackage.test.JPackageCommand;
|
import jdk.jpackage.test.JPackageCommand;
|
||||||
import jdk.jpackage.test.LinuxHelper;
|
import jdk.jpackage.test.LinuxHelper;
|
||||||
|
@ -21,20 +21,11 @@
|
|||||||
* questions.
|
* questions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import jdk.jpackage.internal.ApplicationLayout;
|
import jdk.jpackage.internal.ApplicationLayout;
|
||||||
import jdk.jpackage.test.TKit;
|
import jdk.jpackage.test.TKit;
|
||||||
import jdk.jpackage.test.PackageTest;
|
|
||||||
import jdk.jpackage.test.PackageType;
|
|
||||||
import jdk.jpackage.test.Functional;
|
|
||||||
import jdk.jpackage.test.Annotations.Test;
|
import jdk.jpackage.test.Annotations.Test;
|
||||||
import jdk.jpackage.test.Annotations.Parameter;
|
|
||||||
import jdk.jpackage.test.JPackageCommand;
|
import jdk.jpackage.test.JPackageCommand;
|
||||||
import jdk.jpackage.test.JavaTool;
|
import jdk.jpackage.test.JavaTool;
|
||||||
import jdk.jpackage.test.Executor;
|
import jdk.jpackage.test.Executor;
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
import javax.xml.transform.Result;
|
import javax.xml.transform.Result;
|
||||||
@ -36,7 +35,7 @@ import javax.xml.transform.stream.StreamResult;
|
|||||||
import javax.xml.xpath.XPath;
|
import javax.xml.xpath.XPath;
|
||||||
import javax.xml.xpath.XPathConstants;
|
import javax.xml.xpath.XPathConstants;
|
||||||
import javax.xml.xpath.XPathFactory;
|
import javax.xml.xpath.XPathFactory;
|
||||||
import jdk.jpackage.internal.IOUtils;
|
import jdk.jpackage.internal.util.XmlUtils;
|
||||||
import jdk.jpackage.test.Annotations.Test;
|
import jdk.jpackage.test.Annotations.Test;
|
||||||
import jdk.jpackage.test.Executor;
|
import jdk.jpackage.test.Executor;
|
||||||
import jdk.jpackage.test.PackageTest;
|
import jdk.jpackage.test.PackageTest;
|
||||||
@ -148,7 +147,7 @@ public class WinLongVersionTest {
|
|||||||
|
|
||||||
Path scriptPath = resourceDir.resolve(String.format(
|
Path scriptPath = resourceDir.resolve(String.format(
|
||||||
"%s-post-msi.wsf", cmd.name()));
|
"%s-post-msi.wsf", cmd.name()));
|
||||||
IOUtils.createXml(scriptPath, xml -> {
|
XmlUtils.createXml(scriptPath, xml -> {
|
||||||
xml.writeStartElement("job");
|
xml.writeStartElement("job");
|
||||||
xml.writeAttribute("id", "main");
|
xml.writeAttribute("id", "main");
|
||||||
xml.writeStartElement("script");
|
xml.writeStartElement("script");
|
||||||
@ -194,7 +193,7 @@ public class WinLongVersionTest {
|
|||||||
cmd.setFakeRuntime();
|
cmd.setFakeRuntime();
|
||||||
|
|
||||||
// Create package without Upgrade table
|
// Create package without Upgrade table
|
||||||
Document doc = IOUtils.initDocumentBuilder().parse(
|
Document doc = XmlUtils.initDocumentBuilder().parse(
|
||||||
Files.newInputStream(TKit.SRC_ROOT.resolve(
|
Files.newInputStream(TKit.SRC_ROOT.resolve(
|
||||||
"windows/classes/jdk/jpackage/internal/resources/main.wxs")));
|
"windows/classes/jdk/jpackage/internal/resources/main.wxs")));
|
||||||
XPath xPath = XPathFactory.newInstance().newXPath();
|
XPath xPath = XPathFactory.newInstance().newXPath();
|
||||||
|
@ -24,8 +24,7 @@
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.ArrayList;
|
import jdk.jpackage.internal.util.XmlUtils;
|
||||||
import jdk.jpackage.internal.IOUtils;
|
|
||||||
import jdk.jpackage.test.TKit;
|
import jdk.jpackage.test.TKit;
|
||||||
import jdk.jpackage.test.PackageTest;
|
import jdk.jpackage.test.PackageTest;
|
||||||
import jdk.jpackage.test.PackageType;
|
import jdk.jpackage.test.PackageType;
|
||||||
@ -147,7 +146,7 @@ public class WinScriptTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void createScript(JPackageCommand cmd) throws IOException {
|
void createScript(JPackageCommand cmd) throws IOException {
|
||||||
IOUtils.createXml(Path.of(cmd.getArgumentValue("--resource-dir"),
|
XmlUtils.createXml(Path.of(cmd.getArgumentValue("--resource-dir"),
|
||||||
String.format("%s-%s.wsf", cmd.name(), scriptSuffixName)), xml -> {
|
String.format("%s-%s.wsf", cmd.name(), scriptSuffixName)), xml -> {
|
||||||
xml.writeStartElement("job");
|
xml.writeStartElement("job");
|
||||||
xml.writeAttribute("id", "main");
|
xml.writeAttribute("id", "main");
|
||||||
|
Loading…
Reference in New Issue
Block a user