Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: openjdk/jdk
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 78602be1
Choose a base ref
...
head repository: openjdk/jdk
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 9d1f097d
Choose a head ref

Commits on Nov 16, 2024

  1. - Split IOUtils into PathUtils, FileUtils, and XmlUtils classes in jd…

    …k.jpackage.internal.util package
    
    - Moved jdk.jpackage.test.Functional in jdk.jpackage.internal.util.function package and moved internal classes to outer level
    alexeysemenyukoracle committed Nov 16, 2024
    Copy the full SHA
    3444966 View commit details
  2. Copy the full SHA
    dc5a0cd View commit details
  3. Applied blessed-modifier-order.sh

    alexeysemenyukoracle committed Nov 16, 2024
    Copy the full SHA
    211f3b9 View commit details
  4. Fix bad merge

    alexeysemenyukoracle committed Nov 16, 2024
    Copy the full SHA
    01f6c74 View commit details
  5. Clear trailing whitespaces

    alexeysemenyukoracle committed Nov 16, 2024
    Copy the full SHA
    0f739f5 View commit details
  6. Remove references to AppImageFile, PackageFile, and ApplicationLayout…

    … internal jpackage classes from the tests
    alexeysemenyukoracle committed Nov 16, 2024
    Copy the full SHA
    8267daf View commit details
  7. Copy the full SHA
    e1ef473 View commit details
  8. Copy the full SHA
    1a42cd3 View commit details
  9. Fix imports

    alexeysemenyukoracle committed Nov 16, 2024
    Copy the full SHA
    2b2d481 View commit details
  10. Copy the full SHA
    8c3be92 View commit details
  11. Copy the full SHA
    c58b658 View commit details
  12. Copy the full SHA
    60e1718 View commit details
  13. Fix bad merge

    alexeysemenyukoracle committed Nov 16, 2024
    Copy the full SHA
    2b12b28 View commit details

Commits on Nov 19, 2024

  1. Copy the full SHA
    c622233 View commit details
  2. Copy the full SHA
    b126627 View commit details
  3. Fix bad merge

    alexeysemenyukoracle committed Nov 19, 2024
    Copy the full SHA
    57a2cd6 View commit details
  4. Revert "Get rid of FunctionalUtils.java". Brings back Functional.java…

    … to make the diff easier to digest. It will be replaced with redoing c58b658 commit in the next PR.
    
    This reverts commit c58b658.
    alexeysemenyukoracle committed Nov 19, 2024
    Copy the full SHA
    aac1973 View commit details
  5. Copy the full SHA
    6345483 View commit details
  6. Bad merge fix

    alexeysemenyukoracle committed Nov 19, 2024
    Copy the full SHA
    fa0ba3e View commit details
  7. Bad merge fix

    alexeysemenyukoracle committed Nov 19, 2024
    Copy the full SHA
    f91b850 View commit details
  8. Copy the full SHA
    a9bdbea View commit details
  9. Bugfix & cleanup

    alexeysemenyukoracle committed Nov 19, 2024
    Copy the full SHA
    b7f4de7 View commit details
  10. Make IOUtils class package-private

    alexeysemenyukoracle committed Nov 19, 2024
    Copy the full SHA
    a0b9595 View commit details
  11. Minor improvements

    alexeysemenyukoracle committed Nov 19, 2024
    Copy the full SHA
    9d1f097 View commit details
Showing with 320 additions and 93 deletions.
  1. +1 −1 src/jdk.jpackage/share/classes/jdk/jpackage/internal/AppImageFile.java
  2. +1 −1 src/jdk.jpackage/share/classes/jdk/jpackage/internal/IOUtils.java
  3. +1 −1 src/jdk.jpackage/share/classes/jdk/jpackage/internal/PackageFile.java
  4. +4 −5 src/jdk.jpackage/share/classes/jdk/jpackage/internal/util/PathUtils.java
  5. +1 −2 src/jdk.jpackage/share/classes/jdk/jpackage/internal/util/XmlUtils.java
  6. +122 −0 test/jdk/tools/jpackage/helpers/jdk/jpackage/test/AppImageFile.java
  7. +126 −0 test/jdk/tools/jpackage/helpers/jdk/jpackage/test/ApplicationLayout.java
  8. +0 −1 test/jdk/tools/jpackage/helpers/jdk/jpackage/test/Functional.java
  9. +12 −51 test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JPackageCommand.java
  10. +0 −1 test/jdk/tools/jpackage/helpers/jdk/jpackage/test/LinuxHelper.java
  11. +37 −0 test/jdk/tools/jpackage/helpers/jdk/jpackage/test/PackageFile.java
  12. +0 −1 test/jdk/tools/jpackage/helpers/jdk/jpackage/test/PackageTest.java
  13. +1 −1 test/jdk/tools/jpackage/macosx/SigningPackageFromTwoStepAppImageTest.java
  14. +1 −1 test/jdk/tools/jpackage/macosx/SigningPackageTest.java
  15. +1 −1 test/jdk/tools/jpackage/macosx/SigningPackageTwoStepTest.java
  16. +2 −2 test/jdk/tools/jpackage/share/AppImagePackageTest.java
  17. +2 −9 test/jdk/tools/jpackage/share/AppVersionTest.java
  18. +3 −3 test/jdk/tools/jpackage/share/InOutPathTest.java
  19. +2 −10 test/jdk/tools/jpackage/share/ModulePathTest3.java
  20. +2 −1 test/jdk/tools/jpackage/share/PredefinedAppImageErrorTest.java
  21. +1 −1 test/jdk/tools/jpackage/share/RuntimeImageSymbolicLinksTest.java
Original file line number Diff line number Diff line change
@@ -61,7 +61,7 @@
import static jdk.jpackage.internal.StandardBundlerParam.APP_STORE;
import jdk.jpackage.internal.util.XmlUtils;

public final class AppImageFile {
final class AppImageFile {

// These values will be loaded from AppImage xml file.
private final String appVersion;
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@
*
* A collection of static utility methods.
*/
public class IOUtils {
final class IOUtils {

public static void copyFile(Path sourceFile, Path destFile)
throws IOException {
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@
import java.util.Objects;
import java.util.Optional;

public final class PackageFile {
final class PackageFile {

/**
* Returns path to package file.
Original file line number Diff line number Diff line change
@@ -26,24 +26,23 @@

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());
String filename = replaceSuffix(path.getFileName(), null).toString();
return path.getFileName().toString().substring(filename.length());
}

public static Path addSuffix(Path path, String suffix) {
Path parent = path.getParent();
String filename = IOUtils.getFileName(path).toString() + suffix;
String filename = path.getFileName().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("\\.[^.]*$",
String filename = path.getFileName().toString().replaceAll("\\.[^.]*$",
"") + Optional.ofNullable(suffix).orElse("");
return parent != null ? parent.resolve(filename) : Path.of(filename);
}
Original file line number Diff line number Diff line change
@@ -39,15 +39,14 @@
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));
Files.createDirectories(dstFile.getParent());
try (Writer w = Files.newBufferedWriter(dstFile)) {
// Wrap with pretty print proxy
XMLStreamWriter xml = (XMLStreamWriter) Proxy.newProxyInstance(XMLStreamWriter.class.getClassLoader(),
122 changes: 122 additions & 0 deletions test/jdk/tools/jpackage/helpers/jdk/jpackage/test/AppImageFile.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
/*
* 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.test;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Map;
import java.util.Optional;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathFactory;
import jdk.internal.util.OperatingSystem;
import jdk.jpackage.internal.util.XmlUtils;
import static jdk.jpackage.internal.util.function.ThrowingSupplier.toSupplier;
import org.w3c.dom.Document;

public record AppImageFile(String mainLauncherName, String mainLauncherClassName,
String version, boolean macSigned, boolean macAppStore) {

public static Path getPathInAppImage(Path appImageDir) {
return ApplicationLayout.platformAppImage()
.resolveAt(appImageDir)
.appDirectory()
.resolve(FILENAME);
}

public AppImageFile(String mainLauncherName, String mainLauncherClassName) {
this(mainLauncherName, mainLauncherClassName, "1.0", false, false);
}

public void save(Path appImageDir) throws IOException {
XmlUtils.createXml(getPathInAppImage(appImageDir), xml -> {
xml.writeStartElement("jpackage-state");
xml.writeAttribute("version", getVersion());
xml.writeAttribute("platform", getPlatform());

xml.writeStartElement("app-version");
xml.writeCharacters(version);
xml.writeEndElement();

xml.writeStartElement("main-launcher");
xml.writeCharacters(mainLauncherName);
xml.writeEndElement();

xml.writeStartElement("main-class");
xml.writeCharacters(mainLauncherClassName);
xml.writeEndElement();

xml.writeStartElement("signed");
xml.writeCharacters(Boolean.toString(macSigned));
xml.writeEndElement();

xml.writeStartElement("app-store");
xml.writeCharacters(Boolean.toString(macAppStore));
xml.writeEndElement();
});
}

public static AppImageFile load(Path appImageDir) {
return toSupplier(() -> {
Document doc = XmlUtils.initDocumentBuilder().parse(
Files.newInputStream(getPathInAppImage(appImageDir)));

XPath xPath = XPathFactory.newInstance().newXPath();

var version = xPath.evaluate("/jpackage-state/app-version/text()", doc);

var mainLauncherName = xPath.evaluate(
"/jpackage-state/main-launcher/text()", doc);

var mainLauncherClassName = xPath.evaluate(
"/jpackage-state/main-class/text()", doc);

var macSigned = Optional.ofNullable(xPath.evaluate(
"/jpackage-state/signed/text()", doc)).map(
Boolean::parseBoolean).orElse(false);

var macAppStore = Optional.ofNullable(xPath.evaluate(
"/jpackage-state/app-store/text()", doc)).map(
Boolean::parseBoolean).orElse(false);

return new AppImageFile(mainLauncherName, mainLauncherClassName,
version, macSigned, macAppStore);

}).get();
}

private static String getVersion() {
return System.getProperty("java.version");
}

private static String getPlatform() {
return PLATFORM_LABELS.get(OperatingSystem.current());
}

private static final String FILENAME = ".jpackage.xml";

private static final Map<OperatingSystem, String> PLATFORM_LABELS = Map.of(
OperatingSystem.LINUX, "linux",
OperatingSystem.WINDOWS, "windows",
OperatingSystem.MACOS, "macOS");
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
/*
* 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.test;

import java.nio.file.Path;
import java.util.Optional;

public record ApplicationLayout(Path launchersDirectory, Path appDirectory,
Path runtimeDirectory, Path runtimeHomeDirectory, Path appModsDirectory,
Path destktopIntegrationDirectory, Path contentDirectory) {

public ApplicationLayout resolveAt(Path root) {
return new ApplicationLayout(
resolve(root, launchersDirectory),
resolve(root, appDirectory),
resolve(root, runtimeDirectory),
resolve(root, runtimeHomeDirectory),
resolve(root, appModsDirectory),
resolve(root, destktopIntegrationDirectory),
resolve(root, contentDirectory));
}

public static ApplicationLayout linuxAppImage() {
return new ApplicationLayout(
Path.of("bin"),
Path.of("lib/app"),
Path.of("lib/runtime"),
Path.of("lib/runtime"),
Path.of("lib/app/mods"),
Path.of("lib"),
Path.of("lib")
);
}

public static ApplicationLayout windowsAppImage() {
return new ApplicationLayout(
Path.of(""),
Path.of("app"),
Path.of("runtime"),
Path.of("runtime"),
Path.of("app/mods"),
Path.of(""),
Path.of("")
);
}

public static ApplicationLayout macAppImage() {
return new ApplicationLayout(
Path.of("Contents/MacOS"),
Path.of("Contents/app"),
Path.of("Contents/runtime"),
Path.of("Contents/runtime/Contents/Home"),
Path.of("Contents/app/mods"),
Path.of("Contents/Resources"),
Path.of("Contents")
);
}

public static ApplicationLayout platformAppImage() {
if (TKit.isWindows()) {
return windowsAppImage();
}

if (TKit.isLinux()) {
return linuxAppImage();
}

if (TKit.isOSX()) {
return macAppImage();
}

throw new IllegalArgumentException("Unknown platform");
}

public static ApplicationLayout javaRuntime() {
return new ApplicationLayout(
null,
null,
Path.of(""),
null,
null,
null,
null
);
}

public static ApplicationLayout linuxUsrTreePackageImage(Path prefix,
String packageName) {
final Path lib = prefix.resolve(Path.of("lib", packageName));
return new ApplicationLayout(
prefix.resolve("bin"),
lib.resolve("app"),
lib.resolve("runtime"),
lib.resolve("runtime"),
lib.resolve("app/mods"),
lib,
lib
);
}

private static Path resolve(Path base, Path path) {
return Optional.ofNullable(path).map(base::resolve).orElse(null);
}
}
Original file line number Diff line number Diff line change
@@ -22,7 +22,6 @@
*/
package jdk.jpackage.test;

import java.lang.reflect.InvocationTargetException;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
Loading