From c49f08f4273e6ad759de22ff1e1801619d1dd3ef Mon Sep 17 00:00:00 2001 From: Anton Lakotka Date: Thu, 18 May 2023 16:50:34 +0200 Subject: [PATCH] [Gradle] Test type safe project accessors with KotlinDependencyHandler KT-58759 Verification Pending --- .../kotlin/gradle/HierarchicalMppIT.kt | 19 ++++++++++++++ .../bar/build.gradle.kts | 8 ++++++ .../build.gradle.kts | 25 +++++++++++++++++++ .../foo/build.gradle.kts | 8 ++++++ .../settings.gradle.kts | 5 ++++ 5 files changed, 65 insertions(+) create mode 100644 libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/mpp-project-with-type-safe-accessors/bar/build.gradle.kts create mode 100644 libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/mpp-project-with-type-safe-accessors/build.gradle.kts create mode 100644 libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/mpp-project-with-type-safe-accessors/foo/build.gradle.kts create mode 100644 libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/mpp-project-with-type-safe-accessors/settings.gradle.kts 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 c5a160b8b7e..33f9d8d0d11 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 @@ -1191,6 +1191,25 @@ open class HierarchicalMppIT : KGPBaseTest() { } } + @GradleTest + @GradleTestVersions(minVersion = TestVersions.Gradle.G_7_0) + fun `test type safe project accessors with KotlinDependencyHandler`(gradleVersion: GradleVersion) { + project("mpp-project-with-type-safe-accessors", gradleVersion) { + build("help") { + println(output) + val actualDependencies = output.lineSequence() + .filter { it.startsWith("PROJECT_DEPENDENCY: ") } + .map { it.removePrefix("PROJECT_DEPENDENCY: ") } + .toList() + + assertEquals( + listOf(":foo", ":bar"), + actualDependencies + ) + } + } + } + private fun TestProject.testDependencyTransformations( subproject: String? = null, diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/mpp-project-with-type-safe-accessors/bar/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/mpp-project-with-type-safe-accessors/bar/build.gradle.kts new file mode 100644 index 00000000000..75287ba49f4 --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/mpp-project-with-type-safe-accessors/bar/build.gradle.kts @@ -0,0 +1,8 @@ +plugins { + kotlin("multiplatform") +} + +kotlin { + jvm() + linuxX64() +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/mpp-project-with-type-safe-accessors/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/mpp-project-with-type-safe-accessors/build.gradle.kts new file mode 100644 index 00000000000..0208362b70a --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/mpp-project-with-type-safe-accessors/build.gradle.kts @@ -0,0 +1,25 @@ +plugins { + kotlin("multiplatform") +} + +kotlin { + jvm() + linuxX64() + + sourceSets { + commonMain { + dependencies { + api(projects.foo) + api(projects.bar) { } + } + } + } +} + +afterEvaluate { + configurations + .getByName("commonMainApi") + .dependencies + .filterIsInstance() + .forEach { println("PROJECT_DEPENDENCY: ${it.dependencyProject.path}") } +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/mpp-project-with-type-safe-accessors/foo/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/mpp-project-with-type-safe-accessors/foo/build.gradle.kts new file mode 100644 index 00000000000..75287ba49f4 --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/mpp-project-with-type-safe-accessors/foo/build.gradle.kts @@ -0,0 +1,8 @@ +plugins { + kotlin("multiplatform") +} + +kotlin { + jvm() + linuxX64() +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/mpp-project-with-type-safe-accessors/settings.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/mpp-project-with-type-safe-accessors/settings.gradle.kts new file mode 100644 index 00000000000..1abdf0ac9d9 --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/mpp-project-with-type-safe-accessors/settings.gradle.kts @@ -0,0 +1,5 @@ + +include(":foo") +include(":bar") + +enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") \ No newline at end of file