From 1833347a7dec9125f357351b458fdce7338a02dc Mon Sep 17 00:00:00 2001 From: Anton Lakotka Date: Wed, 29 Mar 2023 13:27:15 +0200 Subject: [PATCH] [Gradle] Check that *sourcesElements is not exposed withSourcesJar(publish=false) ^KT-57652 In Progress --- .../kotlin/gradle/unitTests/MppPublicationTest.kt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/unitTests/MppPublicationTest.kt b/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/unitTests/MppPublicationTest.kt index 2fb46f51473..6da8daee9b0 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/unitTests/MppPublicationTest.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/unitTests/MppPublicationTest.kt @@ -201,6 +201,18 @@ class MppPublicationTest { } } + @Test + fun `test that no sourcesElements should be exposed when sources are not published`() { + kotlin.linuxX64("linux") + kotlin.withSourcesJar(publish = false) + + project.evaluate() + kotlin.targets.forEach { + if (it.sourcesElementsConfigurationName in project.configurations.names) + fail("Configuration '${it.sourcesElementsConfigurationName}' should not be created") + } + } + private fun SoftwareComponent.attributesOfUsageContext(usageContextName: String): AttributeContainer { this as SoftwareComponentInternal return usages.first { it.name == usageContextName }.attributes