diff --git a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineTesting.java b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineTesting.java index 6b829cc59..e75d427f3 100644 --- a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineTesting.java +++ b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineTesting.java @@ -28,7 +28,6 @@ import org.gradle.api.Task; import org.gradle.api.artifacts.component.ModuleComponentIdentifier; import org.gradle.api.artifacts.result.ResolvedComponentResult; -import org.gradle.api.plugins.JavaPlugin; import org.gradle.api.plugins.JavaPluginConvention; import org.gradle.api.provider.Property; import org.gradle.api.tasks.SourceSet; @@ -63,7 +62,7 @@ public void apply(Project project) { } }); - project.getPlugins().withType(JavaPlugin.class, unusedPlugin -> { + project.getPluginManager().withPlugin("java-base", unusedPlugin -> { TaskProvider checkJUnitDependencies = project.getTasks().register("checkJUnitDependencies", CheckJUnitDependencies.class); @@ -120,8 +119,8 @@ private static void ifHasResolvedCompileDependenciesMatching( .afterResolve(deps -> { boolean anyMatch = deps.getResolutionResult().getAllComponents().stream() .map(ResolvedComponentResult::getId) - .filter(componentId -> componentId instanceof ModuleComponentIdentifier) - .map(componentId -> (ModuleComponentIdentifier) componentId) + .filter(ModuleComponentIdentifier.class::isInstance) + .map(ModuleComponentIdentifier.class::cast) .anyMatch(spec); if (anyMatch) { @@ -179,9 +178,9 @@ public static boolean useJUnitPlatformEnabled(Test task) { if (GradleVersion.current().compareTo(GradleVersion.version("7.3")) < 0) { return task.getOptions() instanceof JUnitPlatformOptions; } - Property testFramework = - getTestFrameworkWithReflection(task); - return testFramework.isPresent() && (testFramework.get().getOptions() instanceof JUnitPlatformOptions); + return getTestFrameworkWithReflection(task) + .map(org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestFramework.class::isInstance) + .getOrElse(false); } @SuppressWarnings("IllegalImports") diff --git a/gradle-baseline-java/src/test/groovy/com/palantir/baseline/BaselineTestingIntegrationTest.groovy b/gradle-baseline-java/src/test/groovy/com/palantir/baseline/BaselineTestingIntegrationTest.groovy index f3312ed40..833025223 100644 --- a/gradle-baseline-java/src/test/groovy/com/palantir/baseline/BaselineTestingIntegrationTest.groovy +++ b/gradle-baseline-java/src/test/groovy/com/palantir/baseline/BaselineTestingIntegrationTest.groovy @@ -107,17 +107,19 @@ class BaselineTestingIntegrationTest extends IntegrationSpec { file('src/integrationTest/java/test/TestClass5.java') << junit5Test then: - runTasksSuccessfully('integrationTest') + // Explicitly testing broken state that needs fixing before gradle 8 + runTasksSuccessfully('-DignoreDeprecations=true', 'integrationTest') fileExists("build/reports/tests/integrationTest/classes/test.TestClass5.html") } def 'runs nebula-test version 10+ tests that require junit platform'() { + when: buildFile << standardBuildFile buildFile << ''' apply plugin: 'groovy' dependencies { - testImplementation 'com.netflix.nebula:nebula-test:10.0.0' + testImplementation 'com.netflix.nebula:nebula-test:10.2.0' } '''.stripIndent(true) @@ -128,11 +130,9 @@ class BaselineTestingIntegrationTest extends IntegrationSpec { } '''.stripIndent(true) - when: - runTasksSuccessfully('test') - then: - true + // Explicitly testing broken state that needs fixing before gradle 8 + runTasksSuccessfully('-DignoreDeprecations=true', 'test') } def 'checkJUnitDependencies ensures mixture of junit4 and 5 tests => legacy must be present'() { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e750102e0..2e6e5897b 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists