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)
|
fun dependsOn(other: KotlinSourceSet)
|
||||||
val dependsOn: Set<KotlinSourceSet>
|
val dependsOn: Set<KotlinSourceSet>
|
||||||
|
|
||||||
val metadataLibrariesConfigurationName: String
|
|
||||||
@Deprecated(message = "KT-55312")
|
@Deprecated(message = "KT-55312")
|
||||||
val apiMetadataConfigurationName: String
|
val apiMetadataConfigurationName: String
|
||||||
@Deprecated(message = "KT-55312")
|
@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")
|
@Deprecated(message = "KT-55230: RuntimeOnly scope is not supported for metadata dependency transformation")
|
||||||
val runtimeOnlyMetadataConfigurationName: String
|
val runtimeOnlyMetadataConfigurationName: String
|
||||||
|
|
||||||
override val relatedConfigurationNames: List<String>
|
|
||||||
get() = super.relatedConfigurationNames + metadataLibrariesConfigurationName
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val COMMON_MAIN_SOURCE_SET_NAME = "commonMain"
|
const val COMMON_MAIN_SOURCE_SET_NAME = "commonMain"
|
||||||
const val COMMON_TEST_SOURCE_SET_NAME = "commonTest"
|
const val COMMON_TEST_SOURCE_SET_NAME = "commonTest"
|
||||||
|
|||||||
-1
@@ -86,7 +86,6 @@ private fun KotlinTarget.excludeStdlibAndKotlinTestCommonFromPlatformCompilation
|
|||||||
compilations.all {
|
compilations.all {
|
||||||
listOfNotNull(
|
listOfNotNull(
|
||||||
it.compileDependencyConfigurationName,
|
it.compileDependencyConfigurationName,
|
||||||
it.defaultSourceSet.metadataLibrariesConfigurationName,
|
|
||||||
(it as? KotlinCompilationToRunnableFiles<*>)?.runtimeDependencyConfigurationName,
|
(it as? KotlinCompilationToRunnableFiles<*>)?.runtimeDependencyConfigurationName,
|
||||||
|
|
||||||
// Additional configurations for (old) jvmWithJava-preset. Remove it when we drop it completely
|
// 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
|
override val runtimeOnlyConfigurationName: String
|
||||||
get() = disambiguateName(RUNTIME_ONLY)
|
get() = disambiguateName(RUNTIME_ONLY)
|
||||||
|
|
||||||
override val metadataLibrariesConfigurationName: String
|
|
||||||
get() = disambiguateName(METADATA_CONFIGURATION_NAME_SUFFIX)
|
|
||||||
|
|
||||||
@Deprecated("KT-55312")
|
@Deprecated("KT-55312")
|
||||||
override val apiMetadataConfigurationName: String
|
override val apiMetadataConfigurationName: String
|
||||||
get() = lowerCamelCaseName(apiConfigurationName, METADATA_CONFIGURATION_NAME_SUFFIX)
|
get() = lowerCamelCaseName(apiConfigurationName, METADATA_CONFIGURATION_NAME_SUFFIX)
|
||||||
|
|||||||
+12
-27
@@ -74,35 +74,20 @@ internal class DefaultKotlinSourceSetFactory(
|
|||||||
super.setUpSourceSetDefaults(sourceSet)
|
super.setUpSourceSetDefaults(sourceSet)
|
||||||
sourceSet.resources.srcDir(defaultSourceFolder(project, sourceSet.name, "resources"))
|
sourceSet.resources.srcDir(defaultSourceFolder(project, sourceSet.name, "resources"))
|
||||||
|
|
||||||
val dependencyConfigurationWithMetadata = with(sourceSet) {
|
project.configurations.maybeCreate(sourceSet.intransitiveMetadataConfigurationName).apply {
|
||||||
listOf(
|
attributes.attribute(KotlinPlatformType.attribute, KotlinPlatformType.common)
|
||||||
listOf(apiConfigurationName, implementationConfigurationName, compileOnlyConfigurationName) to metadataLibrariesConfigurationName,
|
attributes.attribute(Usage.USAGE_ATTRIBUTE, project.usageByName(KotlinUsages.KOTLIN_API))
|
||||||
null to intransitiveMetadataConfigurationName
|
attributes.attribute(Category.CATEGORY_ATTRIBUTE, project.categoryByName(Category.LIBRARY))
|
||||||
)
|
isVisible = false
|
||||||
}
|
isCanBeConsumed = false
|
||||||
|
isCanBeResolved = true
|
||||||
|
|
||||||
dependencyConfigurationWithMetadata.forEach { (configurationNames, metadataName) ->
|
if (project.isKotlinGranularMetadataEnabled) {
|
||||||
project.configurations.maybeCreate(metadataName).apply {
|
attributes.attribute(Usage.USAGE_ATTRIBUTE, project.usageByName(KotlinUsages.KOTLIN_METADATA))
|
||||||
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 (configurationNames != null) {
|
project.afterEvaluate {
|
||||||
for (configurationName in configurationNames) {
|
setJsCompilerIfNecessary(sourceSet, this@apply)
|
||||||
extendsFrom(project.configurations.maybeCreate(configurationName))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (project.isKotlinGranularMetadataEnabled) {
|
|
||||||
attributes.attribute(Usage.USAGE_ATTRIBUTE, project.usageByName(KotlinUsages.KOTLIN_METADATA))
|
|
||||||
}
|
|
||||||
|
|
||||||
project.afterEvaluate {
|
|
||||||
setJsCompilerIfNecessary(sourceSet, this@apply)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-35
@@ -162,10 +162,8 @@ class KotlinMetadataTargetConfigurator :
|
|||||||
|
|
||||||
private fun setupDependencyTransformationForCommonSourceSets(target: KotlinMetadataTarget) {
|
private fun setupDependencyTransformationForCommonSourceSets(target: KotlinMetadataTarget) {
|
||||||
target.project.whenEvaluated {
|
target.project.whenEvaluated {
|
||||||
val publishedCommonSourceSets: Set<KotlinSourceSet> = getCommonSourceSetsForMetadataCompilation(project)
|
|
||||||
|
|
||||||
kotlinExtension.sourceSets.all {
|
kotlinExtension.sourceSets.all {
|
||||||
setupDependencyTransformationForSourceSet(target.project, it, it in publishedCommonSourceSets)
|
setupDependencyTransformationForSourceSet(target.project, it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -345,7 +343,7 @@ class KotlinMetadataTargetConfigurator :
|
|||||||
}
|
}
|
||||||
|
|
||||||
compilation.compileDependencyFiles += createMetadataDependencyTransformationClasspath(
|
compilation.compileDependencyFiles += createMetadataDependencyTransformationClasspath(
|
||||||
project.configurations.getByName(sourceSet.metadataLibrariesConfigurationName),
|
sourceSet.internal.resolvableMetadataConfiguration,
|
||||||
compilation
|
compilation
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -356,11 +354,8 @@ class KotlinMetadataTargetConfigurator :
|
|||||||
|
|
||||||
private fun setupDependencyTransformationForSourceSet(
|
private fun setupDependencyTransformationForSourceSet(
|
||||||
project: Project,
|
project: Project,
|
||||||
sourceSet: KotlinSourceSet,
|
sourceSet: KotlinSourceSet
|
||||||
isSourceSetPublished: Boolean
|
|
||||||
) {
|
) {
|
||||||
val dependencyScopesToTransform = KotlinDependencyScope.compileScopes
|
|
||||||
|
|
||||||
val granularMetadataTransformation = GranularMetadataTransformation(
|
val granularMetadataTransformation = GranularMetadataTransformation(
|
||||||
project = project,
|
project = project,
|
||||||
kotlinSourceSet = sourceSet,
|
kotlinSourceSet = sourceSet,
|
||||||
@@ -372,33 +367,6 @@ class KotlinMetadataTargetConfigurator :
|
|||||||
|
|
||||||
if (sourceSet is DefaultKotlinSourceSet)
|
if (sourceSet is DefaultKotlinSourceSet)
|
||||||
sourceSet.compileDependenciesTransformation = granularMetadataTransformation
|
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
|
/** 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.Project
|
||||||
import org.gradle.api.file.FileCollection
|
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.DefaultKotlinSourceSet
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.sources.internal
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dependencies here are using a special configuration called 'intransitiveMetadataConfiguration'.
|
* 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.
|
* 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) {
|
internal fun Project.addIntransitiveMetadataDependencyIfPossible(sourceSet: DefaultKotlinSourceSet, dependency: FileCollection) {
|
||||||
val dependencyConfigurationName =
|
if (project.isIntransitiveMetadataConfigurationEnabled) {
|
||||||
if (project.isIntransitiveMetadataConfigurationEnabled) sourceSet.intransitiveMetadataConfigurationName
|
project.dependencies.add(sourceSet.intransitiveMetadataConfigurationName, dependency)
|
||||||
else sourceSet.metadataLibrariesConfigurationName
|
} /*else {
|
||||||
project.dependencies.add(dependencyConfigurationName, dependency)
|
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.internal.PLATFORM_INTEGERS_SUPPORT_LIBRARY
|
||||||
import org.jetbrains.kotlin.gradle.plugin.*
|
import org.jetbrains.kotlin.gradle.plugin.*
|
||||||
import org.jetbrains.kotlin.gradle.plugin.ide.ideaImportDependsOn
|
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.DefaultKotlinSourceSet
|
||||||
import org.jetbrains.kotlin.gradle.plugin.sources.getVisibleSourceSetsFromAssociateCompilations
|
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.getMetadataCompilationForSourceSet
|
||||||
import org.jetbrains.kotlin.gradle.targets.metadata.isKotlinGranularMetadataEnabled
|
import org.jetbrains.kotlin.gradle.targets.metadata.isKotlinGranularMetadataEnabled
|
||||||
import org.jetbrains.kotlin.gradle.targets.native.internal.MissingNativeStdlibWarning.showMissingNativeStdlibWarning
|
import org.jetbrains.kotlin.gradle.targets.native.internal.MissingNativeStdlibWarning.showMissingNativeStdlibWarning
|
||||||
@@ -97,7 +99,7 @@ private fun Project.addDependencies(
|
|||||||
if (isIdeDependency && sourceSet is DefaultKotlinSourceSet) {
|
if (isIdeDependency && sourceSet is DefaultKotlinSourceSet) {
|
||||||
val metadataConfigurationName =
|
val metadataConfigurationName =
|
||||||
if (project.isIntransitiveMetadataConfigurationEnabled) sourceSet.intransitiveMetadataConfigurationName
|
if (project.isIntransitiveMetadataConfigurationEnabled) sourceSet.intransitiveMetadataConfigurationName
|
||||||
else sourceSet.metadataLibrariesConfigurationName
|
else sourceSet.internal.resolvableMetadataConfiguration.name //TODO: should it be here?
|
||||||
dependencies.add(metadataConfigurationName, libraries)
|
dependencies.add(metadataConfigurationName, libraries)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user