diff --git a/.github/workflows/sanity-check.yml b/.github/workflows/sanity-check.yml new file mode 100644 index 000000000000..379ed85955fd --- /dev/null +++ b/.github/workflows/sanity-check.yml @@ -0,0 +1,51 @@ +name: "Sanity Check" + +on: + push: + branches: + - main + - 'releases/**' + pull_request: + # The branches below must be a subset of the branches above + branches: + - main + - 'releases/**' + schedule: + - cron: '0 19 * * 3' + +concurrency: + # Cancels in-progress runs only for pull requests + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +permissions: {} + +env: + DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }} + +jobs: + analyze: + name: Analyze (${{ matrix.language }}) + runs-on: ubuntu-latest + permissions: + security-events: write + strategy: + fail-fast: false + matrix: + include: + - language: actions + build-mode: none + - language: java-kotlin + build-mode: manual + steps: + - name: Check out repository + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + with: + persist-credentials: false + - name: Sanity Check + if: matrix.build-mode == 'manual' + uses: ./.github/actions/run-gradle + with: + encryptionKey: ${{ secrets.GRADLE_ENCRYPTION_KEY }} + arguments: rewriteDryRun + # arguments: rewriteDryRun -Dorg.gradle.jvmargs=-Xmx8G diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 229b794b8459..9cc2a809d0e4 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,8 +1,8 @@ [versions] ant = "1.10.15" apiguardian = "1.1.2" -asciidoctorj-pdf = "2.3.23" asciidoctor-plugins = "4.0.5" # Check if workaround in documentation.gradle.kts can be removed when upgrading +asciidoctorj-pdf = "2.3.23" assertj = "3.27.6" bnd = "7.1.0" checkstyle = "12.1.1" @@ -15,8 +15,14 @@ junit4 = "4.13.2" junit4Min = "4.12" ktlint = "1.7.1" log4j = "2.25.2" -opentest4j = "1.3.0" openTestReporting = "0.2.5" +opentest4j = "1.3.0" +rewrite-java-security = "7.21.0" +rewrite-migrate-java = "7.21.0" +rewrite-recipe-bom = "7.21.0" +rewrite-rewrite = "7.21.0" +rewrite-static-analysis = "7.21.0" +rewrite-third-party = "7.21.0" snapshotTests = "1.11.0" surefire = "3.5.4" xmlunit = "2.11.0" @@ -27,11 +33,13 @@ ant-junit = { module = "org.apache.ant:ant-junit", version.ref = "ant" } ant-junitlauncher = { module = "org.apache.ant:ant-junitlauncher", version.ref = "ant" } apiguardian = { module = "org.apiguardian:apiguardian-api", version.ref = "apiguardian" } archunit = { module = "com.tngtech.archunit:archunit-junit5", version = "1.4.1" } +asciidoctorj-pdf = { module = "org.asciidoctor:asciidoctorj-pdf", version.ref = "asciidoctorj-pdf" } # Only declared here so Dependabot knows when to update the referenced versions assertj = { module = "org.assertj:assertj-core", version.ref = "assertj" } bndlib = { module = "biz.aQute.bnd:biz.aQute.bndlib", version.ref = "bnd" } checkstyle = { module = "com.puppycrawl.tools:checkstyle", version.ref = "checkstyle" } classgraph = { module = "io.github.classgraph:classgraph", version = "4.8.184" } commons-io = { module = "commons-io:commons-io", version = "2.21.0" } +eclipse-platform = { module = "org.eclipse.platform:org.eclipse.platform", version.ref = "eclipse" } error-prone-contrib = { module = "tech.picnic.error-prone-support:error-prone-contrib", version = "0.26.0" } error-prone-core = { module = "com.google.errorprone:error_prone_core", version = "2.44.0" } fastcsv = { module = "de.siegmar:fastcsv", version = "4.1.0" } @@ -40,6 +48,7 @@ groovy2-bom = { module = "org.codehaus.groovy:groovy-bom", version = "2.5.23" } hamcrest = { module = "org.hamcrest:hamcrest", version = "3.0" } jackson-dataformat-yaml = { module = "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml", version.ref = "jackson" } jackson-module-kotlin = { module = "com.fasterxml.jackson.module:jackson-module-kotlin", version.ref = "jackson" } +jacoco = { module = "org.jacoco:jacoco", version.ref = "jacoco" } jaxb-api = { module = "jakarta.xml.bind:jakarta.xml.bind-api", version = "4.0.4" } jaxb-runtime = { module = "org.glassfish.jaxb:jaxb-runtime", version = "4.0.6" } jfrunit = { module = "org.moditect.jfrunit:jfrunit-core", version = "1.0.0.Alpha2" } @@ -47,10 +56,14 @@ jimfs = { module = "com.google.jimfs:jimfs", version = "1.3.1" } jmh-core = { module = "org.openjdk.jmh:jmh-core", version.ref = "jmh" } jmh-generator-annprocess = { module = "org.openjdk.jmh:jmh-generator-annprocess", version.ref = "jmh" } joox = { module = "org.jooq:joox", version = "2.0.1" } +jruby = { module = "org.jruby:jruby", version.ref = "jruby" } jspecify = { module = "org.jspecify:jspecify", version = "1.0.0" } jte = { module = "gg.jte:jte", version = "3.2.1" } junit4 = { module = "junit:junit", version = { require = "[4.12,)", prefer = "4.13.2" } } +junit4-bundle = { module = "org.apache.servicemix.bundles:org.apache.servicemix.bundles.junit", version = "4.13.2_1" } +junit4-latest = { module = "junit:junit", version.ref = "junit4" } kotlinx-coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version = "1.10.2" } +ktlint-cli = { module = "com.pinterest.ktlint:ktlint-cli", version.ref = "ktlint" } log4j-core = { module = "org.apache.logging.log4j:log4j-core", version.ref = "log4j" } log4j-jul = { module = "org.apache.logging.log4j:log4j-jul", version.ref = "log4j" } maven = { module = "org.apache.maven:apache-maven", version = "3.9.11" } @@ -61,31 +74,28 @@ mockito-core = { module = "org.mockito:mockito-core" } mockito-junit-jupiter = { module = "org.mockito:mockito-junit-jupiter" } nohttp-checkstyle = { module = "io.spring.nohttp:nohttp-checkstyle", version = "0.0.11" } nullaway = { module = "com.uber.nullaway:nullaway", version = "0.12.12" } -opentest4j = { module = "org.opentest4j:opentest4j", version.ref = "opentest4j" } openTestReporting-cli = { module = "org.opentest4j.reporting:open-test-reporting-cli", version.ref = "openTestReporting" } openTestReporting-events = { module = "org.opentest4j.reporting:open-test-reporting-events", version.ref = "openTestReporting" } openTestReporting-tooling-core = { module = "org.opentest4j.reporting:open-test-reporting-tooling-core", version.ref = "openTestReporting" } openTestReporting-tooling-spi = { module = "org.opentest4j.reporting:open-test-reporting-tooling-spi", version.ref = "openTestReporting" } +opentest4j = { module = "org.opentest4j:opentest4j", version.ref = "opentest4j" } picocli = { module = "info.picocli:picocli", version = "4.7.7" } +rewrite-java-security = { module = "org.openrewrite.recipe:rewrite-java-security", version.ref = "rewrite-java-security" } +rewrite-migrate-java = { module = "org.openrewrite.recipe:rewrite-migrate-java", version.ref = "rewrite-migrate-java" } +rewrite-recipe-bom = { module = "org.openrewrite.recipe:rewrite-recipe-bom", version.ref = "rewrite-recipe-bom" } +rewrite-rewrite = { module = "org.openrewrite.recipe:rewrite-rewrite", version.ref = "rewrite-rewrite" } +rewrite-static-analysis = { module = "org.openrewrite.recipe:rewrite-static-analysis", version.ref = "rewrite-static-analysis" } +rewrite-third-party = { module = "org.openrewrite.recipe:rewrite-third-party", version.ref = "rewrite-third-party" } roseau-cli = { module = "io.github.alien-tools:roseau-cli", version = "0.4.0" } slf4j-julBinding = { module = "org.slf4j:slf4j-jdk14", version = "2.0.17" } snapshotTests-junit5 = { module = "de.skuzzle.test:snapshot-tests-junit5", version.ref = "snapshotTests" } snapshotTests-xml = { module = "de.skuzzle.test:snapshot-tests-xml", version.ref = "snapshotTests" } spock1 = { module = "org.spockframework:spock-core", version = "1.3-groovy-2.5" } -xmlunit-assertj = { module = "org.xmlunit:xmlunit-assertj3", version.ref = "xmlunit" } -xmlunit-placeholders = { module = "org.xmlunit:xmlunit-placeholders", version.ref = "xmlunit" } -xmlunit-jakarta-jaxb-impl = { module = "org.xmlunit:xmlunit-jakarta-jaxb-impl", version.ref = "xmlunit" } testingAnnotations = { module = "com.gradle:develocity-testing-annotations", version = "2.0.1" } woodstox = { module = "com.fasterxml.woodstox:woodstox-core", version = "7.1.1" } - -# Only declared here so Dependabot knows when to update the referenced versions -asciidoctorj-pdf = { module = "org.asciidoctor:asciidoctorj-pdf", version.ref = "asciidoctorj-pdf" } -eclipse-platform = { module = "org.eclipse.platform:org.eclipse.platform", version.ref = "eclipse" } -jacoco = { module = "org.jacoco:jacoco", version.ref = "jacoco" } -jruby = { module = "org.jruby:jruby", version.ref = "jruby" } -junit4-latest = { module = "junit:junit", version.ref = "junit4" } -junit4-bundle = { module = "org.apache.servicemix.bundles:org.apache.servicemix.bundles.junit", version = "4.13.2_1" } -ktlint-cli = { module = "com.pinterest.ktlint:ktlint-cli", version.ref = "ktlint" } +xmlunit-assertj = { module = "org.xmlunit:xmlunit-assertj3", version.ref = "xmlunit" } +xmlunit-jakarta-jaxb-impl = { module = "org.xmlunit:xmlunit-jakarta-jaxb-impl", version.ref = "xmlunit" } +xmlunit-placeholders = { module = "org.xmlunit:xmlunit-placeholders", version.ref = "xmlunit" } [bundles] ant = ["ant", "ant-junit", "ant-junitlauncher"] @@ -105,9 +115,9 @@ foojayResolver = { id = "org.gradle.toolchains.foojay-resolver", version = "1.0. gitPublish = { id = "org.ajoberstar.git-publish", version = "5.1.3" } jmh = { id = "me.champeau.jmh", version = "0.7.3" } jreleaser = { id = "org.jreleaser", version = "1.21.0" } -# check if workaround in gradle.properties can be removed when updating -kotlin = { id = "org.jetbrains.kotlin.jvm", version = "2.2.21" } +kotlin = { id = "org.jetbrains.kotlin.jvm", version = "2.2.21" } # check if workaround in gradle.properties can be removed when updating nullaway = { id = "net.ltgt.nullaway", version = "2.3.0" } plantuml = { id = "io.freefair.plantuml", version = "9.1.0" } +rewrite = { id = "org.openrewrite.rewrite", version = "7.21.0" } shadow = { id = "com.gradleup.shadow", version = "9.2.2" } spotless = { id = "com.diffplug.spotless", version = "8.0.0" } diff --git a/gradle/plugins/common/build.gradle.kts b/gradle/plugins/common/build.gradle.kts index 3e05ad907f86..2193e6f363bf 100644 --- a/gradle/plugins/common/build.gradle.kts +++ b/gradle/plugins/common/build.gradle.kts @@ -19,6 +19,7 @@ dependencies { implementation(libs.plugins.nullaway.markerCoordinates) implementation(libs.plugins.shadow.markerCoordinates) implementation(libs.plugins.spotless.markerCoordinates) + implementation(libs.plugins.rewrite.markerCoordinates) } tasks.compileJava { diff --git a/gradle/plugins/common/src/main/kotlin/junitbuild.base-conventions.gradle.kts b/gradle/plugins/common/src/main/kotlin/junitbuild.base-conventions.gradle.kts index 2e20790e87b7..7d9dbec39f73 100644 --- a/gradle/plugins/common/src/main/kotlin/junitbuild.base-conventions.gradle.kts +++ b/gradle/plugins/common/src/main/kotlin/junitbuild.base-conventions.gradle.kts @@ -2,4 +2,5 @@ plugins { eclipse id("junitbuild.java-toolchain-conventions") id("junitbuild.spotless-conventions") + id("junitbuild.rewrite-conventions") } diff --git a/gradle/plugins/common/src/main/kotlin/junitbuild.rewrite-conventions.gradle.kts b/gradle/plugins/common/src/main/kotlin/junitbuild.rewrite-conventions.gradle.kts new file mode 100644 index 000000000000..f0e615e9a0d0 --- /dev/null +++ b/gradle/plugins/common/src/main/kotlin/junitbuild.rewrite-conventions.gradle.kts @@ -0,0 +1,19 @@ +plugins { + id("org.openrewrite.rewrite") +} + +rewrite { + activeRecipe("org.junit.openrewrite.SanityCheck") + exclusion("**CollectionUtils.java") + setExportDatatables(true) + setFailOnDryRunResults(true) +} + +dependencies { + rewrite(platform("org.openrewrite.recipe:rewrite-recipe-bom:3.17.0")) + rewrite("org.openrewrite.recipe:rewrite-migrate-java:3.20.0") + rewrite("org.openrewrite.recipe:rewrite-java-security:3.19.2") + rewrite("org.openrewrite.recipe:rewrite-rewrite:0.14.1") + rewrite("org.openrewrite.recipe:rewrite-static-analysis:2.20.0") + rewrite("org.openrewrite.recipe:rewrite-third-party:0.30.0") +} diff --git a/gradle/plugins/settings.gradle.kts b/gradle/plugins/settings.gradle.kts index b2ae97139041..0a7c7ad39bd9 100644 --- a/gradle/plugins/settings.gradle.kts +++ b/gradle/plugins/settings.gradle.kts @@ -21,8 +21,9 @@ rootProject.name = "plugins" include("backward-compatibility") include("build-parameters") -include("common") include("code-generator") +include("common") include("publishing") +include("rewrite") enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") diff --git a/junit-platform-commons/src/main/java/org/junit/platform/commons/support/ModifierSupport.java b/junit-platform-commons/src/main/java/org/junit/platform/commons/support/ModifierSupport.java index b1c555e24141..d6687d855e08 100644 --- a/junit-platform-commons/src/main/java/org/junit/platform/commons/support/ModifierSupport.java +++ b/junit-platform-commons/src/main/java/org/junit/platform/commons/support/ModifierSupport.java @@ -14,6 +14,7 @@ import static org.apiguardian.api.API.Status.MAINTAINED; import java.lang.reflect.Member; +import java.lang.reflect.Modifier; import org.apiguardian.api.API; import org.junit.platform.commons.util.ReflectionUtils; @@ -47,7 +48,7 @@ private ModifierSupport() { * * @param clazz the class to check; never {@code null} * @return {@code true} if the class is {@code public} - * @see java.lang.reflect.Modifier#isPublic(int) + * @see Modifier#isPublic(int) */ public static boolean isPublic(Class clazz) { return ReflectionUtils.isPublic(clazz); @@ -58,7 +59,7 @@ public static boolean isPublic(Class clazz) { * * @param member the member to check; never {@code null} * @return {@code true} if the member is {@code public} - * @see java.lang.reflect.Modifier#isPublic(int) + * @see Modifier#isPublic(int) */ public static boolean isPublic(Member member) { return ReflectionUtils.isPublic(member); @@ -69,7 +70,7 @@ public static boolean isPublic(Member member) { * * @param clazz the class to check; never {@code null} * @return {@code true} if the class is {@code private} - * @see java.lang.reflect.Modifier#isPrivate(int) + * @see Modifier#isPrivate(int) */ public static boolean isPrivate(Class clazz) { return ReflectionUtils.isPrivate(clazz); @@ -80,7 +81,7 @@ public static boolean isPrivate(Class clazz) { * * @param member the member to check; never {@code null} * @return {@code true} if the member is {@code private} - * @see java.lang.reflect.Modifier#isPrivate(int) + * @see Modifier#isPrivate(int) */ public static boolean isPrivate(Member member) { return ReflectionUtils.isPrivate(member); @@ -96,9 +97,9 @@ public static boolean isPrivate(Member member) { * * @param clazz the class to check; never {@code null} * @return {@code true} if the class is not {@code private} - * @see java.lang.reflect.Modifier#isPublic(int) - * @see java.lang.reflect.Modifier#isProtected(int) - * @see java.lang.reflect.Modifier#isPrivate(int) + * @see Modifier#isPublic(int) + * @see Modifier#isProtected(int) + * @see Modifier#isPrivate(int) */ public static boolean isNotPrivate(Class clazz) { return ReflectionUtils.isNotPrivate(clazz); @@ -114,9 +115,9 @@ public static boolean isNotPrivate(Class clazz) { * * @param member the member to check; never {@code null} * @return {@code true} if the member is not {@code private} - * @see java.lang.reflect.Modifier#isPublic(int) - * @see java.lang.reflect.Modifier#isProtected(int) - * @see java.lang.reflect.Modifier#isPrivate(int) + * @see Modifier#isPublic(int) + * @see Modifier#isProtected(int) + * @see Modifier#isPrivate(int) */ public static boolean isNotPrivate(Member member) { return ReflectionUtils.isNotPrivate(member); @@ -127,7 +128,7 @@ public static boolean isNotPrivate(Member member) { * * @param clazz the class to check; never {@code null} * @return {@code true} if the class is {@code abstract} - * @see java.lang.reflect.Modifier#isAbstract(int) + * @see Modifier#isAbstract(int) */ public static boolean isAbstract(Class clazz) { return ReflectionUtils.isAbstract(clazz); @@ -138,7 +139,7 @@ public static boolean isAbstract(Class clazz) { * * @param member the class to check; never {@code null} * @return {@code true} if the member is {@code abstract} - * @see java.lang.reflect.Modifier#isAbstract(int) + * @see Modifier#isAbstract(int) */ public static boolean isAbstract(Member member) { return ReflectionUtils.isAbstract(member); @@ -150,7 +151,7 @@ public static boolean isAbstract(Member member) { * @param clazz the class to check; never {@code null} * @return {@code true} if the class is not {@code abstract} * @since 1.13 - * @see java.lang.reflect.Modifier#isAbstract(int) + * @see Modifier#isAbstract(int) */ @API(status = EXPERIMENTAL, since = "6.0") public static boolean isNotAbstract(Class clazz) { @@ -163,7 +164,7 @@ public static boolean isNotAbstract(Class clazz) { * @param member the class to check; never {@code null} * @return {@code true} if the member is not {@code abstract} * @since 1.13 - * @see java.lang.reflect.Modifier#isAbstract(int) + * @see Modifier#isAbstract(int) */ @API(status = EXPERIMENTAL, since = "6.0") public static boolean isNotAbstract(Member member) { @@ -175,7 +176,7 @@ public static boolean isNotAbstract(Member member) { * * @param clazz the class to check; never {@code null} * @return {@code true} if the class is {@code static} - * @see java.lang.reflect.Modifier#isStatic(int) + * @see Modifier#isStatic(int) */ public static boolean isStatic(Class clazz) { return ReflectionUtils.isStatic(clazz); @@ -186,7 +187,7 @@ public static boolean isStatic(Class clazz) { * * @param member the member to check; never {@code null} * @return {@code true} if the member is {@code static} - * @see java.lang.reflect.Modifier#isStatic(int) + * @see Modifier#isStatic(int) */ public static boolean isStatic(Member member) { return ReflectionUtils.isStatic(member); @@ -197,7 +198,7 @@ public static boolean isStatic(Member member) { * * @param clazz the class to check; never {@code null} * @return {@code true} if the class is not {@code static} - * @see java.lang.reflect.Modifier#isStatic(int) + * @see Modifier#isStatic(int) */ public static boolean isNotStatic(Class clazz) { return ReflectionUtils.isNotStatic(clazz); @@ -208,7 +209,7 @@ public static boolean isNotStatic(Class clazz) { * * @param member the member to check; never {@code null} * @return {@code true} if the member is not {@code static} - * @see java.lang.reflect.Modifier#isStatic(int) + * @see Modifier#isStatic(int) */ public static boolean isNotStatic(Member member) { return ReflectionUtils.isNotStatic(member); @@ -220,7 +221,7 @@ public static boolean isNotStatic(Member member) { * @param clazz the class to check; never {@code null} * @return {@code true} if the class is {@code final} * @since 1.5 - * @see java.lang.reflect.Modifier#isFinal(int) + * @see Modifier#isFinal(int) */ @API(status = MAINTAINED, since = "1.5") public static boolean isFinal(Class clazz) { @@ -233,7 +234,7 @@ public static boolean isFinal(Class clazz) { * @param clazz the class to check; never {@code null} * @return {@code true} if the class is not {@code final} * @since 1.5 - * @see java.lang.reflect.Modifier#isFinal(int) + * @see Modifier#isFinal(int) */ @API(status = MAINTAINED, since = "1.5") public static boolean isNotFinal(Class clazz) { @@ -246,7 +247,7 @@ public static boolean isNotFinal(Class clazz) { * @param member the member to check; never {@code null} * @return {@code true} if the member is {@code final} * @since 1.5 - * @see java.lang.reflect.Modifier#isFinal(int) + * @see Modifier#isFinal(int) */ @API(status = MAINTAINED, since = "1.5") public static boolean isFinal(Member member) { @@ -259,7 +260,7 @@ public static boolean isFinal(Member member) { * @param member the member to check; never {@code null} * @return {@code true} if the member is not {@code final} * @since 1.5 - * @see java.lang.reflect.Modifier#isFinal(int) + * @see Modifier#isFinal(int) */ @API(status = MAINTAINED, since = "1.5") public static boolean isNotFinal(Member member) { diff --git a/junit-platform-launcher/src/main/java/org/junit/platform/launcher/listeners/OutputDir.java b/junit-platform-launcher/src/main/java/org/junit/platform/launcher/listeners/OutputDir.java index 925c437d5f1a..7c3ee5a78ef1 100644 --- a/junit-platform-launcher/src/main/java/org/junit/platform/launcher/listeners/OutputDir.java +++ b/junit-platform-launcher/src/main/java/org/junit/platform/launcher/listeners/OutputDir.java @@ -140,7 +140,7 @@ private static boolean containsFilesWithExtensions(Path dir, String... extension return false; }; try (Stream pathStream = Files.find(dir, 1, matcher)) { - return pathStream.findFirst().isPresent(); + return pathStream.findAny().isPresent(); } } } diff --git a/platform-tooling-support-tests/src/test/java/platform/tooling/support/tests/ModularUserGuideTests.java b/platform-tooling-support-tests/src/test/java/platform/tooling/support/tests/ModularUserGuideTests.java index daccabb3f49b..140019e06b7a 100644 --- a/platform-tooling-support-tests/src/test/java/platform/tooling/support/tests/ModularUserGuideTests.java +++ b/platform-tooling-support-tests/src/test/java/platform/tooling/support/tests/ModularUserGuideTests.java @@ -10,6 +10,7 @@ package platform.tooling.support.tests; +import static java.util.function.Predicate.not; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertLinesMatch; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -24,7 +25,6 @@ import java.util.ArrayList; import java.util.List; import java.util.function.Consumer; -import java.util.function.Predicate; import java.util.spi.ToolProvider; import org.junit.jupiter.api.Test; @@ -182,7 +182,8 @@ private static void treeWalk(Path root, Consumer out) { try (var stream = Files.walk(root)) { stream.map(root::relativize) // .map(path -> path.toString().replace('\\', '/')) // - .sorted().filter(Predicate.not(String::isEmpty)) // + .filter(not(String::isEmpty)) // + .sorted() // .forEach(out); } catch (Exception e) { diff --git a/platform-tooling-support-tests/src/test/java/platform/tooling/support/tests/ToolProviderTests.java b/platform-tooling-support-tests/src/test/java/platform/tooling/support/tests/ToolProviderTests.java index d018c629fc7a..dd3a6d8e9189 100644 --- a/platform-tooling-support-tests/src/test/java/platform/tooling/support/tests/ToolProviderTests.java +++ b/platform-tooling-support-tests/src/test/java/platform/tooling/support/tests/ToolProviderTests.java @@ -31,8 +31,8 @@ import java.util.ServiceLoader; import java.util.Set; import java.util.spi.ToolProvider; -import java.util.stream.StreamSupport; +import org.assertj.core.util.Streams; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Order; @@ -90,7 +90,7 @@ static void triggerReleaseOfFileHandlesOnWindows() throws Exception { void findAndRunJUnitOnTheClassPath() { try (var loader = new URLClassLoader("junit", urls(lib), ClassLoader.getPlatformClassLoader())) { var sl = ServiceLoader.load(ToolProvider.class, loader); - var junit = StreamSupport.stream(sl.spliterator(), false).filter(p -> p.name().equals("junit")).findFirst(); + var junit = Streams.stream(sl).filter(p -> p.name().equals("junit")).findFirst(); assertTrue(junit.isPresent(), "Tool 'junit' not found in: " + lib); assertJUnitPrintsHelpMessage(junit.get()); @@ -116,7 +116,7 @@ void findAndRunJUnitOnTheModulePath() { var layer = bootLayer.defineModulesWithOneLoader(configuration, ClassLoader.getPlatformClassLoader()); var sl = ServiceLoader.load(layer, ToolProvider.class); - var junit = StreamSupport.stream(sl.spliterator(), false).filter(p -> p.name().equals("junit")).findFirst(); + var junit = Streams.stream(sl).filter(p -> p.name().equals("junit")).findFirst(); assertTrue(junit.isPresent(), "Tool 'junit' not found in modules: " + modules); assertJUnitPrintsHelpMessage(junit.get()); diff --git a/rewrite.yml b/rewrite.yml new file mode 100644 index 000000000000..4d512770c9d6 --- /dev/null +++ b/rewrite.yml @@ -0,0 +1,19 @@ +--- +type: specs.openrewrite.org/v1beta/recipe +name: org.junit.openrewrite.SanityCheck +displayName: Apply all Java & Gradle best practices +description: Comprehensive code quality recipe combining modernization, security, and best practices. +tags: + - java + - gradle + - static-analysis + - cleanup +recipeList: + - org.openrewrite.gradle.EnableGradleBuildCache + - org.openrewrite.gradle.EnableGradleParallelExecution + - org.openrewrite.gradle.GradleBestPractices + - org.openrewrite.java.format.NormalizeLineBreaks + - org.openrewrite.java.format.RemoveTrailingWhitespace + - org.openrewrite.java.migrate.UpgradeToJava17 + - tech.picnic.errorprone.refasterrules.StreamRulesRecipes +---