From 792c08ec7ddbb27f9f710716166d9b478596f3f0 Mon Sep 17 00:00:00 2001 From: Anton Lakotka Date: Mon, 22 May 2023 13:44:22 +0200 Subject: [PATCH] [Gradle] Test CInterop commonization doesn't trigger configuration resolution ...before taskGraph is ready KT-56858 Verification Pending --- .../gradle/MppCInteropDependencyTransformationIT.kt | 5 ++++- .../build.gradle.kts | 13 +++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/MppCInteropDependencyTransformationIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/MppCInteropDependencyTransformationIT.kt index 872ca3b9518..652f60cd8e2 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/MppCInteropDependencyTransformationIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/MppCInteropDependencyTransformationIT.kt @@ -96,6 +96,9 @@ abstract class MppCInteropDependencyTransformationIT : BaseGradleIT() { /* Assert p2 & p3 compiled tests */ assertTasksExecuted(":p2:compileTestKotlinLinuxX64") assertTasksExecuted(":p3:compileTestKotlinLinuxX64") + + /* Configurations should not be resolved during configuration phase */ + assertNotContains("Configuration resolved before Task Graph is ready") } } @@ -257,7 +260,7 @@ abstract class MppCInteropDependencyTransformationIT : BaseGradleIT() { ) project.build(":p3:transformNativeMainCInteropDependenciesMetadata", options = repositoryDependencyOptions) { assertSuccessful() - /* Same binaries to transform; but the outputs are different (transformed libraries file) */ + /* Same binaries to transform; but project(":p2") is excluded from Task Inputs now */ assertTasksExecuted(":p3:transformNativeMainCInteropDependenciesMetadata") } } diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/cinterop-MetadataDependencyTransformation/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/cinterop-MetadataDependencyTransformation/build.gradle.kts index 06c497070a9..0bf6a9548f7 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/cinterop-MetadataDependencyTransformation/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/cinterop-MetadataDependencyTransformation/build.gradle.kts @@ -1,4 +1,5 @@ import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension +import java.util.concurrent.atomic.AtomicBoolean plugins { kotlin("multiplatform") apply false @@ -21,3 +22,15 @@ allprojects { } } } + +// Setup configuration resolution hook +// Report configurations that is going to be resolved before the task graph is ready +val isResolutionAllowed = AtomicBoolean(false) +project.gradle.taskGraph.whenReady { isResolutionAllowed.set(true) } + +configurations.all { + incoming.beforeResolve { + if (isResolutionAllowed.get()) return@beforeResolve + println("!!!Configuration resolved before Task Graph is ready: $name") + } +} \ No newline at end of file