From fabc42f21acb70429289103b12545f4be8e3bdb4 Mon Sep 17 00:00:00 2001 From: Vincent Potucek Date: Mon, 15 Dec 2025 14:09:22 +0100 Subject: [PATCH] [S1132] Fix `NPE` add `org.springframework.boot.openrewrite.SanityCheck#EqualsAvoidsNull` #48530 Signed-off-by: Vincent Potucek --- .github/workflows/build-pull-request.yml | 12 ++++++------ .github/workflows/distribute.yml | 1 + .github/workflows/run-codeql-analysis.yml | 3 ++- .github/workflows/sanity.yml | 19 +++++++++++++++++++ build.gradle | 3 +++ .../boot/build/DeployedPlugin.java | 4 ++-- .../boot/build/MavenRepositoryPlugin.java | 4 ++-- .../boot/build/antora/CheckJavadocMacros.java | 2 +- .../AutoConfigurationChecker.java | 2 +- .../bomr/StandardLibraryUpdateResolver.java | 2 +- ...eckClasspathForProhibitedDependencies.java | 2 +- .../boot/build/starters/DocumentStarters.java | 2 +- .../boot/build/ConventionsPluginTests.java | 10 +++++----- ...DocumentAutoConfigurationClassesTests.java | 4 ++-- .../build/bom/BomPluginIntegrationTests.java | 13 ++++++------- .../bom/bomr/UpgradeApplicatorTests.java | 5 ++--- .../ConfigurationPropertiesAnalyzerTests.java | 18 +++++++++--------- ...nalDependenciesPluginIntegrationTests.java | 10 +++++----- .../autoconfigure/TestSliceMetadataTests.java | 2 +- gradle/plugins/config/sanity.gradle | 19 +++++++++++++++++++ gradle/plugins/config/sanity.yml | 16 ++++++++++++++++ gradle/wrapper/gradle-wrapper.properties | 5 ++--- gradlew.bat | 0 23 files changed, 107 insertions(+), 51 deletions(-) create mode 100644 .github/workflows/sanity.yml create mode 100644 gradle/plugins/config/sanity.gradle create mode 100644 gradle/plugins/config/sanity.yml mode change 100644 => 100755 gradlew.bat diff --git a/.github/workflows/build-pull-request.yml b/.github/workflows/build-pull-request.yml index 7f096119643c..8df405a03cf0 100644 --- a/.github/workflows/build-pull-request.yml +++ b/.github/workflows/build-pull-request.yml @@ -1,22 +1,22 @@ -name: Build Pull Request +name: Build Pull Request 🏭️ on: pull_request permissions: contents: read jobs: build: - name: Build Pull Request + name: Build 🏗 if: ${{ github.repository == 'spring-projects/spring-boot' }} runs-on: ${{ vars.UBUNTU_MEDIUM || 'ubuntu-latest' }} steps: - - name: Check Out Code + - name: Checkout Code 📥 uses: actions/checkout@v6 - - name: Build + - name: Build 📦 id: build uses: ./.github/actions/build - - name: Print JVM Thread Dumps When Cancelled + - name: Log Potentially Cancelled JVM Thread Dumps 📋 if: cancelled() uses: ./.github/actions/print-jvm-thread-dumps - - name: Upload Build Reports + - name: Upload Build Report 📊 if: failure() uses: actions/upload-artifact@v5 with: diff --git a/.github/workflows/distribute.yml b/.github/workflows/distribute.yml index e8462178fe5c..d8250fe4300f 100644 --- a/.github/workflows/distribute.yml +++ b/.github/workflows/distribute.yml @@ -19,6 +19,7 @@ permissions: contents: read jobs: distribute-spring-enterprise-release-bundle: + name: Distribute Release Bundle 📦 runs-on: ${{ vars.UBUNTU_SMALL || 'ubuntu-latest' }} steps: - name: Create Bundle diff --git a/.github/workflows/run-codeql-analysis.yml b/.github/workflows/run-codeql-analysis.yml index f3a9f268e463..5c2642de0f8b 100644 --- a/.github/workflows/run-codeql-analysis.yml +++ b/.github/workflows/run-codeql-analysis.yml @@ -1,4 +1,4 @@ -name: "Run CodeQL Analysis" +name: Run CodeQL Analysis 📊 on: push: pull_request: @@ -6,6 +6,7 @@ on: permissions: read-all jobs: run-analysis: + name: Inspect 🔎 permissions: actions: read contents: read diff --git a/.github/workflows/sanity.yml b/.github/workflows/sanity.yml new file mode 100644 index 000000000000..d5106fedbfd6 --- /dev/null +++ b/.github/workflows/sanity.yml @@ -0,0 +1,19 @@ +name: Sanity Check 🕊️ +on: + push: + pull_request: + workflow_dispatch: +permissions: read-all +jobs: + verify: + name: Verify 📊 + if: ${{ github.repository == 'spring-projects/spring-boot' }} + runs-on: ${{ vars.UBUNTU_MEDIUM || 'ubuntu-latest' }} + steps: + - name: Checkout Code 📥 + uses: actions/checkout@v6 + - name: Build 📦 + id: build + uses: ./.github/actions/build + - name: Rewrite ♻️ + run: ./gradlew rewriteDryRun diff --git a/build.gradle b/build.gradle index 84acc8603902..0a7bc5321baf 100644 --- a/build.gradle +++ b/build.gradle @@ -16,6 +16,7 @@ plugins { id "base" + id "org.openrewrite.rewrite" version "7.22.0" apply false } description = "Spring Boot Build" @@ -46,3 +47,5 @@ subprojects { resolutionStrategy.cacheChangingModulesFor 0, "minutes" } } + +apply from: rootProject.file("${rootDir}/gradle/plugins/config/sanity.gradle") \ No newline at end of file diff --git a/buildSrc/src/main/java/org/springframework/boot/build/DeployedPlugin.java b/buildSrc/src/main/java/org/springframework/boot/build/DeployedPlugin.java index 62ed4f809308..dc40c23577a0 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/DeployedPlugin.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/DeployedPlugin.java @@ -47,14 +47,14 @@ public void apply(Project project) { project.afterEvaluate((evaluated) -> project.getPlugins().withType(JavaPlugin.class).all((javaPlugin) -> { if (((Jar) project.getTasks().getByName(JavaPlugin.JAR_TASK_NAME)).isEnabled()) { project.getComponents() - .matching((component) -> component.getName().equals("java")) + .matching((component) -> "java".equals(component.getName())) .all(mavenPublication::from); } })); project.getPlugins() .withType(JavaPlatformPlugin.class) .all((javaPlugin) -> project.getComponents() - .matching((component) -> component.getName().equals("javaPlatform")) + .matching((component) -> "javaPlatform".equals(component.getName())) .all(mavenPublication::from)); } diff --git a/buildSrc/src/main/java/org/springframework/boot/build/MavenRepositoryPlugin.java b/buildSrc/src/main/java/org/springframework/boot/build/MavenRepositoryPlugin.java index aacc84476324..69c4461c07d7 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/MavenRepositoryPlugin.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/MavenRepositoryPlugin.java @@ -62,10 +62,10 @@ public void apply(Project project) { mavenRepository.setUrl(repositoryLocation.toURI()); }); project.getTasks() - .matching((task) -> task.getName().equals(PUBLISH_TO_PROJECT_REPOSITORY_TASK_NAME)) + .matching((task) -> PUBLISH_TO_PROJECT_REPOSITORY_TASK_NAME.equals(task.getName())) .all((task) -> setUpProjectRepository(project, task, repositoryLocation)); project.getTasks() - .matching((task) -> task.getName().equals("publishPluginMavenPublicationToProjectRepository")) + .matching((task) -> "publishPluginMavenPublicationToProjectRepository".equals(task.getName())) .all((task) -> setUpProjectRepository(project, task, repositoryLocation)); } diff --git a/buildSrc/src/main/java/org/springframework/boot/build/antora/CheckJavadocMacros.java b/buildSrc/src/main/java/org/springframework/boot/build/antora/CheckJavadocMacros.java index 8c7cb35c981f..70a8ab2cd019 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/antora/CheckJavadocMacros.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/antora/CheckJavadocMacros.java @@ -336,7 +336,7 @@ private WellKnownAnchor(Origin origin) { } private static WellKnownAnchor of(String anchor, Origin origin) { - if (anchor.equals("enum-constant-summary")) { + if ("enum-constant-summary".equals(anchor)) { return new WellKnownAnchor(origin); } return null; diff --git a/buildSrc/src/main/java/org/springframework/boot/build/architecture/AutoConfigurationChecker.java b/buildSrc/src/main/java/org/springframework/boot/build/architecture/AutoConfigurationChecker.java index c1d7ee9d131c..03d6441c5e93 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/architecture/AutoConfigurationChecker.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/architecture/AutoConfigurationChecker.java @@ -117,7 +117,7 @@ private JavaClass[] getImportedClasses(JavaClass javaClass) { private boolean isBootClass(JavaClass javaClass) { String pkg = javaClass.getPackage().getName(); - return pkg.equals(SPRING_BOOT_ROOT_PACKAGE) || pkg.startsWith(SPRING_BOOT_ROOT_PACKAGE + "."); + return SPRING_BOOT_ROOT_PACKAGE.equals(pkg) || pkg.startsWith(SPRING_BOOT_ROOT_PACKAGE + "."); } } diff --git a/buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/StandardLibraryUpdateResolver.java b/buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/StandardLibraryUpdateResolver.java index 851fafb7801d..6697278a3fc4 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/StandardLibraryUpdateResolver.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/StandardLibraryUpdateResolver.java @@ -74,7 +74,7 @@ public List findLibraryUpdates(Collection li } protected boolean isLibraryExcluded(Library library) { - return library.getName().equals("Spring Boot"); + return "Spring Boot".equals(library.getName()); } protected List getVersionOptions(Library library) { diff --git a/buildSrc/src/main/java/org/springframework/boot/build/classpath/CheckClasspathForProhibitedDependencies.java b/buildSrc/src/main/java/org/springframework/boot/build/classpath/CheckClasspathForProhibitedDependencies.java index 1e4cab02d0c1..d97148423e4a 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/classpath/CheckClasspathForProhibitedDependencies.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/classpath/CheckClasspathForProhibitedDependencies.java @@ -85,7 +85,7 @@ private boolean prohibited(ModuleVersionIdentifier id) { } private boolean prohibitedSlf4j(ModuleVersionIdentifier id) { - return id.getGroup().equals("org.slf4j") && id.getName().equals("jcl-over-slf4j"); + return "org.slf4j".equals(id.getGroup()) && "jcl-over-slf4j".equals(id.getName()); } private boolean prohibitedJbossSpec(ModuleVersionIdentifier id) { diff --git a/buildSrc/src/main/java/org/springframework/boot/build/starters/DocumentStarters.java b/buildSrc/src/main/java/org/springframework/boot/build/starters/DocumentStarters.java index 56a0b6e246b3..87e436bc10d4 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/starters/DocumentStarters.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/starters/DocumentStarters.java @@ -139,7 +139,7 @@ private Starter(String name, String description, Set dependencies) { } private boolean isProduction() { - return this.name.equals("spring-boot-starter-actuator"); + return "spring-boot-starter-actuator".equals(this.name); } private boolean isTechnical() { diff --git a/buildSrc/src/test/java/org/springframework/boot/build/ConventionsPluginTests.java b/buildSrc/src/test/java/org/springframework/boot/build/ConventionsPluginTests.java index 63df2376612d..14b955941230 100644 --- a/buildSrc/src/test/java/org/springframework/boot/build/ConventionsPluginTests.java +++ b/buildSrc/src/test/java/org/springframework/boot/build/ConventionsPluginTests.java @@ -70,7 +70,7 @@ void setup(@TempDir File projectDir) throws IOException { } @Test - void jarIncludesLegalFiles() throws IOException { + void jarIncludesLegalFiles() throws Exception { try (PrintWriter out = new PrintWriter(new FileWriter(this.buildFile))) { out.println("plugins {"); out.println(" id 'java'"); @@ -101,7 +101,7 @@ void jarIncludesLegalFiles() throws IOException { } @Test - void sourceJarIsBuilt() throws IOException { + void sourceJarIsBuilt() throws Exception { try (PrintWriter out = new PrintWriter(new FileWriter(this.buildFile))) { out.println("plugins {"); out.println(" id 'java'"); @@ -132,7 +132,7 @@ void sourceJarIsBuilt() throws IOException { } @Test - void javadocJarIsBuilt() throws IOException { + void javadocJarIsBuilt() throws Exception { try (PrintWriter out = new PrintWriter(new FileWriter(this.buildFile))) { out.println("plugins {"); out.println(" id 'java'"); @@ -176,7 +176,7 @@ private void assertThatNoticeIsPresent(JarFile jar) throws IOException { } @Test - void testRetryIsConfiguredWithThreeRetriesOnCI() throws IOException { + void retryIsConfiguredWithThreeRetriesOnCI() throws Exception { try (PrintWriter out = new PrintWriter(new FileWriter(this.buildFile))) { out.println("plugins {"); out.println(" id 'java'"); @@ -198,7 +198,7 @@ void testRetryIsConfiguredWithThreeRetriesOnCI() throws IOException { } @Test - void testRetryIsConfiguredWithZeroRetriesLocally() throws IOException { + void retryIsConfiguredWithZeroRetriesLocally() throws Exception { try (PrintWriter out = new PrintWriter(new FileWriter(this.buildFile))) { out.println("plugins {"); out.println(" id 'java'"); diff --git a/buildSrc/src/test/java/org/springframework/boot/build/autoconfigure/DocumentAutoConfigurationClassesTests.java b/buildSrc/src/test/java/org/springframework/boot/build/autoconfigure/DocumentAutoConfigurationClassesTests.java index e0a2abba4d07..b1ab1432148f 100644 --- a/buildSrc/src/test/java/org/springframework/boot/build/autoconfigure/DocumentAutoConfigurationClassesTests.java +++ b/buildSrc/src/test/java/org/springframework/boot/build/autoconfigure/DocumentAutoConfigurationClassesTests.java @@ -43,7 +43,7 @@ class DocumentAutoConfigurationClassesTests { private File temp; @Test - void classesAreDocumented() throws IOException { + void classesAreDocumented() throws Exception { File output = documentAutoConfigurationClasses((metadataDir) -> { writeAutoConfigurationMetadata("spring-boot-one", List.of("org.springframework.boot.one.AAutoConfiguration", "org.springframework.boot.one.BAutoConfiguration"), metadataDir); @@ -56,7 +56,7 @@ void classesAreDocumented() throws IOException { } @Test - void whenMetadataIsRemovedThenOutputForThatMetadataIsNoLongerPresent() throws IOException { + void whenMetadataIsRemovedThenOutputForThatMetadataIsNoLongerPresent() throws Exception { documentAutoConfigurationClasses((metadataDir) -> { writeAutoConfigurationMetadata("spring-boot-one", List.of("org.springframework.boot.one.AAutoConfiguration", "org.springframework.boot.one.BAutoConfiguration"), metadataDir); diff --git a/buildSrc/src/test/java/org/springframework/boot/build/bom/BomPluginIntegrationTests.java b/buildSrc/src/test/java/org/springframework/boot/build/bom/BomPluginIntegrationTests.java index cbec8ea9136b..112ace58e7c9 100644 --- a/buildSrc/src/test/java/org/springframework/boot/build/bom/BomPluginIntegrationTests.java +++ b/buildSrc/src/test/java/org/springframework/boot/build/bom/BomPluginIntegrationTests.java @@ -18,7 +18,6 @@ import java.io.File; import java.io.FileWriter; -import java.io.IOException; import java.io.PrintWriter; import java.util.function.Consumer; @@ -51,7 +50,7 @@ void setup(@TempDir File projectDir) { } @Test - void libraryModulesAreIncludedInDependencyManagementOfGeneratedPom() throws IOException { + void libraryModulesAreIncludedInDependencyManagementOfGeneratedPom() throws Exception { try (PrintWriter out = new PrintWriter(new FileWriter(this.buildFile))) { out.println("plugins {"); out.println(" id 'org.springframework.boot.bom'"); @@ -88,7 +87,7 @@ void libraryModulesAreIncludedInDependencyManagementOfGeneratedPom() throws IOEx } @Test - void libraryPluginsAreIncludedInPluginManagementOfGeneratedPom() throws IOException { + void libraryPluginsAreIncludedInPluginManagementOfGeneratedPom() throws Exception { try (PrintWriter out = new PrintWriter(new FileWriter(this.buildFile))) { out.println("plugins {"); out.println(" id 'org.springframework.boot.bom'"); @@ -143,7 +142,7 @@ void libraryImportsAreIncludedInDependencyManagementOfGeneratedPom() throws Exce } @Test - void moduleExclusionsAreIncludedInDependencyManagementOfGeneratedPom() throws IOException { + void moduleExclusionsAreIncludedInDependencyManagementOfGeneratedPom() throws Exception { try (PrintWriter out = new PrintWriter(new FileWriter(this.buildFile))) { out.println("plugins {"); out.println(" id 'org.springframework.boot.bom'"); @@ -177,7 +176,7 @@ void moduleExclusionsAreIncludedInDependencyManagementOfGeneratedPom() throws IO } @Test - void moduleTypesAreIncludedInDependencyManagementOfGeneratedPom() throws IOException { + void moduleTypesAreIncludedInDependencyManagementOfGeneratedPom() throws Exception { try (PrintWriter out = new PrintWriter(new FileWriter(this.buildFile))) { out.println("plugins {"); out.println(" id 'org.springframework.boot.bom'"); @@ -209,7 +208,7 @@ void moduleTypesAreIncludedInDependencyManagementOfGeneratedPom() throws IOExcep } @Test - void moduleClassifiersAreIncludedInDependencyManagementOfGeneratedPom() throws IOException { + void moduleClassifiersAreIncludedInDependencyManagementOfGeneratedPom() throws Exception { try (PrintWriter out = new PrintWriter(new FileWriter(this.buildFile))) { out.println("plugins {"); out.println(" id 'org.springframework.boot.bom'"); @@ -268,7 +267,7 @@ void moduleClassifiersAreIncludedInDependencyManagementOfGeneratedPom() throws I } @Test - void libraryNamedSpringBootHasNoVersionProperty() throws IOException { + void libraryNamedSpringBootHasNoVersionProperty() throws Exception { try (PrintWriter out = new PrintWriter(new FileWriter(this.buildFile))) { out.println("plugins {"); out.println(" id 'org.springframework.boot.bom'"); diff --git a/buildSrc/src/test/java/org/springframework/boot/build/bom/bomr/UpgradeApplicatorTests.java b/buildSrc/src/test/java/org/springframework/boot/build/bom/bomr/UpgradeApplicatorTests.java index d7732ee7233e..48f5f8e7e68b 100644 --- a/buildSrc/src/test/java/org/springframework/boot/build/bom/bomr/UpgradeApplicatorTests.java +++ b/buildSrc/src/test/java/org/springframework/boot/build/bom/bomr/UpgradeApplicatorTests.java @@ -18,7 +18,6 @@ import java.io.File; import java.io.FileInputStream; -import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; import java.util.Collections; @@ -46,7 +45,7 @@ class UpgradeApplicatorTests { File temp; @Test - void whenUpgradeIsAppliedToLibraryWithVersionThenBomIsUpdated() throws IOException { + void whenUpgradeIsAppliedToLibraryWithVersionThenBomIsUpdated() throws Exception { File bom = new File(this.temp, "bom.gradle"); FileCopyUtils.copy(new File("src/test/resources/bom.gradle"), bom); String originalContents = Files.readString(bom.toPath()); @@ -61,7 +60,7 @@ void whenUpgradeIsAppliedToLibraryWithVersionThenBomIsUpdated() throws IOExcepti } @Test - void whenUpgradeIsAppliedToLibraryWithVersionPropertyThenGradlePropertiesIsUpdated() throws IOException { + void whenUpgradeIsAppliedToLibraryWithVersionPropertyThenGradlePropertiesIsUpdated() throws Exception { File bom = new File(this.temp, "bom.gradle"); FileCopyUtils.copy(new File("src/test/resources/bom.gradle"), bom); File gradleProperties = new File(this.temp, "gradle.properties"); diff --git a/buildSrc/src/test/java/org/springframework/boot/build/context/properties/ConfigurationPropertiesAnalyzerTests.java b/buildSrc/src/test/java/org/springframework/boot/build/context/properties/ConfigurationPropertiesAnalyzerTests.java index 959ba4ad6c98..1a3d27ee8ce7 100644 --- a/buildSrc/src/test/java/org/springframework/boot/build/context/properties/ConfigurationPropertiesAnalyzerTests.java +++ b/buildSrc/src/test/java/org/springframework/boot/build/context/properties/ConfigurationPropertiesAnalyzerTests.java @@ -46,7 +46,7 @@ void createAnalyzerWithNoSource() { } @Test - void analyzeSortWithAlphabeticalOrder(@TempDir File tempDir) throws IOException { + void analyzeSortWithAlphabeticalOrder(@TempDir File tempDir) throws Exception { File metadata = new File(tempDir, "metadata.json"); Files.writeString(metadata.toPath(), """ { "properties": [ @@ -62,7 +62,7 @@ void analyzeSortWithAlphabeticalOrder(@TempDir File tempDir) throws IOException } @Test - void analyzeSortWithViolations(@TempDir File tempDir) throws IOException { + void analyzeSortWithViolations(@TempDir File tempDir) throws Exception { File metadata = new File(tempDir, "metadata.json"); Files.writeString(metadata.toPath(), """ { "properties": [ @@ -80,7 +80,7 @@ void analyzeSortWithViolations(@TempDir File tempDir) throws IOException { } @Test - void analyzePropertyDescription(@TempDir File tempDir) throws IOException { + void analyzePropertyDescription(@TempDir File tempDir) throws Exception { File metadata = new File(tempDir, "metadata.json"); Files.writeString(metadata.toPath(), """ { "properties": [ @@ -98,7 +98,7 @@ void analyzePropertyDescription(@TempDir File tempDir) throws IOException { } @Test - void analyzePropertyDescriptionWithMissingDescription(@TempDir File tempDir) throws IOException { + void analyzePropertyDescriptionWithMissingDescription(@TempDir File tempDir) throws Exception { File metadata = new File(tempDir, "metadata.json"); Files.writeString(metadata.toPath(), """ { "properties": [ @@ -116,7 +116,7 @@ void analyzePropertyDescriptionWithMissingDescription(@TempDir File tempDir) thr } @Test - void analyzeDeprecatedPropertyWithMissingSince(@TempDir File tempDir) throws IOException { + void analyzeDeprecatedPropertyWithMissingSince(@TempDir File tempDir) throws Exception { File metadata = new File(tempDir, "metadata.json"); Files.writeString(metadata.toPath(), """ { "properties": [ @@ -142,12 +142,12 @@ void analyzeDeprecatedPropertyWithMissingSince(@TempDir File tempDir) throws IOE } @Test - void writeEmptyReport(@TempDir File tempDir) throws IOException { + void writeEmptyReport(@TempDir File tempDir) throws Exception { assertThat(writeToFile(tempDir, new Report(tempDir))).hasContent("No problems found."); } @Test - void writeReportWithNoProblemsFound(@TempDir File tempDir) throws IOException { + void writeReportWithNoProblemsFound(@TempDir File tempDir) throws Exception { Report report = new Report(tempDir); File first = new File(tempDir, "metadata-1.json"); report.registerAnalysis(first, new Analysis("Check for things:")); @@ -163,7 +163,7 @@ void writeReportWithNoProblemsFound(@TempDir File tempDir) throws IOException { } @Test - void writeReportWithOneProblem(@TempDir File tempDir) throws IOException { + void writeReportWithOneProblem(@TempDir File tempDir) throws Exception { Report report = new Report(tempDir); File metadata = new File(tempDir, "metadata-1.json"); Analysis analysis = new Analysis("Check for things:"); @@ -181,7 +181,7 @@ void writeReportWithOneProblem(@TempDir File tempDir) throws IOException { } @Test - void writeReportWithSeveralProblems(@TempDir File tempDir) throws IOException { + void writeReportWithSeveralProblems(@TempDir File tempDir) throws Exception { Report report = new Report(tempDir); File metadata = new File(tempDir, "metadata-1.json"); Analysis firstAnalysis = new Analysis("Check for things:"); diff --git a/buildSrc/src/test/java/org/springframework/boot/build/optional/OptionalDependenciesPluginIntegrationTests.java b/buildSrc/src/test/java/org/springframework/boot/build/optional/OptionalDependenciesPluginIntegrationTests.java index 8f457292bd4a..df0fac678621 100644 --- a/buildSrc/src/test/java/org/springframework/boot/build/optional/OptionalDependenciesPluginIntegrationTests.java +++ b/buildSrc/src/test/java/org/springframework/boot/build/optional/OptionalDependenciesPluginIntegrationTests.java @@ -47,7 +47,7 @@ void setup(@TempDir File projectDir) { } @Test - void optionalConfigurationIsCreated() throws IOException { + void optionalConfigurationIsCreated() throws Exception { try (PrintWriter out = new PrintWriter(new FileWriter(this.buildFile))) { out.println("plugins { id 'org.springframework.boot.optional-dependencies' }"); out.println("task printConfigurations {"); @@ -61,22 +61,22 @@ void optionalConfigurationIsCreated() throws IOException { } @Test - void optionalDependenciesAreAddedToMainSourceSetsCompileClasspath() throws IOException { + void optionalDependenciesAreAddedToMainSourceSetsCompileClasspath() throws Exception { optionalDependenciesAreAddedToSourceSetClasspath("main", "compileClasspath"); } @Test - void optionalDependenciesAreAddedToMainSourceSetsRuntimeClasspath() throws IOException { + void optionalDependenciesAreAddedToMainSourceSetsRuntimeClasspath() throws Exception { optionalDependenciesAreAddedToSourceSetClasspath("main", "runtimeClasspath"); } @Test - void optionalDependenciesAreAddedToTestSourceSetsCompileClasspath() throws IOException { + void optionalDependenciesAreAddedToTestSourceSetsCompileClasspath() throws Exception { optionalDependenciesAreAddedToSourceSetClasspath("test", "compileClasspath"); } @Test - void optionalDependenciesAreAddedToTestSourceSetsRuntimeClasspath() throws IOException { + void optionalDependenciesAreAddedToTestSourceSetsRuntimeClasspath() throws Exception { optionalDependenciesAreAddedToSourceSetClasspath("test", "runtimeClasspath"); } diff --git a/buildSrc/src/test/java/org/springframework/boot/build/test/autoconfigure/TestSliceMetadataTests.java b/buildSrc/src/test/java/org/springframework/boot/build/test/autoconfigure/TestSliceMetadataTests.java index 217fb5b22035..e2cd0fdd47ab 100644 --- a/buildSrc/src/test/java/org/springframework/boot/build/test/autoconfigure/TestSliceMetadataTests.java +++ b/buildSrc/src/test/java/org/springframework/boot/build/test/autoconfigure/TestSliceMetadataTests.java @@ -31,7 +31,7 @@ * * @author Andy Wilkinson */ -public class TestSliceMetadataTests { +class TestSliceMetadataTests { @TempDir private File temp; diff --git a/gradle/plugins/config/sanity.gradle b/gradle/plugins/config/sanity.gradle new file mode 100644 index 000000000000..7693836e9011 --- /dev/null +++ b/gradle/plugins/config/sanity.gradle @@ -0,0 +1,19 @@ +project.apply(plugin: "org.openrewrite.rewrite") + +dependencies { + rewrite("org.openrewrite.recipe:rewrite-static-analysis:2.23.0") + rewrite("org.openrewrite.recipe:rewrite-testing-frameworks:3.23.0") +} + +rewrite { + activeRecipe("org.springframework.boot.openrewrite.SanityCheck") + configFile = project.getRootProject().file("${rootDir}/config/sanity.yml") + exclusion( // incompatible + "**AggregatorPlugin.java", + "**AntoraConventions.java", + "**ArchitectureCheckTests.java", + "**architecture/junit/enumsource**", + ) + setExportDatatables(true) + setFailOnDryRunResults(true) +} diff --git a/gradle/plugins/config/sanity.yml b/gradle/plugins/config/sanity.yml new file mode 100644 index 000000000000..dbac933bf7ed --- /dev/null +++ b/gradle/plugins/config/sanity.yml @@ -0,0 +1,16 @@ +--- +type: specs.openrewrite.org/v1beta/recipe +name: org.springframework.boot.openrewrite.SanityCheck +displayName: Apply all common best practices +description: Comprehensive code quality recipe combining modernization, security, and best practices. +recipeList: + - org.openrewrite.gradle.UpdateGradleWrapper + - org.openrewrite.java.testing.junit.JupiterBestPractices + - org.openrewrite.java.testing.junit5.CleanupAssertions + - org.openrewrite.staticanalysis.EqualsAvoidsNull + - tech.picnic.errorprone.refasterrules.TimeRulesRecipes + - tech.picnic.errorprone.refasterrules.EqualityRulesRecipes +# - tech.picnic.errorprone.refasterrules.NullRulesRecipes +# - tech.picnic.errorprone.refasterrules.StreamRulesRecipes +# - tech.picnic.errorprone.refasterrules.StringRulesRecipes +--- diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 23449a2b5432..4b91fc216e2f 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,7 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip -networkTimeout=10000 -validateDistributionUrl=true +distributionSha256Sum=72f44c9f8ebcb1af43838f45ee5c4aa9c5444898b3468ab3f4af7b6076c5bc3f zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists +zipStorePath=wrapper/dists \ No newline at end of file diff --git a/gradlew.bat b/gradlew.bat old mode 100644 new mode 100755