Setup versions consistently only among published source sets
The common source sets that are not published (like commonTest) should not affect dependency resolution for other source sets. Signed-off-by: Sergey Igushkin <hotkeytlt@gmail.com>
This commit is contained in:
+22
-13
@@ -104,8 +104,12 @@ class KotlinMetadataTargetConfigurator(kotlinPluginVersion: String) :
|
|||||||
lowerCamelCaseName("transform", sourceSet.name, "DependenciesMetadata")
|
lowerCamelCaseName("transform", sourceSet.name, "DependenciesMetadata")
|
||||||
|
|
||||||
private fun setupDependencyTransformationForCommonSourceSets(target: KotlinMetadataTarget) {
|
private fun setupDependencyTransformationForCommonSourceSets(target: KotlinMetadataTarget) {
|
||||||
target.project.kotlinExtension.sourceSets.all {
|
target.project.whenEvaluated {
|
||||||
setupDependencyTransformationForSourceSet(target.project, it)
|
val publishedCommonSourceSets: Set<KotlinSourceSet> = getPublishedCommonSourceSets(project)
|
||||||
|
|
||||||
|
kotlinExtension.sourceSets.all {
|
||||||
|
setupDependencyTransformationForSourceSet(target.project, it, it in publishedCommonSourceSets)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,7 +205,8 @@ class KotlinMetadataTargetConfigurator(kotlinPluginVersion: String) :
|
|||||||
|
|
||||||
private fun setupDependencyTransformationForSourceSet(
|
private fun setupDependencyTransformationForSourceSet(
|
||||||
project: Project,
|
project: Project,
|
||||||
sourceSet: KotlinSourceSet
|
sourceSet: KotlinSourceSet,
|
||||||
|
isSourceSetPublished: Boolean
|
||||||
) {
|
) {
|
||||||
KotlinDependencyScope.values().forEach { scope ->
|
KotlinDependencyScope.values().forEach { scope ->
|
||||||
val allMetadataConfigurations = mutableListOf<Configuration>().apply {
|
val allMetadataConfigurations = mutableListOf<Configuration>().apply {
|
||||||
@@ -226,24 +231,28 @@ class KotlinMetadataTargetConfigurator(kotlinPluginVersion: String) :
|
|||||||
|
|
||||||
val sourceSetDependencyConfigurationByScope = project.sourceSetDependencyConfigurationByScope(sourceSet, scope)
|
val sourceSetDependencyConfigurationByScope = project.sourceSetDependencyConfigurationByScope(sourceSet, scope)
|
||||||
|
|
||||||
// All source set dependencies except for compileOnly take part and agree in versions with all other runtime dependencies:
|
// All source set dependencies except for compileOnly agree in versions with all other published runtime dependencies:
|
||||||
if (scope != KotlinDependencyScope.COMPILE_ONLY_SCOPE) {
|
if (scope != KotlinDependencyScope.COMPILE_ONLY_SCOPE) {
|
||||||
project.addExtendsFromRelation(
|
if (isSourceSetPublished) {
|
||||||
ALL_RUNTIME_METADATA_CONFIGURATION_NAME,
|
project.addExtendsFromRelation(
|
||||||
sourceSetDependencyConfigurationByScope.name
|
ALL_RUNTIME_METADATA_CONFIGURATION_NAME,
|
||||||
)
|
sourceSetDependencyConfigurationByScope.name
|
||||||
|
)
|
||||||
|
}
|
||||||
project.addExtendsFromRelation(
|
project.addExtendsFromRelation(
|
||||||
sourceSetMetadataConfigurationByScope.name,
|
sourceSetMetadataConfigurationByScope.name,
|
||||||
ALL_RUNTIME_METADATA_CONFIGURATION_NAME
|
ALL_RUNTIME_METADATA_CONFIGURATION_NAME
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// All source set dependencies except for runtimeOnly take part and agree in versions with all other compile dependencies:
|
// All source set dependencies except for runtimeOnly agree in versions with all other published compile dependencies:
|
||||||
if (scope != KotlinDependencyScope.RUNTIME_ONLY_SCOPE) {
|
if (scope != KotlinDependencyScope.RUNTIME_ONLY_SCOPE) {
|
||||||
project.addExtendsFromRelation(
|
if (isSourceSetPublished) {
|
||||||
ALL_COMPILE_METADATA_CONFIGURATION_NAME,
|
project.addExtendsFromRelation(
|
||||||
sourceSetDependencyConfigurationByScope.name
|
ALL_COMPILE_METADATA_CONFIGURATION_NAME,
|
||||||
)
|
sourceSetDependencyConfigurationByScope.name
|
||||||
|
)
|
||||||
|
}
|
||||||
project.addExtendsFromRelation(
|
project.addExtendsFromRelation(
|
||||||
sourceSetMetadataConfigurationByScope.name,
|
sourceSetMetadataConfigurationByScope.name,
|
||||||
ALL_COMPILE_METADATA_CONFIGURATION_NAME
|
ALL_COMPILE_METADATA_CONFIGURATION_NAME
|
||||||
|
|||||||
Reference in New Issue
Block a user