[Gradle] Don't resolve platform classpath configuration consistently ...
... with metadata dependencies. As it can cause unexpected version downgrades. This change restores behavior that existed previous versions. While the separation between different source set trees remained. The proper implementation should be done as part of KT-66375. Related tests that were verifying the fact that platform dependencies are also resolved consistently is ignored with reference to KT-66375 ^KT-66372 Verification Pending ^KT-66154 Verification Pending ^KT-66375
This commit is contained in:
committed by
Space Team
parent
c3a0a41524
commit
5779465366
+1
-5
@@ -134,9 +134,5 @@ private fun Project.configureConsistentDependencyResolution(groupOfSourceSets: C
|
||||
configuration.extendsFrom(*extenders.toTypedArray())
|
||||
groupOfSourceSets.forEach { it.internal.resolvableMetadataConfiguration.shouldResolveConsistentlyWith(configuration) }
|
||||
|
||||
// Make actual compilation classpaths/libraries configurations to have the same consistent dependencies
|
||||
groupOfSourceSets
|
||||
.flatMap { it.internal.compilations }
|
||||
.toSet()
|
||||
.forEach { project.configurations.getByName(it.compileDependencyConfigurationName).shouldResolveConsistentlyWith(configuration) }
|
||||
// FIXME: KT-66375 Make actual compilation classpaths/libraries configurations to have the same consistent dependencies
|
||||
}
|
||||
+30
@@ -19,6 +19,7 @@ import org.jetbrains.kotlin.gradle.plugin.kotlinToolingVersion
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.resolvableMetadataConfiguration
|
||||
import org.jetbrains.kotlin.gradle.plugin.sources.internal
|
||||
import org.jetbrains.kotlin.gradle.util.*
|
||||
import kotlin.test.Ignore
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.fail
|
||||
@@ -115,6 +116,7 @@ class ResolvableMetadataConfigurationTest : SourceSetDependenciesResolution() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore("TODO: KT-66375")
|
||||
fun jvmMainWithHigherVersion() {
|
||||
assertSourceSetDependenciesResolution("leafSourceSetWithHigherVersion.txt") { project ->
|
||||
project.defaultTargets()
|
||||
@@ -130,6 +132,7 @@ class ResolvableMetadataConfigurationTest : SourceSetDependenciesResolution() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore("TODO: KT-66375")
|
||||
fun nativeMainWithHigherVersion() {
|
||||
assertSourceSetDependenciesResolution("leafSourceSetWithHigherVersion.txt") { project ->
|
||||
project.defaultTargets()
|
||||
@@ -142,6 +145,7 @@ class ResolvableMetadataConfigurationTest : SourceSetDependenciesResolution() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore("TODO: KT-66375")
|
||||
fun jsMainWithHigherVersion() {
|
||||
assertSourceSetDependenciesResolution("leafSourceSetWithHigherVersion.txt") { project ->
|
||||
project.defaultTargets()
|
||||
@@ -167,6 +171,7 @@ class ResolvableMetadataConfigurationTest : SourceSetDependenciesResolution() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore("TODO: KT-66375")
|
||||
fun leafSourceSetsDependsOnDifferentVersionsAndCommonCodeDoesNot() {
|
||||
assertSourceSetDependenciesResolution("leafSourceSetsDependsOnDifferentVersionsAndCommonCodeDoesNot.txt") { project ->
|
||||
project.defaultTargets()
|
||||
@@ -180,6 +185,31 @@ class ResolvableMetadataConfigurationTest : SourceSetDependenciesResolution() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* after KT-66375 is fixed it is expected that all source sets will have foo:2.0 dependency
|
||||
* unless other is decided
|
||||
*/
|
||||
@Test
|
||||
fun KT66375JvmDependenciesShouldNotDowngrade() {
|
||||
val appProject = buildProject(projectBuilder = { withName("app") })
|
||||
val libProject = buildProject(projectBuilder = { withName("lib").withParent(appProject) })
|
||||
|
||||
assertSourceSetDependenciesResolution("KT66375JvmDependenciesShouldNotDowngrade.txt", withProject = appProject) {
|
||||
appProject.applyMultiplatformPlugin().apply {
|
||||
jvm(); linuxX64()
|
||||
// common main depends on 1.0
|
||||
sourceSets.getByName("commonMain").dependencies { this.api(mockedDependency("foo", "1.0")) }
|
||||
// jvm main depends on lib that transitively depends on 2.0
|
||||
sourceSets.jvmMain.dependencies { api(project(":lib")) }
|
||||
}
|
||||
|
||||
libProject.applyMultiplatformPlugin().apply {
|
||||
jvm(); linuxX64()
|
||||
sourceSets.jvmMain.dependencies { api(mockedDependency("foo", "2.0")) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun Project.defaultTargets() {
|
||||
kotlin { jvm(); linuxX64(); js(); applyDefaultHierarchyTemplate() }
|
||||
}
|
||||
|
||||
+24
-7
@@ -6,6 +6,7 @@
|
||||
package org.jetbrains.kotlin.gradle.dependencyResolutionTests
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.internal.project.ProjectInternal
|
||||
import org.gradle.kotlin.dsl.maven
|
||||
import org.jetbrains.kotlin.gradle.dsl.kotlinExtension
|
||||
import org.jetbrains.kotlin.gradle.dsl.multiplatformExtension
|
||||
@@ -29,20 +30,36 @@ abstract class SourceSetDependenciesResolution {
|
||||
/**
|
||||
* Declares an API dependency to test:[name]:[version] for [sourceSetName] source set
|
||||
*/
|
||||
fun api(sourceSetName: String, name: String, version: String) {
|
||||
fun api(sourceSetName: String, name: String, version: String): Unit = project
|
||||
.kotlinExtension
|
||||
.sourceSets
|
||||
.getByName(sourceSetName)
|
||||
.dependencies { api(mockedDependency(name, version)) }
|
||||
|
||||
fun mockedDependency(name: String, version: String): String {
|
||||
declaredDependencies.add(name to version)
|
||||
project.kotlinExtension.sourceSets.getByName(sourceSetName).dependencies { api("test:$name:$version") }
|
||||
return "test:$name:$version"
|
||||
}
|
||||
}
|
||||
|
||||
fun assertSourceSetDependenciesResolution(expectedFilePath: String, configure: SourceSetDependenciesDsl.(Project) -> Unit) {
|
||||
/**
|
||||
* If [withProject] is not null then dependencies of source sets in this projects will be verified against [expectedFilePath]
|
||||
*
|
||||
*/
|
||||
fun assertSourceSetDependenciesResolution(
|
||||
expectedFilePath: String,
|
||||
withProject: ProjectInternal? = null,
|
||||
configure: SourceSetDependenciesDsl.(Project) -> Unit
|
||||
) {
|
||||
val repoRoot = tempFolder.newFolder()
|
||||
val project = buildProject {
|
||||
enableDefaultStdlibDependency(false)
|
||||
enableDependencyVerification(false)
|
||||
val project = withProject ?: buildProject {
|
||||
applyMultiplatformPlugin()
|
||||
}
|
||||
|
||||
repositories.maven(repoRoot)
|
||||
project.allprojects {
|
||||
it.enableDefaultStdlibDependency(false)
|
||||
it.enableDependencyVerification(false)
|
||||
it.repositories.maven(repoRoot)
|
||||
}
|
||||
|
||||
val dsl = SourceSetDependenciesDsl(project)
|
||||
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
commonMain
|
||||
test:foo:1.0
|
||||
commonTest
|
||||
test:foo:1.0
|
||||
jvmMain
|
||||
project :lib
|
||||
test:foo:2.0
|
||||
jvmTest
|
||||
project :lib
|
||||
test:foo:2.0
|
||||
linuxMain
|
||||
test:foo:1.0
|
||||
linuxTest
|
||||
test:foo:1.0
|
||||
linuxX64Main
|
||||
test:foo:1.0
|
||||
linuxX64Test
|
||||
test:foo:1.0
|
||||
nativeMain
|
||||
test:foo:1.0
|
||||
nativeTest
|
||||
test:foo:1.0
|
||||
Reference in New Issue
Block a user