From 4733c6dcaa8fe1da3efbe8a164036207f92b1d8d Mon Sep 17 00:00:00 2001 From: Vincent Potucek Date: Wed, 24 Sep 2025 13:55:05 +0200 Subject: [PATCH] Issue #2634: Add `Java8toJava11` --- .github/workflows/ci.yml | 8 +++++--- CHANGES.md | 1 + build.gradle | 6 ++++++ gradle/rewrite.gradle | 7 +++++++ .../java/com/diffplug/spotless/biome/BiomeStep.java | 9 ++++----- .../com/diffplug/spotless/java/ImportSorterImpl.java | 12 ++++++++++-- .../com/diffplug/spotless/kotlin/DiktatStep.java | 10 +++++++--- .../java/com/diffplug/spotless/npm/FileFinder.java | 10 ++++++---- .../com/diffplug/spotless/npm/NpmResourceHelper.java | 9 ++++++--- .../java/com/diffplug/spotless/npm/ShadowCopy.java | 7 +++---- .../diffplug/spotless/npm/TsFmtFormatterStep.java | 9 +++++---- .../compat/KtLintCompat0Dot48Dot0AdapterTest.java | 7 +++---- .../compat/KtLintCompat0Dot49Dot0AdapterTest.java | 7 +++---- .../compat/KtLintCompat0Dot50Dot0AdapterTest.java | 7 +++---- .../compat/KtLintCompat1Dot0Dot0AdapterTest.java | 7 +++---- .../diffplug/gradle/spotless/BiomeStepConfig.java | 4 ++-- .../gradle/spotless/SpotlessDiagnoseTask.java | 3 +-- .../spotless/NpmInstallCacheIntegrationTests.java | 6 +++--- .../gradle/spotless/SpotlessTaskImplTest.java | 8 ++++---- plugin-maven/build.gradle | 2 ++ .../com/diffplug/spotless/maven/FileLocator.java | 5 ++--- .../com/diffplug/spotless/maven/GitRatchetMaven.java | 7 +++---- .../spotless/maven/generic/AbstractBiome.java | 4 ++-- .../diffplug/spotless/maven/generic/Prettier.java | 9 +++++++-- .../spotless/maven/incremental/FileIndex.java | 8 +++----- .../maven/npm/AbstractNpmFormatterStepFactory.java | 6 +++--- .../com/diffplug/spotless/maven/FileLocatorTest.java | 8 ++++---- .../diffplug/spotless/maven/SpecificFilesTest.java | 7 +++---- .../maven/incremental/FileIndexConfigTest.java | 7 +++---- .../spotless/maven/incremental/FileIndexTest.java | 7 +++---- .../maven/npm/NpmStepsWithNpmInstallCacheTest.java | 7 +++---- settings.gradle | 1 + .../com/diffplug/spotless/biome/BiomeStepTest.java | 3 +-- 33 files changed, 122 insertions(+), 96 deletions(-) create mode 100644 gradle/rewrite.gradle diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9ef9b7582b..2e1ce0ea03 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ concurrency: cancel-in-progress: true jobs: sanityCheck: - name: spotlessCheck assemble testClasses + name: spotlessCheck rewriteDryRun assemble testClasses runs-on: ubuntu-latest env: buildcacheuser: ${{ secrets.BUILDCACHE_USER }} @@ -31,6 +31,8 @@ jobs: uses: gradle/actions/setup-gradle@v4 - name: spotlessCheck run: ./gradlew spotlessCheck + - name: rewriteDryRun + run: ./gradlew rewriteDryRun - name: assemble testClasses run: ./gradlew assemble testClasses build: @@ -66,10 +68,10 @@ jobs: uses: gradle/actions/setup-gradle@v4 - name: build (maven-only) if: matrix.kind == 'maven' - run: ./gradlew :plugin-maven:build -x spotlessCheck + run: ./gradlew :plugin-maven:build -x spotlessCheck -x rewriteDryRun - name: build (everything-but-maven) if: matrix.kind == 'gradle' - run: ./gradlew build -x spotlessCheck -PSPOTLESS_EXCLUDE_MAVEN=true + run: ./gradlew build -x spotlessCheck -x rewriteDryRun -PSPOTLESS_EXCLUDE_MAVEN=true - name: test npm if: matrix.kind == 'npm' run: ./gradlew testNpm diff --git a/CHANGES.md b/CHANGES.md index 38b36ca7b4..891199c124 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -27,6 +27,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format ( ### Added * Add a `lint` mode to `ReplaceRegexStep` ([#2571](https://github.com/diffplug/spotless/pull/2571)) * `LintSuppression` now enforces unix-style paths in its `setPath` and `relativizeAsUnix` methods. ([#2629](https://github.com/diffplug/spotless/pull/2629)) +* Add `rewrite` support ([#2588](https://github.com/diffplug/spotless/pull/2588)) ## [3.3.1] - 2025-07-21 ### Fixed diff --git a/build.gradle b/build.gradle index fafd6abe43..042a7c9647 100644 --- a/build.gradle +++ b/build.gradle @@ -12,6 +12,7 @@ repositories { apply from: rootProject.file('gradle/java-publish.gradle') apply from: rootProject.file('gradle/changelog.gradle') allprojects { + apply from: rootProject.file('gradle/rewrite.gradle') apply from: rootProject.file('gradle/spotless.gradle') } apply from: rootProject.file('gradle/spotless-freshmark.gradle') @@ -27,3 +28,8 @@ spotless { endWithNewline() } } + +dependencies { + rewrite(platform("org.openrewrite.recipe:rewrite-recipe-bom:3.14.1")) + rewrite("org.openrewrite.recipe:rewrite-migrate-java:3.17.1") +} diff --git a/gradle/rewrite.gradle b/gradle/rewrite.gradle new file mode 100644 index 0000000000..5ce759ef31 --- /dev/null +++ b/gradle/rewrite.gradle @@ -0,0 +1,7 @@ +apply plugin: 'org.openrewrite.rewrite' + +rewrite { + activeRecipe("org.openrewrite.java.migrate.Java8toJava11") + exportDatatables = true + failOnDryRunResults = true +} diff --git a/lib/src/main/java/com/diffplug/spotless/biome/BiomeStep.java b/lib/src/main/java/com/diffplug/spotless/biome/BiomeStep.java index 2ebb9d75c5..9b580ead51 100644 --- a/lib/src/main/java/com/diffplug/spotless/biome/BiomeStep.java +++ b/lib/src/main/java/com/diffplug/spotless/biome/BiomeStep.java @@ -22,7 +22,6 @@ import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.nio.file.attribute.PosixFilePermission; import java.util.ArrayList; import java.util.Collections; @@ -161,7 +160,7 @@ private static String defaultVersion() { * @param filePath Path to the file to make executable. */ private static void makeExecutable(String filePath) { - var exePath = Paths.get(filePath); + var exePath = Path.of(filePath); attemptToAddPosixPermission(exePath, PosixFilePermission.GROUP_EXECUTE); attemptToAddPosixPermission(exePath, PosixFilePermission.OTHERS_EXECUTE); attemptToAddPosixPermission(exePath, PosixFilePermission.OWNER_EXECUTE); @@ -199,7 +198,7 @@ private static void validateBiomeConfigPath(String configPath, String version) { return; } var atLeastV2 = BiomeSettings.versionHigherThanOrEqualTo(version, 2, 0, 0); - var path = Paths.get(configPath); + var path = Path.of(configPath); var configFile = Files.isRegularFile(path) && atLeastV2 ? path : path.resolve(BiomeSettings.configName()); if (!Files.exists(path)) { throw new IllegalArgumentException("Biome config directory does not exist: " + path); @@ -323,13 +322,13 @@ private State createState() throws IOException, InterruptedException { private String resolveExe() throws IOException, InterruptedException { new ForeignExe(); if (pathToExe != null) { - if (Paths.get(pathToExe).getNameCount() == 1) { + if (Path.of(pathToExe).getNameCount() == 1) { return resolveNameAgainstPath(pathToExe); } else { return pathToExe; } } else { - var downloader = new BiomeExecutableDownloader(Paths.get(downloadDir)); + var downloader = new BiomeExecutableDownloader(Path.of(downloadDir)); var downloaded = downloader.ensureDownloaded(version).toString(); makeExecutable(downloaded); return downloaded; diff --git a/lib/src/main/java/com/diffplug/spotless/java/ImportSorterImpl.java b/lib/src/main/java/com/diffplug/spotless/java/ImportSorterImpl.java index 4393de95a3..dbaaac9be2 100644 --- a/lib/src/main/java/com/diffplug/spotless/java/ImportSorterImpl.java +++ b/lib/src/main/java/com/diffplug/spotless/java/ImportSorterImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2024 DiffPlug + * Copyright 2016-2025 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,15 @@ package com.diffplug.spotless.java; import java.io.Serializable; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Comparator; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; diff --git a/lib/src/main/java/com/diffplug/spotless/kotlin/DiktatStep.java b/lib/src/main/java/com/diffplug/spotless/kotlin/DiktatStep.java index daf101d9ce..7c99ab1c19 100644 --- a/lib/src/main/java/com/diffplug/spotless/kotlin/DiktatStep.java +++ b/lib/src/main/java/com/diffplug/spotless/kotlin/DiktatStep.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2024 DiffPlug + * Copyright 2021-2025 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,11 +18,15 @@ import java.io.File; import java.io.Serializable; import java.lang.reflect.Constructor; -import java.util.*; +import java.util.Objects; import javax.annotation.Nullable; -import com.diffplug.spotless.*; +import com.diffplug.spotless.FileSignature; +import com.diffplug.spotless.FormatterFunc; +import com.diffplug.spotless.FormatterStep; +import com.diffplug.spotless.JarState; +import com.diffplug.spotless.Provisioner; /** Wraps up diktat as a FormatterStep. */ public class DiktatStep implements Serializable { diff --git a/lib/src/main/java/com/diffplug/spotless/npm/FileFinder.java b/lib/src/main/java/com/diffplug/spotless/npm/FileFinder.java index fce1497de6..d674621261 100644 --- a/lib/src/main/java/com/diffplug/spotless/npm/FileFinder.java +++ b/lib/src/main/java/com/diffplug/spotless/npm/FileFinder.java @@ -1,5 +1,5 @@ /* - * Copyright 2020-2023 DiffPlug + * Copyright 2020-2025 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,10 @@ import static java.util.Objects.requireNonNull; import java.io.File; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Optional; import java.util.function.Function; import java.util.function.Predicate; import java.util.function.Supplier; @@ -43,8 +46,7 @@ Optional tryFind() { return fileCandidateFinders .stream() .map(Supplier::get) - .filter(Optional::isPresent) - .map(Optional::get) + .flatMap(Optional::stream) .findFirst(); } diff --git a/lib/src/main/java/com/diffplug/spotless/npm/NpmResourceHelper.java b/lib/src/main/java/com/diffplug/spotless/npm/NpmResourceHelper.java index 3c146cd315..85bbc48305 100644 --- a/lib/src/main/java/com/diffplug/spotless/npm/NpmResourceHelper.java +++ b/lib/src/main/java/com/diffplug/spotless/npm/NpmResourceHelper.java @@ -15,11 +15,14 @@ */ package com.diffplug.spotless.npm; -import java.io.*; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.nio.file.StandardCopyOption; import java.security.MessageDigest; import java.time.Duration; @@ -130,7 +133,7 @@ static File copyFileToDirAtSubpath(File file, File targetDir, String relativePat Objects.requireNonNull(relativePath); try { // create file pointing to relativePath in targetDir - final Path relativeTargetFile = Paths.get(targetDir.getAbsolutePath(), relativePath); + final Path relativeTargetFile = Path.of(targetDir.getAbsolutePath(), relativePath); assertDirectoryExists(relativeTargetFile.getParent().toFile()); Files.copy(file.toPath(), relativeTargetFile, StandardCopyOption.REPLACE_EXISTING); diff --git a/lib/src/main/java/com/diffplug/spotless/npm/ShadowCopy.java b/lib/src/main/java/com/diffplug/spotless/npm/ShadowCopy.java index 3182d81fbb..6adf3a28dd 100644 --- a/lib/src/main/java/com/diffplug/spotless/npm/ShadowCopy.java +++ b/lib/src/main/java/com/diffplug/spotless/npm/ShadowCopy.java @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 DiffPlug + * Copyright 2023-2025 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +24,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.attribute.BasicFileAttributes; @@ -108,11 +107,11 @@ public File getEntry(String key, String fileName) { } private File entry(String key, String origName) { - return Paths.get(shadowCopyRoot().getAbsolutePath(), key, origName).toFile(); + return Path.of(shadowCopyRoot().getAbsolutePath(), key, origName).toFile(); } public File copyEntryInto(String key, String origName, File targetParentFolder) { - File target = Paths.get(targetParentFolder.getAbsolutePath(), origName).toFile(); + File target = Path.of(targetParentFolder.getAbsolutePath(), origName).toFile(); if (target.exists()) { logger.warn("Shadow copy destination already exists, deleting! {}: {}", key, target); ThrowingEx.run(() -> Files.walkFileTree(target.toPath(), new DeleteDirectoryRecursively())); diff --git a/lib/src/main/java/com/diffplug/spotless/npm/TsFmtFormatterStep.java b/lib/src/main/java/com/diffplug/spotless/npm/TsFmtFormatterStep.java index b171b0ca7f..f013a255e6 100644 --- a/lib/src/main/java/com/diffplug/spotless/npm/TsFmtFormatterStep.java +++ b/lib/src/main/java/com/diffplug/spotless/npm/TsFmtFormatterStep.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2024 DiffPlug + * Copyright 2016-2025 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,9 @@ import java.io.File; import java.io.IOException; import java.io.Serializable; -import java.util.*; +import java.util.HashMap; +import java.util.Map; +import java.util.TreeMap; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -68,8 +70,7 @@ public static class State extends NpmFormatterStepStateBase implements Serializa private final File buildDir; - @Nullable - private final TypedTsFmtConfigFile configFile; + @Nullable private final TypedTsFmtConfigFile configFile; public State(String stepName, Map versions, File projectDir, File buildDir, File cacheDir, NpmPathResolver npmPathResolver, @Nullable TypedTsFmtConfigFile configFile, @Nullable Map inlineTsFmtSettings) throws IOException { super(stepName, diff --git a/lib/src/testCompatKtLint0Dot48Dot0/java/com/diffplug/spotless/glue/ktlint/compat/KtLintCompat0Dot48Dot0AdapterTest.java b/lib/src/testCompatKtLint0Dot48Dot0/java/com/diffplug/spotless/glue/ktlint/compat/KtLintCompat0Dot48Dot0AdapterTest.java index f9c19d69a7..97278f9ffb 100644 --- a/lib/src/testCompatKtLint0Dot48Dot0/java/com/diffplug/spotless/glue/ktlint/compat/KtLintCompat0Dot48Dot0AdapterTest.java +++ b/lib/src/testCompatKtLint0Dot48Dot0/java/com/diffplug/spotless/glue/ktlint/compat/KtLintCompat0Dot48Dot0AdapterTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 DiffPlug + * Copyright 2023-2025 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,6 @@ import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.HashMap; import java.util.Map; @@ -34,7 +33,7 @@ public class KtLintCompat0Dot48Dot0AdapterTest { public void testDefaults(@TempDir Path path) throws IOException { KtLintCompat0Dot48Dot0Adapter ktLintCompat0Dot48Dot0Adapter = new KtLintCompat0Dot48Dot0Adapter(); var content = loadAndWriteText(path, "empty_class_body.kt"); - final Path filePath = Paths.get(path.toString(), "empty_class_body.kt"); + final Path filePath = Path.of(path.toString(), "empty_class_body.kt"); Map editorConfigOverrideMap = new HashMap<>(); @@ -46,7 +45,7 @@ public void testDefaults(@TempDir Path path) throws IOException { public void testEditorConfigCanDisable(@TempDir Path path) throws IOException { KtLintCompat0Dot48Dot0Adapter ktLintCompat0Dot48Dot0Adapter = new KtLintCompat0Dot48Dot0Adapter(); var content = loadAndWriteText(path, "fails_no_semicolons.kt"); - final Path filePath = Paths.get(path.toString(), "fails_no_semicolons.kt"); + final Path filePath = Path.of(path.toString(), "fails_no_semicolons.kt"); Map editorConfigOverrideMap = new HashMap<>(); editorConfigOverrideMap.put("indent_style", "tab"); diff --git a/lib/src/testCompatKtLint0Dot49Dot0/java/com/diffplug/spotless/glue/ktlint/compat/KtLintCompat0Dot49Dot0AdapterTest.java b/lib/src/testCompatKtLint0Dot49Dot0/java/com/diffplug/spotless/glue/ktlint/compat/KtLintCompat0Dot49Dot0AdapterTest.java index 27d085f7fd..faa95c938c 100644 --- a/lib/src/testCompatKtLint0Dot49Dot0/java/com/diffplug/spotless/glue/ktlint/compat/KtLintCompat0Dot49Dot0AdapterTest.java +++ b/lib/src/testCompatKtLint0Dot49Dot0/java/com/diffplug/spotless/glue/ktlint/compat/KtLintCompat0Dot49Dot0AdapterTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 DiffPlug + * Copyright 2023-2025 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,6 @@ import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.HashMap; import java.util.Map; @@ -34,7 +33,7 @@ public class KtLintCompat0Dot49Dot0AdapterTest { public void testDefaults(@TempDir Path path) throws IOException { KtLintCompat0Dot49Dot0Adapter ktLintCompat0Dot49Dot0Adapter = new KtLintCompat0Dot49Dot0Adapter(); var content = loadAndWriteText(path, "EmptyClassBody.kt"); - final Path filePath = Paths.get(path.toString(), "EmptyClassBody.kt"); + final Path filePath = Path.of(path.toString(), "EmptyClassBody.kt"); Map editorConfigOverrideMap = new HashMap<>(); @@ -46,7 +45,7 @@ public void testDefaults(@TempDir Path path) throws IOException { public void testEditorConfigCanDisable(@TempDir Path path) throws IOException { KtLintCompat0Dot49Dot0Adapter ktLintCompat0Dot49Dot0Adapter = new KtLintCompat0Dot49Dot0Adapter(); var content = loadAndWriteText(path, "FailsNoSemicolons.kt"); - final Path filePath = Paths.get(path.toString(), "FailsNoSemicolons.kt"); + final Path filePath = Path.of(path.toString(), "FailsNoSemicolons.kt"); Map editorConfigOverrideMap = new HashMap<>(); editorConfigOverrideMap.put("indent_style", "tab"); diff --git a/lib/src/testCompatKtLint0Dot50Dot0/java/com/diffplug/spotless/glue/ktlint/compat/KtLintCompat0Dot50Dot0AdapterTest.java b/lib/src/testCompatKtLint0Dot50Dot0/java/com/diffplug/spotless/glue/ktlint/compat/KtLintCompat0Dot50Dot0AdapterTest.java index 27dce68f09..ccb5e931db 100644 --- a/lib/src/testCompatKtLint0Dot50Dot0/java/com/diffplug/spotless/glue/ktlint/compat/KtLintCompat0Dot50Dot0AdapterTest.java +++ b/lib/src/testCompatKtLint0Dot50Dot0/java/com/diffplug/spotless/glue/ktlint/compat/KtLintCompat0Dot50Dot0AdapterTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 DiffPlug + * Copyright 2023-2025 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,6 @@ import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.HashMap; import java.util.Map; @@ -34,7 +33,7 @@ public class KtLintCompat0Dot50Dot0AdapterTest { public void testDefaults(@TempDir Path path) throws IOException { KtLintCompat0Dot50Dot0Adapter KtLintCompat0Dot50Dot0Adapter = new KtLintCompat0Dot50Dot0Adapter(); var content = loadAndWriteText(path, "EmptyClassBody.kt"); - final Path filePath = Paths.get(path.toString(), "EmptyClassBody.kt"); + final Path filePath = Path.of(path.toString(), "EmptyClassBody.kt"); Map editorConfigOverrideMap = new HashMap<>(); @@ -46,7 +45,7 @@ public void testDefaults(@TempDir Path path) throws IOException { public void testEditorConfigCanDisable(@TempDir Path path) throws IOException { KtLintCompat0Dot50Dot0Adapter KtLintCompat0Dot50Dot0Adapter = new KtLintCompat0Dot50Dot0Adapter(); var content = loadAndWriteText(path, "FailsNoSemicolons.kt"); - final Path filePath = Paths.get(path.toString(), "FailsNoSemicolons.kt"); + final Path filePath = Path.of(path.toString(), "FailsNoSemicolons.kt"); Map editorConfigOverrideMap = new HashMap<>(); editorConfigOverrideMap.put("indent_style", "tab"); diff --git a/lib/src/testCompatKtLint1Dot0Dot0/java/com/diffplug/spotless/glue/ktlint/compat/KtLintCompat1Dot0Dot0AdapterTest.java b/lib/src/testCompatKtLint1Dot0Dot0/java/com/diffplug/spotless/glue/ktlint/compat/KtLintCompat1Dot0Dot0AdapterTest.java index 760aa89ae5..4792e278d0 100644 --- a/lib/src/testCompatKtLint1Dot0Dot0/java/com/diffplug/spotless/glue/ktlint/compat/KtLintCompat1Dot0Dot0AdapterTest.java +++ b/lib/src/testCompatKtLint1Dot0Dot0/java/com/diffplug/spotless/glue/ktlint/compat/KtLintCompat1Dot0Dot0AdapterTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 DiffPlug + * Copyright 2023-2025 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,6 @@ import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.HashMap; import java.util.Map; @@ -34,7 +33,7 @@ public class KtLintCompat1Dot0Dot0AdapterTest { public void testDefaults(@TempDir Path path) throws IOException { KtLintCompat1Dot0Dot0Adapter KtLintCompat1Dot0Dot0Adapter = new KtLintCompat1Dot0Dot0Adapter(); var content = loadAndWriteText(path, "EmptyClassBody.kt"); - final Path filePath = Paths.get(path.toString(), "EmptyClassBody.kt"); + final Path filePath = Path.of(path.toString(), "EmptyClassBody.kt"); Map editorConfigOverrideMap = new HashMap<>(); @@ -46,7 +45,7 @@ public void testDefaults(@TempDir Path path) throws IOException { public void testEditorConfigCanDisable(@TempDir Path path) throws IOException { KtLintCompat1Dot0Dot0Adapter KtLintCompat1Dot0Dot0Adapter = new KtLintCompat1Dot0Dot0Adapter(); var content = loadAndWriteText(path, "FailsNoSemicolons.kt"); - final Path filePath = Paths.get(path.toString(), "FailsNoSemicolons.kt"); + final Path filePath = Path.of(path.toString(), "FailsNoSemicolons.kt"); Map editorConfigOverrideMap = new HashMap<>(); editorConfigOverrideMap.put("indent_style", "tab"); diff --git a/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/BiomeStepConfig.java b/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/BiomeStepConfig.java index 4767e5112a..69932670ac 100644 --- a/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/BiomeStepConfig.java +++ b/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/BiomeStepConfig.java @@ -18,7 +18,7 @@ import static java.util.Objects.requireNonNull; import java.io.File; -import java.nio.file.Paths; +import java.nio.file.Path; import java.util.function.Consumer; import javax.annotation.Nullable; @@ -227,7 +227,7 @@ private BiomeStep newBuilder() { * @return The resolved path to the Biome executable. */ private String resolvePathToExe() { - var fileNameOnly = pathToExe instanceof String && Paths.get(pathToExe.toString()).getNameCount() == 1; + var fileNameOnly = pathToExe instanceof String && Path.of(pathToExe.toString()).getNameCount() == 1; if (fileNameOnly) { return pathToExe.toString(); } else { diff --git a/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/SpotlessDiagnoseTask.java b/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/SpotlessDiagnoseTask.java index 68f6e63e75..8ef7394c7b 100644 --- a/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/SpotlessDiagnoseTask.java +++ b/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/SpotlessDiagnoseTask.java @@ -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.Locale; import org.gradle.api.DefaultTask; @@ -59,7 +58,7 @@ public void performAction() throws IOException { Path relative = srcRoot.relativize(file.toPath()); Path diagnoseFile = diagnoseRoot.resolve(relative); for (int i = 0; i < padded.steps().size(); ++i) { - Path path = Paths.get(diagnoseFile + "." + padded.type().name().toLowerCase(Locale.ROOT) + i); + Path path = Path.of(diagnoseFile + "." + padded.type().name().toLowerCase(Locale.ROOT) + i); Files.createDirectories(path.getParent()); String version = padded.steps().get(i); Files.write(path, version.getBytes(formatter.getEncoding())); diff --git a/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/NpmInstallCacheIntegrationTests.java b/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/NpmInstallCacheIntegrationTests.java index e7ad5f1654..46d0817fcd 100644 --- a/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/NpmInstallCacheIntegrationTests.java +++ b/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/NpmInstallCacheIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 DiffPlug + * Copyright 2023-2025 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ import java.io.File; import java.io.IOException; -import java.nio.file.Paths; +import java.nio.file.Path; import org.assertj.core.api.Assertions; import org.gradle.testkit.runner.BuildResult; @@ -54,7 +54,7 @@ void prettierCachesNodeModulesToADefaultFolderWhenCachingEnabled() throws IOExce Assertions.assertThat(result.getOutput()) .doesNotContain("Using cached node_modules for") .contains("Caching node_modules for ") - .contains(Paths.get(dir1.getAbsolutePath(), "build", SPOTLESS_NPM_INSTALL_CACHE_DEFAULT_NAME).toString()); + .contains(Path.of(dir1.getAbsolutePath(), "build", SPOTLESS_NPM_INSTALL_CACHE_DEFAULT_NAME).toString()); } diff --git a/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/SpotlessTaskImplTest.java b/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/SpotlessTaskImplTest.java index a1f49c7373..ad2ae7c5aa 100644 --- a/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/SpotlessTaskImplTest.java +++ b/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/SpotlessTaskImplTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 DiffPlug + * Copyright 2023-2025 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ package com.diffplug.gradle.spotless; import java.io.File; -import java.nio.file.Paths; +import java.nio.file.Path; import org.assertj.core.api.Assertions; import org.gradle.api.file.DirectoryProperty; @@ -32,13 +32,13 @@ public void testThrowsMessageContainsFilename() throws Exception { SpotlessTaskImpl task = Mockito.mock(SpotlessTaskImpl.class, Mockito.CALLS_REAL_METHODS); Mockito.when(task.getLogger()).thenReturn(Mockito.mock(Logger.class)); - File projectDir = Paths.get("unitTests", "projectDir").toFile(); + File projectDir = Path.of("unitTests", "projectDir").toFile(); DirectoryProperty projectDirProperty = Mockito.mock(DirectoryProperty.class, Mockito.RETURNS_DEEP_STUBS); Mockito.when(projectDirProperty.get().getAsFile()).thenReturn(projectDir); Mockito.when(task.getProjectDir()).thenReturn(projectDirProperty); - File input = Paths.get("unitTests", "projectDir", "someInput").toFile(); + File input = Path.of("unitTests", "projectDir", "someInput").toFile(); Formatter formatter = Mockito.mock(Formatter.class); Assertions.assertThatThrownBy(() -> task.processInputFile(null, formatter, input, "someInput")).hasMessageContaining(input.toString()); diff --git a/plugin-maven/build.gradle b/plugin-maven/build.gradle index c54783d56a..2ee22a6477 100644 --- a/plugin-maven/build.gradle +++ b/plugin-maven/build.gradle @@ -31,6 +31,8 @@ dependencies { compileOnly "org.apache.maven:maven-core:${VER_MAVEN_API}" compileOnly "org.eclipse.aether:aether-api:${VER_ECLIPSE_AETHER}" + compileOnly "jakarta.annotation:jakarta.annotation-api:1.3.5" + implementation "com.diffplug.durian:durian-core:${VER_DURIAN}" implementation "com.diffplug.durian:durian-io:${VER_DURIAN}" implementation "com.diffplug.durian:durian-collect:${VER_DURIAN}" diff --git a/plugin-maven/src/main/java/com/diffplug/spotless/maven/FileLocator.java b/plugin-maven/src/main/java/com/diffplug/spotless/maven/FileLocator.java index 088c35a3d0..09938e8ee6 100644 --- a/plugin-maven/src/main/java/com/diffplug/spotless/maven/FileLocator.java +++ b/plugin-maven/src/main/java/com/diffplug/spotless/maven/FileLocator.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2023 DiffPlug + * Copyright 2016-2025 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,6 @@ import java.net.URISyntaxException; import java.nio.file.FileSystemNotFoundException; import java.nio.file.Path; -import java.nio.file.Paths; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.Base64; @@ -146,7 +145,7 @@ private static File findDataDir() { } private static File findUserHome() { - var home = Paths.get(System.getenv("user.home")); + var home = Path.of(System.getenv("user.home")); return home.resolve(".rome").toAbsolutePath().toFile(); } } diff --git a/plugin-maven/src/main/java/com/diffplug/spotless/maven/GitRatchetMaven.java b/plugin-maven/src/main/java/com/diffplug/spotless/maven/GitRatchetMaven.java index f68ac295f6..ab3ec8b958 100644 --- a/plugin-maven/src/main/java/com/diffplug/spotless/maven/GitRatchetMaven.java +++ b/plugin-maven/src/main/java/com/diffplug/spotless/maven/GitRatchetMaven.java @@ -1,5 +1,5 @@ /* - * Copyright 2020 DiffPlug + * Copyright 2020-2025 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,6 @@ import java.io.File; import java.io.IOException; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.HashSet; import java.util.Set; import java.util.stream.Collectors; @@ -64,7 +63,7 @@ Iterable getDirtyFiles(File baseDir, String ratchetFrom) throws IOExcept indexDiff.diff(); String workTreePath = repository.getWorkTree().getPath(); - Path baseDirPath = Paths.get(baseDir.getPath()); + Path baseDirPath = Path.of(baseDir.getPath()); Set dirtyPaths = new HashSet<>(indexDiff.getChanged()); dirtyPaths.addAll(indexDiff.getAdded()); @@ -93,7 +92,7 @@ Iterable getDirtyFiles(File baseDir, String ratchetFrom) throws IOExcept dirtyPaths.removeAll(indexDiff.getMissing()); return dirtyPaths.stream() - .map(path -> baseDirPath.relativize(Paths.get(workTreePath, path)).toString()) + .map(path -> baseDirPath.relativize(Path.of(workTreePath, path)).toString()) .collect(Collectors.toList()); } } diff --git a/plugin-maven/src/main/java/com/diffplug/spotless/maven/generic/AbstractBiome.java b/plugin-maven/src/main/java/com/diffplug/spotless/maven/generic/AbstractBiome.java index 3d1cf82ca4..3bf46f9be8 100644 --- a/plugin-maven/src/main/java/com/diffplug/spotless/maven/generic/AbstractBiome.java +++ b/plugin-maven/src/main/java/com/diffplug/spotless/maven/generic/AbstractBiome.java @@ -15,7 +15,7 @@ */ package com.diffplug.spotless.maven.generic; -import java.nio.file.Paths; +import java.nio.file.Path; import org.apache.maven.plugins.annotations.Parameter; @@ -163,7 +163,7 @@ private String resolveConfigFile(FormatterStepConfig config) { * @return The resolved path to the Biome executable. */ private String resolveExePath(FormatterStepConfig config) { - var path = Paths.get(pathToExe); + var path = Path.of(pathToExe); if (path.getNameCount() == 1) { return path.toString(); } else { diff --git a/plugin-maven/src/main/java/com/diffplug/spotless/maven/generic/Prettier.java b/plugin-maven/src/main/java/com/diffplug/spotless/maven/generic/Prettier.java index c6b3e46e3c..36efe4e7ab 100644 --- a/plugin-maven/src/main/java/com/diffplug/spotless/maven/generic/Prettier.java +++ b/plugin-maven/src/main/java/com/diffplug/spotless/maven/generic/Prettier.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2023 DiffPlug + * Copyright 2016-2025 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,12 @@ package com.diffplug.spotless.maven.generic; import java.io.File; -import java.util.*; +import java.util.AbstractMap; +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; import java.util.stream.Collectors; import org.apache.maven.plugins.annotations.Parameter; diff --git a/plugin-maven/src/main/java/com/diffplug/spotless/maven/incremental/FileIndex.java b/plugin-maven/src/main/java/com/diffplug/spotless/maven/incremental/FileIndex.java index c719419923..5104512b8e 100644 --- a/plugin-maven/src/main/java/com/diffplug/spotless/maven/incremental/FileIndex.java +++ b/plugin-maven/src/main/java/com/diffplug/spotless/maven/incremental/FileIndex.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2023 DiffPlug + * Copyright 2021-2025 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,7 +28,6 @@ import java.nio.file.Files; import java.nio.file.LinkOption; import java.nio.file.Path; -import java.nio.file.Paths; import java.time.Instant; import java.time.format.DateTimeParseException; import java.util.Map; @@ -102,8 +101,7 @@ static void delete(FileIndexConfig config, Log log) { } } - @Nullable - Instant getLastModifiedTime(Path file) { + @Nullable Instant getLastModifiedTime(Path file) { if (!file.startsWith(projectDir)) { return null; } @@ -169,7 +167,7 @@ private static Content readIndexContent(BufferedReader reader, Path projectDir, throw new IOException("Incorrect index file. No separator found in '" + line + "'"); } - Path relativeFile = Paths.get(line.substring(0, separatorIndex)); + Path relativeFile = Path.of(line.substring(0, separatorIndex)); Path absoluteFile = projectDir.resolve(relativeFile); if (Files.notExists(absoluteFile)) { log.info("File stored in the index does not exist: " + relativeFile); diff --git a/plugin-maven/src/main/java/com/diffplug/spotless/maven/npm/AbstractNpmFormatterStepFactory.java b/plugin-maven/src/main/java/com/diffplug/spotless/maven/npm/AbstractNpmFormatterStepFactory.java index b0645c151e..fbf920b853 100644 --- a/plugin-maven/src/main/java/com/diffplug/spotless/maven/npm/AbstractNpmFormatterStepFactory.java +++ b/plugin-maven/src/main/java/com/diffplug/spotless/maven/npm/AbstractNpmFormatterStepFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2023 DiffPlug + * Copyright 2016-2025 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ package com.diffplug.spotless.maven.npm; import java.io.File; -import java.nio.file.Paths; +import java.nio.file.Path; import java.util.AbstractMap; import java.util.Arrays; import java.util.Collections; @@ -74,7 +74,7 @@ protected File cacheDir(FormatterStepConfig stepConfig) { if ("true".equals(this.npmInstallCache.toLowerCase(Locale.ROOT))) { return new File(buildDir(stepConfig), SPOTLESS_NPM_INSTALL_CACHE_DEFAULT_NAME); } - return Paths.get(this.npmInstallCache).toFile(); + return Path.of(this.npmInstallCache).toFile(); } protected File baseDir(FormatterStepConfig stepConfig) { diff --git a/plugin-maven/src/test/java/com/diffplug/spotless/maven/FileLocatorTest.java b/plugin-maven/src/test/java/com/diffplug/spotless/maven/FileLocatorTest.java index 9a80d07f1a..1e28359a3b 100644 --- a/plugin-maven/src/test/java/com/diffplug/spotless/maven/FileLocatorTest.java +++ b/plugin-maven/src/test/java/com/diffplug/spotless/maven/FileLocatorTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2021 DiffPlug + * Copyright 2016-2025 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +24,7 @@ import static org.mockito.Mockito.when; import java.io.File; -import java.nio.file.Paths; +import java.nio.file.Path; import org.codehaus.plexus.resource.ResourceManager; import org.junit.jupiter.api.BeforeEach; @@ -56,12 +56,12 @@ void locateNull() { @Test void locateXmlFile() throws Exception { - testFileLocator(Paths.get("tmp", "configs", "my-config.xml").toString(), "xml"); + testFileLocator(Path.of("tmp", "configs", "my-config.xml").toString(), "xml"); } @Test void locatePropertiesFile() throws Exception { - testFileLocator(Paths.get("home", "ubuntu", "my-other-config.properties").toString(), "properties"); + testFileLocator(Path.of("home", "ubuntu", "my-other-config.properties").toString(), "properties"); } @Test diff --git a/plugin-maven/src/test/java/com/diffplug/spotless/maven/SpecificFilesTest.java b/plugin-maven/src/test/java/com/diffplug/spotless/maven/SpecificFilesTest.java index 6ce11d179f..1486fefa95 100644 --- a/plugin-maven/src/test/java/com/diffplug/spotless/maven/SpecificFilesTest.java +++ b/plugin-maven/src/test/java/com/diffplug/spotless/maven/SpecificFilesTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2023 DiffPlug + * Copyright 2016-2025 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,6 @@ import java.io.IOException; import java.nio.file.Path; -import java.nio.file.Paths; import org.junit.jupiter.api.Test; @@ -26,9 +25,9 @@ private String testFile(int number, boolean absolute) throws IOException { String rel = "src/main/java/test" + number + ".java"; Path path; if (absolute) { - path = Paths.get(rootFolder().getAbsolutePath(), rel); + path = Path.of(rootFolder().getAbsolutePath(), rel); } else { - path = Paths.get(rel); + path = Path.of(rel); } String result = path.toString(); if (!isOnWindows()) { diff --git a/plugin-maven/src/test/java/com/diffplug/spotless/maven/incremental/FileIndexConfigTest.java b/plugin-maven/src/test/java/com/diffplug/spotless/maven/incremental/FileIndexConfigTest.java index 4d167bc18f..864a874542 100644 --- a/plugin-maven/src/test/java/com/diffplug/spotless/maven/incremental/FileIndexConfigTest.java +++ b/plugin-maven/src/test/java/com/diffplug/spotless/maven/incremental/FileIndexConfigTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2022 DiffPlug + * Copyright 2021-2025 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,6 @@ import java.io.File; import java.nio.file.Path; -import java.nio.file.Paths; import org.apache.maven.model.Build; import org.apache.maven.project.MavenProject; @@ -32,7 +31,7 @@ void returnsCorrectProjectDir() { MavenProject project = mavenProject(); FileIndexConfig config = new FileIndexConfig(project, getIndexFile(project), PluginFingerprint.from("foo")); - assertThat(config.getProjectDir()).isEqualTo(Paths.get("projectDir")); + assertThat(config.getProjectDir()).isEqualTo(Path.of("projectDir")); } @Test @@ -41,7 +40,7 @@ void returnsCorrectIndexFile() { FileIndexConfig config = new FileIndexConfig(project, getIndexFile(project), PluginFingerprint.from("foo")); assertThat(config.getIndexFile()) - .isEqualTo(Paths.get("projectDir", "target", "spotless-index")); + .isEqualTo(Path.of("projectDir", "target", "spotless-index")); } @Test diff --git a/plugin-maven/src/test/java/com/diffplug/spotless/maven/incremental/FileIndexTest.java b/plugin-maven/src/test/java/com/diffplug/spotless/maven/incremental/FileIndexTest.java index 8cd5e8a2f7..c5dcb70383 100644 --- a/plugin-maven/src/test/java/com/diffplug/spotless/maven/incremental/FileIndexTest.java +++ b/plugin-maven/src/test/java/com/diffplug/spotless/maven/incremental/FileIndexTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2023 DiffPlug + * Copyright 2021-2025 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,7 +25,6 @@ import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.nio.file.attribute.FileTime; import java.time.Instant; import java.util.List; @@ -214,7 +213,7 @@ void getLastModifiedTimeReturnsEmptyOptionalForUnknownFile() throws Exception { @Test void setLastModifiedTimeThrowsForNonProjectFile() { FileIndex index = FileIndex.read(config, log); - Path nonProjectFile = Paths.get("non-project-file"); + Path nonProjectFile = Path.of("non-project-file"); assertThatThrownBy(() -> index.setLastModifiedTime(nonProjectFile, Instant.now())).isInstanceOf(IllegalArgumentException.class); } @@ -256,7 +255,7 @@ void rewritesIndexFileThatReferencesNonExistingFile() throws Exception { @Test void writeFailsWhenIndexFilesDoesNotHaveParentDir() { - when(config.getIndexFile()).thenReturn(Paths.get("file-without-parent")); + when(config.getIndexFile()).thenReturn(Path.of("file-without-parent")); FileIndex index = FileIndex.read(config, log); assertThat(index.size()).isZero(); diff --git a/plugin-maven/src/test/java/com/diffplug/spotless/maven/npm/NpmStepsWithNpmInstallCacheTest.java b/plugin-maven/src/test/java/com/diffplug/spotless/maven/npm/NpmStepsWithNpmInstallCacheTest.java index eabdd5c5fc..75d4b3f693 100644 --- a/plugin-maven/src/test/java/com/diffplug/spotless/maven/npm/NpmStepsWithNpmInstallCacheTest.java +++ b/plugin-maven/src/test/java/com/diffplug/spotless/maven/npm/NpmStepsWithNpmInstallCacheTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 DiffPlug + * Copyright 2023-2025 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,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; @@ -85,7 +84,7 @@ void prettierTypescriptWithDefaultCacheIsReusedOnSecondRun() throws Exception { .doesNotContain("Using cached node_modules for"); // recursively delete target folder to simulate a fresh run (except the default cache folder) - recursiveDelete(Paths.get(rootFolder().getAbsolutePath(), "target"), SPOTLESS_NPM_INSTALL_CACHE_DEFAULT_NAME); + recursiveDelete(Path.of(rootFolder().getAbsolutePath(), "target"), SPOTLESS_NPM_INSTALL_CACHE_DEFAULT_NAME); Result result2 = run("typescript", suffix); Assertions.assertThat(result2.stdOutUtf8()) @@ -129,7 +128,7 @@ void prettierTypescriptWithSpecificCacheIsUsedOnSecondRun() throws Exception { .doesNotContain("Using cached node_modules for"); // recursively delete target folder to simulate a fresh run - recursiveDelete(Paths.get(rootFolder().getAbsolutePath(), "target"), null); + recursiveDelete(Path.of(rootFolder().getAbsolutePath(), "target"), null); Result result2 = run("typescript", suffix); Assertions.assertThat(result2.stdOutUtf8()) diff --git a/settings.gradle b/settings.gradle index 8ab2d796e6..92bffc5031 100644 --- a/settings.gradle +++ b/settings.gradle @@ -23,6 +23,7 @@ plugins { id 'com.gradle.develocity' version '3.19.2' // https://github.com/equodev/equo-ide/blob/main/plugin-gradle/CHANGELOG.md id 'dev.equo.ide' version '1.7.8' apply false + id 'org.openrewrite.rewrite' version '7.16.0' apply false } dependencyResolutionManagement { diff --git a/testlib/src/test/java/com/diffplug/spotless/biome/BiomeStepTest.java b/testlib/src/test/java/com/diffplug/spotless/biome/BiomeStepTest.java index 090c898df8..a47a5ad4cc 100644 --- a/testlib/src/test/java/com/diffplug/spotless/biome/BiomeStepTest.java +++ b/testlib/src/test/java/com/diffplug/spotless/biome/BiomeStepTest.java @@ -20,7 +20,6 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Nested; @@ -40,7 +39,7 @@ class BiomeStepTest extends ResourceHarness { @BeforeAll static void createDownloadDir() throws IOException { // We do not want to download Biome each time we execute a test - var userHome = Paths.get(StandardSystemProperty.USER_HOME.value()); + var userHome = Path.of(StandardSystemProperty.USER_HOME.value()); downloadDir = userHome.resolve(".gradle").resolve("rome-dl-test").toAbsolutePath().normalize().toString(); }