From ddbdfc76bc7ee665bb5e177aef5f80b7b75c10d4 Mon Sep 17 00:00:00 2001 From: "Alexander.Glukhov" Date: Thu, 24 Aug 2023 15:41:56 +0200 Subject: [PATCH] [gradle] [IDEA-330622] use Gradle 8.3 for tests GitOrigin-RevId: d0531e4bf18079d4ba38f08a480e3966e809c7a5 --- .../test/events/GradleExecutionTestCase.kt | 2 ++ .../test/events/GradleTestAssertionTest.kt | 4 ++-- .../test/events/GradleTestExecutionTest.kt | 7 ++++++- .../util/resolve/DependencyResolverImpl.java | 14 +++++++++++--- .../plugins/gradle/tooling/VersionMatcherRule.java | 4 ++-- 5 files changed, 23 insertions(+), 8 deletions(-) diff --git a/plugins/gradle/java/testSources/execution/test/events/GradleExecutionTestCase.kt b/plugins/gradle/java/testSources/execution/test/events/GradleExecutionTestCase.kt index c98a312ff9a7..042aaa36d1ff 100644 --- a/plugins/gradle/java/testSources/execution/test/events/GradleExecutionTestCase.kt +++ b/plugins/gradle/java/testSources/execution/test/events/GradleExecutionTestCase.kt @@ -27,6 +27,8 @@ abstract class GradleExecutionTestCase : GradleExecutionBaseTestCase() { return isGradleAtLeast("7.6") } + fun isTestLauncherUsed(): Boolean = isGradleAtLeast("8.3") + fun testJunit5Project(gradleVersion: GradleVersion, action: () -> Unit) { assumeThatJunit5IsSupported(gradleVersion) testJavaProject(gradleVersion, action) diff --git a/plugins/gradle/java/testSources/execution/test/events/GradleTestAssertionTest.kt b/plugins/gradle/java/testSources/execution/test/events/GradleTestAssertionTest.kt index efa8e9ab97fb..ca8a372268ab 100644 --- a/plugins/gradle/java/testSources/execution/test/events/GradleTestAssertionTest.kt +++ b/plugins/gradle/java/testSources/execution/test/events/GradleTestAssertionTest.kt @@ -350,7 +350,7 @@ class GradleTestAssertionTest : GradleExecutionTestCase() { """.trimMargin()) } assertNode("test assert equals for objects") { - if (isBuiltInTestEventsUsed()) { + if (isBuiltInTestEventsUsed() && !isTestLauncherUsed()) { assertTestConsoleContains(""" | |assertion message @@ -370,7 +370,7 @@ class GradleTestAssertionTest : GradleExecutionTestCase() { } } assertNode("test assert equals for same objects") { - if (isBuiltInTestEventsUsed()) { + if (isBuiltInTestEventsUsed() && !isTestLauncherUsed()) { assertTestConsoleContains(""" | |assertion message diff --git a/plugins/gradle/java/testSources/execution/test/events/GradleTestExecutionTest.kt b/plugins/gradle/java/testSources/execution/test/events/GradleTestExecutionTest.kt index 29b22457b322..292ba938b671 100644 --- a/plugins/gradle/java/testSources/execution/test/events/GradleTestExecutionTest.kt +++ b/plugins/gradle/java/testSources/execution/test/events/GradleTestExecutionTest.kt @@ -77,7 +77,12 @@ class GradleTestExecutionTest : GradleExecutionTestCase() { } } } - assertNode("There were failing tests. See the report at: .*".toRegex()) + if (!isTestLauncherUsed()) { + assertNode("There were failing tests. See the report at: .*".toRegex()) + } + } + if (isTestLauncherUsed()) { + assertNode("Test failed.") } } } diff --git a/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/util/resolve/DependencyResolverImpl.java b/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/util/resolve/DependencyResolverImpl.java index 09b28eab6881..16d768e94932 100644 --- a/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/util/resolve/DependencyResolverImpl.java +++ b/plugins/gradle/tooling-extension-impl/src/org/jetbrains/plugins/gradle/tooling/util/resolve/DependencyResolverImpl.java @@ -53,8 +53,9 @@ import static java.util.Collections.*; public final class DependencyResolverImpl implements DependencyResolver { private static final Logger LOG = LoggerFactory.getLogger(DependencyResolverImpl.class); - private static final boolean IS_NEW_DEPENDENCY_RESOLUTION_APPLICABLE = - GradleVersion.current().getBaseVersion().compareTo(GradleVersion.version("4.5")) >= 0; + private static final GradleVersion GRADLE_BASE_VERSION = GradleVersion.current().getBaseVersion(); + private static final boolean IS_83_OR_BETTER = GRADLE_BASE_VERSION.compareTo(GradleVersion.version("8.3")) >= 0; + private static final boolean IS_NEW_DEPENDENCY_RESOLUTION_APPLICABLE = GRADLE_BASE_VERSION.compareTo(GradleVersion.version("4.5")) >= 0; private final @NotNull ModelBuilderContext myContext; private final @NotNull Project myProject; @@ -264,7 +265,14 @@ public final class DependencyResolverImpl implements DependencyResolver { } ProjectComponentIdentifier projectComponentIdentifier = (ProjectComponentIdentifier)artifact.getId().getComponentIdentifier(); - String buildName = projectComponentIdentifier.getBuild().getName(); + BuildIdentifier buildIdentifier = projectComponentIdentifier.getBuild(); + String buildName; + if (IS_83_OR_BETTER) { + buildName = buildIdentifier.getBuildPath(); + } + else { + buildName = buildIdentifier.getName(); + } String projectPath = projectComponentIdentifier.getProjectPath(); String key = buildName + "_" + projectPath + "_" + resolvedDependency.getConfiguration(); DefaultExternalProjectDependency projectDependency = resolvedProjectDependencies.get(key); diff --git a/plugins/gradle/tooling-extension-impl/testSources/org/jetbrains/plugins/gradle/tooling/VersionMatcherRule.java b/plugins/gradle/tooling-extension-impl/testSources/org/jetbrains/plugins/gradle/tooling/VersionMatcherRule.java index 61955dec3450..909199b6b00c 100644 --- a/plugins/gradle/tooling-extension-impl/testSources/org/jetbrains/plugins/gradle/tooling/VersionMatcherRule.java +++ b/plugins/gradle/tooling-extension-impl/testSources/org/jetbrains/plugins/gradle/tooling/VersionMatcherRule.java @@ -32,9 +32,9 @@ public class VersionMatcherRule extends TestWatcher { "5.0", /*"5.1", "5.2", "5.3.1", "5.4.1", "5.5.1",*/ "5.6.2", "6.0", /* "6.0.1", "6.1", "6.2", "6.3", "6.4", "6.8.3", */ "6.9", "7.0.2", /* "7.1", "7.2", "7.4", "7.5.1", */ "7.6", - "8.0", "8.2" + "8.0", /*"8.2",*/ "8.3" }; - public static final String BASE_GRADLE_VERSION = "8.2"; + public static final String BASE_GRADLE_VERSION = "8.3"; @Nullable private CustomMatcher myMatcher;