Remove metadataConfiguration for source set and reuse
resolvableMetadataConfiguration
This commit is contained in:
committed by
Space Team
parent
0690613082
commit
eaa3eadc9e
-4
@@ -25,7 +25,6 @@ interface KotlinSourceSet : Named, HasKotlinDependencies {
|
||||
fun dependsOn(other: KotlinSourceSet)
|
||||
val dependsOn: Set<KotlinSourceSet>
|
||||
|
||||
val metadataLibrariesConfigurationName: String
|
||||
@Deprecated(message = "KT-55312")
|
||||
val apiMetadataConfigurationName: String
|
||||
@Deprecated(message = "KT-55312")
|
||||
@@ -35,9 +34,6 @@ interface KotlinSourceSet : Named, HasKotlinDependencies {
|
||||
@Deprecated(message = "KT-55230: RuntimeOnly scope is not supported for metadata dependency transformation")
|
||||
val runtimeOnlyMetadataConfigurationName: String
|
||||
|
||||
override val relatedConfigurationNames: List<String>
|
||||
get() = super.relatedConfigurationNames + metadataLibrariesConfigurationName
|
||||
|
||||
companion object {
|
||||
const val COMMON_MAIN_SOURCE_SET_NAME = "commonMain"
|
||||
const val COMMON_TEST_SOURCE_SET_NAME = "commonTest"
|
||||
|
||||
-1
@@ -86,7 +86,6 @@ private fun KotlinTarget.excludeStdlibAndKotlinTestCommonFromPlatformCompilation
|
||||
compilations.all {
|
||||
listOfNotNull(
|
||||
it.compileDependencyConfigurationName,
|
||||
it.defaultSourceSet.metadataLibrariesConfigurationName,
|
||||
(it as? KotlinCompilationToRunnableFiles<*>)?.runtimeDependencyConfigurationName,
|
||||
|
||||
// Additional configurations for (old) jvmWithJava-preset. Remove it when we drop it completely
|
||||
|
||||
-3
@@ -45,9 +45,6 @@ abstract class DefaultKotlinSourceSet @Inject constructor(
|
||||
override val runtimeOnlyConfigurationName: String
|
||||
get() = disambiguateName(RUNTIME_ONLY)
|
||||
|
||||
override val metadataLibrariesConfigurationName: String
|
||||
get() = disambiguateName(METADATA_CONFIGURATION_NAME_SUFFIX)
|
||||
|
||||
@Deprecated("KT-55312")
|
||||
override val apiMetadataConfigurationName: String
|
||||
get() = lowerCamelCaseName(apiConfigurationName, METADATA_CONFIGURATION_NAME_SUFFIX)
|
||||
|
||||
+12
-27
@@ -74,35 +74,20 @@ internal class DefaultKotlinSourceSetFactory(
|
||||
super.setUpSourceSetDefaults(sourceSet)
|
||||
sourceSet.resources.srcDir(defaultSourceFolder(project, sourceSet.name, "resources"))
|
||||
|
||||
val dependencyConfigurationWithMetadata = with(sourceSet) {
|
||||
listOf(
|
||||
listOf(apiConfigurationName, implementationConfigurationName, compileOnlyConfigurationName) to metadataLibrariesConfigurationName,
|
||||
null to intransitiveMetadataConfigurationName
|
||||
)
|
||||
}
|
||||
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
|
||||
|
||||
dependencyConfigurationWithMetadata.forEach { (configurationNames, metadataName) ->
|
||||
project.configurations.maybeCreate(metadataName).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
|
||||
if (project.isKotlinGranularMetadataEnabled) {
|
||||
attributes.attribute(Usage.USAGE_ATTRIBUTE, project.usageByName(KotlinUsages.KOTLIN_METADATA))
|
||||
}
|
||||
|
||||
if (configurationNames != null) {
|
||||
for (configurationName in configurationNames) {
|
||||
extendsFrom(project.configurations.maybeCreate(configurationName))
|
||||
}
|
||||
}
|
||||
|
||||
if (project.isKotlinGranularMetadataEnabled) {
|
||||
attributes.attribute(Usage.USAGE_ATTRIBUTE, project.usageByName(KotlinUsages.KOTLIN_METADATA))
|
||||
}
|
||||
|
||||
project.afterEvaluate {
|
||||
setJsCompilerIfNecessary(sourceSet, this@apply)
|
||||
}
|
||||
project.afterEvaluate {
|
||||
setJsCompilerIfNecessary(sourceSet, this@apply)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-35
@@ -162,10 +162,8 @@ class KotlinMetadataTargetConfigurator :
|
||||
|
||||
private fun setupDependencyTransformationForCommonSourceSets(target: KotlinMetadataTarget) {
|
||||
target.project.whenEvaluated {
|
||||
val publishedCommonSourceSets: Set<KotlinSourceSet> = getCommonSourceSetsForMetadataCompilation(project)
|
||||
|
||||
kotlinExtension.sourceSets.all {
|
||||
setupDependencyTransformationForSourceSet(target.project, it, it in publishedCommonSourceSets)
|
||||
setupDependencyTransformationForSourceSet(target.project, it)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -345,7 +343,7 @@ class KotlinMetadataTargetConfigurator :
|
||||
}
|
||||
|
||||
compilation.compileDependencyFiles += createMetadataDependencyTransformationClasspath(
|
||||
project.configurations.getByName(sourceSet.metadataLibrariesConfigurationName),
|
||||
sourceSet.internal.resolvableMetadataConfiguration,
|
||||
compilation
|
||||
)
|
||||
|
||||
@@ -356,11 +354,8 @@ class KotlinMetadataTargetConfigurator :
|
||||
|
||||
private fun setupDependencyTransformationForSourceSet(
|
||||
project: Project,
|
||||
sourceSet: KotlinSourceSet,
|
||||
isSourceSetPublished: Boolean
|
||||
sourceSet: KotlinSourceSet
|
||||
) {
|
||||
val dependencyScopesToTransform = KotlinDependencyScope.compileScopes
|
||||
|
||||
val granularMetadataTransformation = GranularMetadataTransformation(
|
||||
project = project,
|
||||
kotlinSourceSet = sourceSet,
|
||||
@@ -372,33 +367,6 @@ class KotlinMetadataTargetConfigurator :
|
||||
|
||||
if (sourceSet is DefaultKotlinSourceSet)
|
||||
sourceSet.compileDependenciesTransformation = granularMetadataTransformation
|
||||
|
||||
dependencyScopesToTransform.forEach { scope ->
|
||||
val sourceSetDependencyConfigurationByScope = project.configurations.sourceSetDependencyConfigurationByScope(sourceSet, scope)
|
||||
|
||||
if (isSourceSetPublished) {
|
||||
project.addExtendsFromRelation(
|
||||
sourceSet.metadataLibrariesConfigurationName,
|
||||
sourceSetDependencyConfigurationByScope.name
|
||||
)
|
||||
|
||||
// we need to include dependencies from sourceSetDependencyConfigurationByScope to
|
||||
// ALL_COMPILE_METADATA_CONFIGURATION_NAME so then we can resolve consistently with it
|
||||
// when resolving [sourceSet.metadataLibrariesConfigurationName]
|
||||
project.addExtendsFromRelation(
|
||||
ALL_COMPILE_METADATA_CONFIGURATION_NAME,
|
||||
sourceSetDependencyConfigurationByScope.name
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
val sourceSetMetadataConfiguration = project.configurations.getByName(sourceSet.metadataLibrariesConfigurationName)
|
||||
// not necessary: because granularMetadataTransformation already created out of this configuration
|
||||
// so there is no real logic to do dependency handling there.
|
||||
// !!!! granularMetadataTransformation.applyToConfiguration(sourceSetMetadataConfiguration)
|
||||
sourceSetMetadataConfiguration.shouldResolveConsistentlyWith(
|
||||
project.configurations.getByName(ALL_COMPILE_METADATA_CONFIGURATION_NAME)
|
||||
)
|
||||
}
|
||||
|
||||
/** Ensure that the [configuration] excludes the dependencies that are classified by this [GranularMetadataTransformation] as
|
||||
|
||||
+8
-4
@@ -7,7 +7,10 @@ package org.jetbrains.kotlin.gradle.targets.native.internal
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.file.FileCollection
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.resolvableMetadataConfiguration
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.resolvableMetadataConfigurationName
|
||||
import org.jetbrains.kotlin.gradle.plugin.sources.DefaultKotlinSourceSet
|
||||
import org.jetbrains.kotlin.gradle.plugin.sources.internal
|
||||
|
||||
/**
|
||||
* Dependencies here are using a special configuration called 'intransitiveMetadataConfiguration'.
|
||||
@@ -16,8 +19,9 @@ import org.jetbrains.kotlin.gradle.plugin.sources.DefaultKotlinSourceSet
|
||||
* In this mode, every source set will receive exactly one commonized library to analyze its source code with.
|
||||
*/
|
||||
internal fun Project.addIntransitiveMetadataDependencyIfPossible(sourceSet: DefaultKotlinSourceSet, dependency: FileCollection) {
|
||||
val dependencyConfigurationName =
|
||||
if (project.isIntransitiveMetadataConfigurationEnabled) sourceSet.intransitiveMetadataConfigurationName
|
||||
else sourceSet.metadataLibrariesConfigurationName
|
||||
project.dependencies.add(dependencyConfigurationName, dependency)
|
||||
if (project.isIntransitiveMetadataConfigurationEnabled) {
|
||||
project.dependencies.add(sourceSet.intransitiveMetadataConfigurationName, dependency)
|
||||
} /*else {
|
||||
project.dependencies.add(sourceSet.internal.resolvableMetadataConfiguration.name, dependency)
|
||||
}*/
|
||||
}
|
||||
|
||||
+3
-1
@@ -16,8 +16,10 @@ import org.jetbrains.kotlin.gradle.internal.KOTLIN_MODULE_GROUP
|
||||
import org.jetbrains.kotlin.gradle.internal.PLATFORM_INTEGERS_SUPPORT_LIBRARY
|
||||
import org.jetbrains.kotlin.gradle.plugin.*
|
||||
import org.jetbrains.kotlin.gradle.plugin.ide.ideaImportDependsOn
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.resolvableMetadataConfiguration
|
||||
import org.jetbrains.kotlin.gradle.plugin.sources.DefaultKotlinSourceSet
|
||||
import org.jetbrains.kotlin.gradle.plugin.sources.getVisibleSourceSetsFromAssociateCompilations
|
||||
import org.jetbrains.kotlin.gradle.plugin.sources.internal
|
||||
import org.jetbrains.kotlin.gradle.targets.metadata.getMetadataCompilationForSourceSet
|
||||
import org.jetbrains.kotlin.gradle.targets.metadata.isKotlinGranularMetadataEnabled
|
||||
import org.jetbrains.kotlin.gradle.targets.native.internal.MissingNativeStdlibWarning.showMissingNativeStdlibWarning
|
||||
@@ -97,7 +99,7 @@ private fun Project.addDependencies(
|
||||
if (isIdeDependency && sourceSet is DefaultKotlinSourceSet) {
|
||||
val metadataConfigurationName =
|
||||
if (project.isIntransitiveMetadataConfigurationEnabled) sourceSet.intransitiveMetadataConfigurationName
|
||||
else sourceSet.metadataLibrariesConfigurationName
|
||||
else sourceSet.internal.resolvableMetadataConfiguration.name //TODO: should it be here?
|
||||
dependencies.add(metadataConfigurationName, libraries)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user