[Gradle] Create deprecated configurations as some projects are still...
...dependending on them.
This commit is contained in:
committed by
Space Team
parent
ee3034328b
commit
26c1b931c8
+28
-12
@@ -19,6 +19,7 @@ import org.jetbrains.kotlin.gradle.targets.js.KotlinJsCompilerAttribute
|
||||
import org.jetbrains.kotlin.gradle.targets.js.KotlinJsTarget
|
||||
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrTarget
|
||||
import org.jetbrains.kotlin.gradle.targets.metadata.isKotlinGranularMetadataEnabled
|
||||
import org.jetbrains.kotlin.gradle.utils.maybeRegister
|
||||
import java.io.File
|
||||
|
||||
internal abstract class KotlinSourceSetFactory<T : KotlinSourceSet> internal constructor(
|
||||
@@ -74,20 +75,35 @@ internal class DefaultKotlinSourceSetFactory(
|
||||
super.setUpSourceSetDefaults(sourceSet)
|
||||
sourceSet.resources.srcDir(defaultSourceFolder(project, sourceSet.name, "resources"))
|
||||
|
||||
project.configurations.maybeCreate(sourceSet.intransitiveMetadataConfigurationName).apply {
|
||||
attributes.attribute(KotlinPlatformType.attribute, KotlinPlatformType.common)
|
||||
attributes.attribute(Usage.USAGE_ATTRIBUTE, project.usageByName(KotlinUsages.KOTLIN_API))
|
||||
attributes.attribute(Category.CATEGORY_ATTRIBUTE, project.categoryByName(Category.LIBRARY))
|
||||
isVisible = false
|
||||
isCanBeConsumed = false
|
||||
isCanBeResolved = true
|
||||
val dependencyConfigurationWithMetadata = with(sourceSet) {
|
||||
@Suppress("DEPRECATION")
|
||||
listOf(
|
||||
apiConfigurationName to apiMetadataConfigurationName,
|
||||
implementationConfigurationName to implementationMetadataConfigurationName,
|
||||
compileOnlyConfigurationName to compileOnlyMetadataConfigurationName,
|
||||
null to intransitiveMetadataConfigurationName
|
||||
)
|
||||
}
|
||||
|
||||
if (project.isKotlinGranularMetadataEnabled) {
|
||||
attributes.attribute(Usage.USAGE_ATTRIBUTE, project.usageByName(KotlinUsages.KOTLIN_METADATA))
|
||||
}
|
||||
dependencyConfigurationWithMetadata.forEach { (configurationName, metadataName) ->
|
||||
project.configurations.maybeRegister(metadataName) {
|
||||
attributes.attribute(KotlinPlatformType.attribute, KotlinPlatformType.common)
|
||||
attributes.attribute(Usage.USAGE_ATTRIBUTE, project.usageByName(KotlinUsages.KOTLIN_API))
|
||||
attributes.attribute(Category.CATEGORY_ATTRIBUTE, project.categoryByName(Category.LIBRARY))
|
||||
isVisible = false
|
||||
isCanBeConsumed = false
|
||||
|
||||
project.afterEvaluate {
|
||||
setJsCompilerIfNecessary(sourceSet, this@apply)
|
||||
if (configurationName != null) {
|
||||
extendsFrom(project.configurations.maybeCreate(configurationName))
|
||||
}
|
||||
|
||||
if (project.isKotlinGranularMetadataEnabled) {
|
||||
attributes.attribute(Usage.USAGE_ATTRIBUTE, project.usageByName(KotlinUsages.KOTLIN_METADATA))
|
||||
}
|
||||
|
||||
project.afterEvaluate {
|
||||
setJsCompilerIfNecessary(sourceSet, this)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+15
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.gradle.utils
|
||||
|
||||
import org.gradle.api.DomainObjectCollection
|
||||
import org.gradle.api.NamedDomainObjectContainer
|
||||
import org.gradle.api.NamedDomainObjectProvider
|
||||
import org.gradle.api.Task
|
||||
import org.gradle.api.tasks.TaskCollection
|
||||
import org.gradle.api.tasks.TaskProvider
|
||||
@@ -29,3 +30,17 @@ internal fun <T> NamedDomainObjectContainer<T>.getOrCreate(
|
||||
if (invokeWhenCreated != null) invokeWhenCreated(value)
|
||||
}
|
||||
}
|
||||
|
||||
internal fun <T> NamedDomainObjectContainer<T>.maybeRegister(
|
||||
name: String,
|
||||
configure: (T.() -> Unit)? = null
|
||||
): NamedDomainObjectProvider<T> {
|
||||
val entity = if (name in names) {
|
||||
named(name)
|
||||
} else {
|
||||
register(name)
|
||||
}
|
||||
|
||||
if (configure != null) entity.configure(configure)
|
||||
return entity
|
||||
}
|
||||
Reference in New Issue
Block a user