[Gradle] Keep "-publishable" configurations as dependencyScope
As they would clash with the ones that is intended to be consumed as project dependencies. It will not be compatible with future Gradle versions. This should be fixed with KT-49919 ^KT-60879
This commit is contained in:
+5
-4
@@ -17,6 +17,8 @@ import org.jetbrains.kotlin.gradle.plugin.KotlinPluginLifecycle
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinTargetComponent
|
||||
import org.jetbrains.kotlin.gradle.plugin.launchInStage
|
||||
import org.jetbrains.kotlin.gradle.utils.copyAttributes
|
||||
import org.jetbrains.kotlin.gradle.utils.createDependencyScope
|
||||
import org.jetbrains.kotlin.gradle.utils.findDependencyScope
|
||||
import org.jetbrains.kotlin.tooling.core.UnsafeApi
|
||||
|
||||
internal fun KotlinTargetSoftwareComponent(
|
||||
@@ -32,10 +34,9 @@ internal fun KotlinTargetSoftwareComponent(
|
||||
/* Explicitly typing 'Project' to avoid smart cast from 'target.project as ProjectInternal' */
|
||||
val project: Project = target.project
|
||||
val publishedConfigurationName = publishedConfigurationName(kotlinUsageContext.name)
|
||||
val configuration = project.configurations.findByName(publishedConfigurationName)
|
||||
?: project.configurations.create(publishedConfigurationName).also { publishedConfiguration ->
|
||||
publishedConfiguration.isCanBeConsumed = false
|
||||
publishedConfiguration.isCanBeResolved = false
|
||||
val configuration = project.configurations.findDependencyScope(publishedConfigurationName)
|
||||
?: project.configurations.createDependencyScope(publishedConfigurationName).also { publishedConfiguration ->
|
||||
publishedConfiguration.isVisible = false
|
||||
publishedConfiguration.extendsFrom(project.configurations.getByName(kotlinUsageContext.dependencyConfigurationName))
|
||||
publishedConfiguration.artifacts.addAll(kotlinUsageContext.artifacts)
|
||||
copyAttributes(from = kotlinUsageContext.attributes, to = publishedConfiguration.attributes)
|
||||
|
||||
+7
-3
@@ -46,14 +46,18 @@ fun <T : DecoratedExternalKotlinTarget> KotlinMultiplatformExtension.createExter
|
||||
val sourcesElementsConfiguration = project.configurations
|
||||
.maybeCreateConsumable(lowerCamelCaseName(descriptor.targetName, "sourcesElements"))
|
||||
|
||||
fun Configuration.notVisible() = apply { isVisible = false }
|
||||
val apiElementsPublishedConfiguration = project.configurations
|
||||
.maybeCreateConsumable(lowerCamelCaseName(descriptor.targetName, "apiElements-published"))
|
||||
.maybeCreateDependencyScope(lowerCamelCaseName(descriptor.targetName, "apiElements-published"))
|
||||
.notVisible()
|
||||
|
||||
val runtimeElementsPublishedConfiguration = project.configurations
|
||||
.maybeCreateConsumable(lowerCamelCaseName(descriptor.targetName, "runtimeElements-published"))
|
||||
.maybeCreateDependencyScope(lowerCamelCaseName(descriptor.targetName, "runtimeElements-published"))
|
||||
.notVisible()
|
||||
|
||||
val sourcesElementsPublishedConfiguration = project.configurations
|
||||
.maybeCreateConsumable(lowerCamelCaseName(descriptor.targetName, "sourcesElements-published"))
|
||||
.maybeCreateDependencyScope(lowerCamelCaseName(descriptor.targetName, "sourcesElements-published"))
|
||||
.notVisible()
|
||||
|
||||
val kotlinTargetComponent = ExternalKotlinTargetComponent(
|
||||
ExternalKotlinTargetComponent.TargetProvider.byTargetName(this, descriptor.targetName)
|
||||
|
||||
Reference in New Issue
Block a user