[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 {
|
||||
if (target.internal.isSourcesPublishable) {
|
||||
configurations.maybeCreate(target.sourcesElementsConfigurationName).apply {
|
||||
description = "Source files of main compilation of ${target.name}."
|
||||
isVisible = false
|
||||
isCanBeResolved = false
|
||||
isCanBeConsumed = true
|
||||
configureSourcesPublicationAttributes(target)
|
||||
}
|
||||
}
|
||||
configurations.maybeCreate(target.sourcesElementsConfigurationName).apply {
|
||||
description = "Source files of main compilation of ${target.name}."
|
||||
isVisible = false
|
||||
isCanBeResolved = false
|
||||
isCanBeConsumed = true
|
||||
configureSourcesPublicationAttributes(target)
|
||||
project.whenEvaluated { isCanBeConsumed = target.internal.isSourcesPublishable }
|
||||
}
|
||||
|
||||
if (createTestCompilation) {
|
||||
|
||||
+15
-3
@@ -202,14 +202,26 @@ class MppPublicationTest {
|
||||
}
|
||||
|
||||
@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.withSourcesJar(publish = false)
|
||||
|
||||
project.evaluate()
|
||||
kotlin.targets.forEach {
|
||||
if (it.sourcesElementsConfigurationName in project.configurations.names)
|
||||
fail("Configuration '${it.sourcesElementsConfigurationName}' should not be created")
|
||||
val sourcesElements = project.configurations.getByName(it.sourcesElementsConfigurationName)
|
||||
if (sourcesElements.isCanBeConsumed) fail("Configuration '${it.sourcesElementsConfigurationName}' should not be consumable")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user