From 32be35051d2180d0ddb070073033dce4b8e9b05c Mon Sep 17 00:00:00 2001 From: Anton Lakotka Date: Fri, 23 Feb 2024 07:49:55 +0100 Subject: [PATCH] [Gradle] Test that metadata compilation for bug KT-65954 doesn't fail Metadata compilation should not fail when test source set has dependency with higher version ^KT-65954 Verification Pending --- .../kotlin/gradle/HierarchicalMppIT.kt | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/HierarchicalMppIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/HierarchicalMppIT.kt index f8cbd6e75b8..2e9be140c1d 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/HierarchicalMppIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/HierarchicalMppIT.kt @@ -1266,6 +1266,38 @@ open class HierarchicalMppIT : KGPBaseTest() { } } + @GradleTest + @DisplayName("KT-65954 Metadata Compilation should not fail when test source set has higher version of a library") + fun kt65954MetadataCompilationShouldNotFail(gradleVersion: GradleVersion, @TempDir tempDir: Path) { + // publish version 1.0 + publishThirdPartyLib(withGranularMetadata = true, gradleVersion = gradleVersion, localRepoDir = tempDir) + + // publish version 2.0 + publishThirdPartyLib(withGranularMetadata = true, gradleVersion = gradleVersion, localRepoDir = tempDir) { + buildGradleKts.appendText("\nversion = \"2.0\"\n") + } + + nativeProject( + "my-lib-foo".withPrefix, + gradleVersion, + localRepoDir = tempDir, + ).run { + // add a dependency from commonTest on 2.0 version + buildGradleKts.appendText( + """ + + kotlin.sourceSets.getByName("jvmTest").dependencies { + implementation("com.example.thirdparty:third-party-lib:2.0") + } + """.trimIndent() + ) + build(":compileJvmAndJsMainKotlinMetadata") { + assertTasksExecuted(":compileJvmAndJsMainKotlinMetadata") + } + } + } + + private fun TestProject.testDependencyTransformations( subproject: String? = null, check: BuildResult.(reports: Iterable) -> Unit,