[Gradle] Mark sourcesElements configurations as non-consumable
In case if `isSourcesPublishable` set to false. ^KT-57652 Verification Pending
This commit is contained in:
committed by
Space Team
parent
0b07a20a70
commit
118c62cfbb
+7
-10
@@ -201,16 +201,13 @@ abstract class AbstractKotlinTargetConfigurator<KotlinTargetType : KotlinTarget>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
project.whenEvaluated {
|
configurations.maybeCreate(target.sourcesElementsConfigurationName).apply {
|
||||||
if (target.internal.isSourcesPublishable) {
|
description = "Source files of main compilation of ${target.name}."
|
||||||
configurations.maybeCreate(target.sourcesElementsConfigurationName).apply {
|
isVisible = false
|
||||||
description = "Source files of main compilation of ${target.name}."
|
isCanBeResolved = false
|
||||||
isVisible = false
|
isCanBeConsumed = true
|
||||||
isCanBeResolved = false
|
configureSourcesPublicationAttributes(target)
|
||||||
isCanBeConsumed = true
|
project.whenEvaluated { isCanBeConsumed = target.internal.isSourcesPublishable }
|
||||||
configureSourcesPublicationAttributes(target)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (createTestCompilation) {
|
if (createTestCompilation) {
|
||||||
|
|||||||
+15
-3
@@ -202,14 +202,26 @@ class MppPublicationTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `test that no sourcesElements should be exposed when sources are not published`() {
|
fun `test that no sourcesElements should be consumable when sources are published`() {
|
||||||
|
kotlin.linuxX64("linux")
|
||||||
|
kotlin.withSourcesJar(publish = true)
|
||||||
|
|
||||||
|
project.evaluate()
|
||||||
|
kotlin.targets.forEach {
|
||||||
|
val sourcesElements = project.configurations.getByName(it.sourcesElementsConfigurationName)
|
||||||
|
if (!sourcesElements.isCanBeConsumed) fail("Configuration '${it.sourcesElementsConfigurationName}' should be consumable")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `test that no sourcesElements should be consumable when sources are not published`() {
|
||||||
kotlin.linuxX64("linux")
|
kotlin.linuxX64("linux")
|
||||||
kotlin.withSourcesJar(publish = false)
|
kotlin.withSourcesJar(publish = false)
|
||||||
|
|
||||||
project.evaluate()
|
project.evaluate()
|
||||||
kotlin.targets.forEach {
|
kotlin.targets.forEach {
|
||||||
if (it.sourcesElementsConfigurationName in project.configurations.names)
|
val sourcesElements = project.configurations.getByName(it.sourcesElementsConfigurationName)
|
||||||
fail("Configuration '${it.sourcesElementsConfigurationName}' should not be created")
|
if (sourcesElements.isCanBeConsumed) fail("Configuration '${it.sourcesElementsConfigurationName}' should not be consumable")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user