Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/actions/build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@ runs:
COMMERCIAL_REPO_USERNAME: ${{ inputs.commercial-repository-username }}
COMMERCIAL_SNAPSHOT_REPO_URL: ${{ inputs.commercial-snapshot-repository-url }}
run: ./gradlew build
- name: Sanity Check
id: sanity
if: ${{ inputs.publish == 'false' }}
shell: bash
env:
COMMERCIAL_RELEASE_REPO_URL: ${{ inputs.commercial-release-repository-url }}
COMMERCIAL_REPO_PASSWORD: ${{ inputs.commercial-repository-password }}
COMMERCIAL_REPO_USERNAME: ${{ inputs.commercial-repository-username }}
COMMERCIAL_SNAPSHOT_REPO_URL: ${{ inputs.commercial-snapshot-repository-url }}
run: ./gradlew rewriteDryRun -Dorg.gradle.jvmargs=-Xmx12G
- name: Publish
id: publish
if: ${{ inputs.publish == 'true' }}
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/build-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ jobs:
- name: Build
id: build
uses: ./.github/actions/build
- name: Sanity
id: sanity
uses: ./.github/actions/build
- name: Print JVM Thread Dumps When Cancelled
if: cancelled()
uses: ./.github/actions/print-jvm-thread-dumps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,8 @@ void buildsImageWithBindCaches() throws IOException {
assertThat(result.getOutput()).contains("---> Test Info buildpack done");
removeImages(projectName);
String tempDir = System.getProperty("java.io.tmpdir");
Path buildCachePath = Paths.get(tempDir, "junit-image-cache-" + projectName + "-build");
Path launchCachePath = Paths.get(tempDir, "junit-image-cache-" + projectName + "-launch");
Path buildCachePath = Path.of(tempDir, "junit-image-cache-" + projectName + "-build");
Path launchCachePath = Path.of(tempDir, "junit-image-cache-" + projectName + "-launch");
assertThat(buildCachePath).exists().isDirectory();
assertThat(launchCachePath).exists().isDirectory();
cleanupCache(buildCachePath);
Expand Down Expand Up @@ -595,7 +595,7 @@ private void writeLongNameResource() throws IOException {
new Random().ints('a', 'z' + 1).limit(128).forEach((i) -> name.append((char) i));
Path path = this.gradleBuild.getProjectDir()
.toPath()
.resolve(Paths.get("src", "main", "resources", name.toString()));
.resolve(Path.of("src", "main", "resources", name.toString()));
Files.createDirectories(path.getParent());
Files.createFile(path);
}
Expand All @@ -620,13 +620,13 @@ private void writeBuildpackContent() throws IOException {
writer.println("[[stacks]]\n");
writer.println("id = \"*\"");
}
File detect = Files.createFile(Paths.get(binDir.getAbsolutePath(), "detect"), execFileAttribute).toFile();
File detect = Files.createFile(Path.of(binDir.getAbsolutePath(), "detect"), execFileAttribute).toFile();
try (PrintWriter writer = new PrintWriter(new FileWriter(detect))) {
writer.println("#!/usr/bin/env bash");
writer.println("set -eo pipefail");
writer.println("exit 0");
}
File build = Files.createFile(Paths.get(binDir.getAbsolutePath(), "build"), execFileAttribute).toFile();
File build = Files.createFile(Path.of(binDir.getAbsolutePath(), "build"), execFileAttribute).toFile();
try (PrintWriter writer = new PrintWriter(new FileWriter(build))) {
writer.println("#!/usr/bin/env bash");
writer.println("set -eo pipefail");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import java.io.StringReader;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Enumeration;
Expand Down Expand Up @@ -725,7 +724,7 @@ private void writeResource() {
try {
Path path = this.gradleBuild.getProjectDir()
.toPath()
.resolve(Paths.get("src", "main", "resources", "static", "file.txt"));
.resolve(Path.of("src", "main", "resources", "static", "file.txt"));
Files.createDirectories(path.getParent());
Files.createFile(path);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.OffsetDateTime;
import java.util.Random;
import java.util.stream.IntStream;
Expand Down Expand Up @@ -455,8 +454,8 @@ void whenBuildImageIsInvokedWithBindCaches(MavenBuild mavenBuild) {
.contains("Successfully built image");
removeImage("build-image-bind-caches", "0.0.1.BUILD-SNAPSHOT");
String tempDir = System.getProperty("java.io.tmpdir");
Path buildCachePath = Paths.get(tempDir, "junit-image-cache-" + testBuildId + "-build");
Path launchCachePath = Paths.get(tempDir, "junit-image-cache-" + testBuildId + "-launch");
Path buildCachePath = Path.of(tempDir, "junit-image-cache-" + testBuildId + "-build");
Path launchCachePath = Path.of(tempDir, "junit-image-cache-" + testBuildId + "-launch");
assertThat(buildCachePath).exists().isDirectory();
assertThat(launchCachePath).exists().isDirectory();
cleanupCache(buildCachePath);
Expand Down Expand Up @@ -627,7 +626,7 @@ private void writeLongNameResource(File project) {
StringBuilder name = new StringBuilder();
new Random().ints('a', 'z' + 1).limit(128).forEach((i) -> name.append((char) i));
try {
Path path = project.toPath().resolve(Paths.get("src", "main", "resources", name.toString()));
Path path = project.toPath().resolve(Path.of("src", "main", "resources", name.toString()));
Files.createDirectories(path.getParent());
Files.createFile(path);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.StandardCopyOption;
import java.nio.file.StandardOpenOption;
Expand Down Expand Up @@ -163,7 +162,7 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IO
}

});
String settingsXml = Files.readString(Paths.get("build", "generated-resources", "settings", "settings.xml"))
String settingsXml = Files.readString(Path.of("build", "generated-resources", "settings", "settings.xml"))
.replace("@localCentralUrl@", new File("build/test-maven-repository").toURI().toURL().toString())
.replace("@localRepositoryPath@", new File("build/local-maven-repository").getAbsolutePath());
Files.writeString(destination.resolve("settings.xml"), settingsXml, StandardOpenOption.CREATE_NEW);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Stream;
Expand Down Expand Up @@ -49,7 +48,7 @@ public Stream<TestTemplateInvocationContext> provideTestTemplateInvocationContex
try {
// Returning a stream which must be closed here is fine, as JUnit will take
// care of closing it
return Files.list(Paths.get("build/maven-binaries")).map(MavenVersionTestTemplateInvocationContext::new);
return Files.list(Path.of("build/maven-binaries")).map(MavenVersionTestTemplateInvocationContext::new);
}
catch (IOException ex) {
throw new RuntimeException(ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.nio.charset.UnsupportedCharsetException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -139,7 +138,7 @@ private static boolean isWindows(UnaryOperator<@Nullable String> getSystemProper

private static String toPathString(URL url) {
try {
return Paths.get(url.toURI()).toString();
return Path.of(url.toURI()).toString();
}
catch (URISyntaxException ex) {
throw new IllegalArgumentException(ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Collections;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -66,7 +65,7 @@ void argsWhenMultipleUrlsOnWindowsAndAllowedUsesArgFile(@TempDir Path temp) thro
List<String> args = classPath.args(true);
assertThat(args.get(0)).isEqualTo("-cp");
assertThat(args.get(1)).startsWith("@");
assertThat(Paths.get(args.get(1).substring(1)))
assertThat(Path.of(args.get(1).substring(1)))
.hasContent("\"" + (path1 + File.pathSeparator + path2).replace("\\", "\\\\") + "\"");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -115,7 +114,7 @@ void buildWithClassPathOnWindows(@TempDir Path tempDir) throws Exception {
assertThat(args.get(0)).isEqualTo("-cp");
assertThat(args.get(1)).startsWith("@");
assertThat(args.get(2)).isEqualTo(CLASS_NAME);
assertThat(Paths.get(args.get(1).substring(1)))
assertThat(Path.of(args.get(1).substring(1)))
.hasContent("\"" + (file + File.pathSeparator + file1).replace("\\", "\\\\") + "\"");
}

Expand All @@ -140,7 +139,7 @@ void buildAndRunWithLongClassPath() throws IOException, InterruptedException {

private URL toURL(String path) {
try {
return Paths.get(path).toUri().toURL();
return Path.of(path).toUri().toURL();
}
catch (MalformedURLException ex) {
throw new RuntimeException(ex);
Expand Down
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

plugins {
id "base"
id "org.openrewrite.rewrite" version "7.23.0" apply false
}

description = "Spring Boot Build"
Expand Down Expand Up @@ -46,3 +47,5 @@ subprojects {
resolutionStrategy.cacheChangingModulesFor 0, "minutes"
}
}

apply from: rootProject.file("gradle/plugins/config/sanity.gradle")
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Path;
import java.nio.file.Paths;

import org.jspecify.annotations.Nullable;

Expand Down Expand Up @@ -54,15 +53,15 @@ boolean hasPrefix(String prefix) {
try {
URL url = new URL(this.value);
if (url.getProtocol().equals("file")) {
return Paths.get(url.toURI());
return Path.of(url.toURI());
}
return null;
}
catch (MalformedURLException | URISyntaxException ex) {
// not a URL, fall through to attempting to find a plain file path
}
try {
return Paths.get(this.value);
return Path.of(this.value);
}
catch (Exception ex) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;

Expand Down Expand Up @@ -82,7 +81,7 @@ public void apply(IOConsumer<Layer> layers) throws IOException {

private void addLayerContent(Layout layout) throws IOException {
String id = this.coordinates.getSanitizedId();
Path cnbPath = Paths.get("/cnb/buildpacks/", id, this.coordinates.getVersion());
Path cnbPath = Path.of("/cnb/buildpacks/", id, this.coordinates.getVersion());
writeBasePathEntries(layout, cnbPath);
Files.walkFileTree(this.path, new LayoutFileVisitor(this.path, cnbPath, layout));
}
Expand Down Expand Up @@ -152,7 +151,7 @@ private int getMode(Path path) throws IOException {

private String relocate(Path path) {
Path node = path.subpath(this.basePath.getNameCount(), path.getNameCount());
return Paths.get(this.layerPath.toString(), node.toString()).toString();
return Path.of(this.layerPath.toString(), node.toString()).toString();
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

import org.apache.commons.compress.archivers.ArchiveEntry;
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
Expand Down Expand Up @@ -86,7 +85,7 @@ public void apply(IOConsumer<Layer> layers) throws IOException {

private void copyAndRebaseEntries(OutputStream outputStream) throws IOException {
String id = this.coordinates.getSanitizedId();
Path basePath = Paths.get("/cnb/buildpacks/", id, this.coordinates.getVersion());
Path basePath = Path.of("/cnb/buildpacks/", id, this.coordinates.getVersion());
try (TarArchiveInputStream tar = new TarArchiveInputStream(
new GzipCompressorInputStream(Files.newInputStream(this.path)));
TarArchiveOutputStream output = new TarArchiveOutputStream(outputStream)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package org.springframework.boot.buildpack.platform.docker.configuration;

import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.Path;

import com.sun.jna.Platform;
import org.jspecify.annotations.Nullable;
Expand Down Expand Up @@ -70,7 +70,7 @@ public boolean isRemote() {

public boolean isLocalFileReference() {
try {
return Files.exists(Paths.get(getAddress()));
return Files.exists(Path.of(getAddress()));
}
catch (Exception ex) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
Expand Down Expand Up @@ -53,10 +52,10 @@ public SslContextFactory() {
*/
public SSLContext forDirectory(String directory) {
try {
Path keyPath = Paths.get(directory, "key.pem");
Path certPath = Paths.get(directory, "cert.pem");
Path caPath = Paths.get(directory, "ca.pem");
Path caKeyPath = Paths.get(directory, "ca-key.pem");
Path keyPath = Path.of(directory, "key.pem");
Path certPath = Path.of(directory, "cert.pem");
Path caPath = Path.of(directory, "ca.pem");
Path caKeyPath = Path.of(directory, "ca-key.pem");
verifyCertificateFiles(keyPath, certPath, caPath);
KeyManagerFactory keyManagerFactory = getKeyManagerFactory(keyPath, certPath);
TrustManagerFactory trustManagerFactory = getTrustManagerFactory(caPath, caKeyPath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import java.nio.channels.Channels;
import java.nio.channels.CompletionHandler;
import java.nio.file.FileSystemException;
import java.nio.file.Paths;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Future;
Expand Down Expand Up @@ -62,7 +62,7 @@ private AsynchronousFileByteChannel open(String path) throws IOException {
long startTime = System.nanoTime();
while (true) {
try {
return new AsynchronousFileByteChannel(AsynchronousFileChannel.open(Paths.get(path),
return new AsynchronousFileByteChannel(AsynchronousFileChannel.open(Path.of(path),
StandardOpenOption.READ, StandardOpenOption.WRITE));
}
catch (FileSystemException ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.nio.file.Paths;

import org.jspecify.annotations.Nullable;
import org.junit.jupiter.api.Test;
Expand All @@ -39,7 +38,7 @@
*/
class BuildpackCoordinatesTests extends AbstractJsonTests {

private final Path archive = Paths.get("/buildpack/path");
private final Path archive = Path.of("/buildpack/path");

@Test
void fromToml() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package org.springframework.boot.buildpack.platform.build;

import java.nio.file.Paths;
import java.nio.file.Path;

import org.junit.jupiter.api.Test;

Expand Down Expand Up @@ -84,13 +84,13 @@ void getSubReferenceWhenPrefixMismatchReturnsNull() {
@Test
void asPathWhenFileUrlReturnsPath() {
BuildpackReference reference = BuildpackReference.of("file:///test.dat");
assertThat(reference.asPath()).isEqualTo(Paths.get("/test.dat"));
assertThat(reference.asPath()).isEqualTo(Path.of("/test.dat"));
}

@Test
void asPathWhenPathReturnsPath() {
BuildpackReference reference = BuildpackReference.of("/test.dat");
assertThat(reference.asPath()).isEqualTo(Paths.get("/test.dat"));
assertThat(reference.asPath()).isEqualTo(Path.of("/test.dat"));
}

}
Loading