[Gradle] Update tests after removing runtimeOnly metadata transformations

Additionally check that all metadata dependencies per scope resolve
consistently. It is a side effect after creating GranularMetadata
dependency for all compile scopes instead per scope style.

^KT-55230
This commit is contained in:
Anton Lakotka
2022-12-05 16:34:12 +01:00
committed by Space Team
parent d28659fdbe
commit 8726360a8e
5 changed files with 11 additions and 19 deletions
@@ -1193,14 +1193,13 @@ abstract class AbstractKotlin2JsGradlePluginIT(protected val irBackend: Boolean)
| api(project(":base")) | api(project(":base"))
| implementation(project(":base")) | implementation(project(":base"))
| compileOnly(project(":base")) | compileOnly(project(":base"))
| runtimeOnly(project(":base"))
| } | }
| } | }
| } | }
| |
|task("printMetadataFiles") { |task("printMetadataFiles") {
| doFirst { | doFirst {
| listOf("api", "implementation", "compileOnly", "runtimeOnly").forEach { kind -> | listOf("api", "implementation", "compileOnly").forEach { kind ->
| val configuration = configurations.getByName(kind + "DependenciesMetadata") | val configuration = configurations.getByName(kind + "DependenciesMetadata")
| configuration.files.forEach { println("$pathPrefix" + configuration.name + "->" + it.name) } | configuration.files.forEach { println("$pathPrefix" + configuration.name + "->" + it.name) }
| } | }
@@ -1223,7 +1222,7 @@ abstract class AbstractKotlin2JsGradlePluginIT(protected val irBackend: Boolean)
.toSet() .toSet()
assertEquals( assertEquals(
listOf("api", "implementation", "compileOnly", "runtimeOnly").map { listOf("api", "implementation", "compileOnly").map {
"$it$METADATA_CONFIGURATION_NAME_SUFFIX" to expectedFileName "$it$METADATA_CONFIGURATION_NAME_SUFFIX" to expectedFileName
}.toSet(), }.toSet(),
paths paths
@@ -919,14 +919,13 @@ class NewMultiplatformIT : BaseGradleIT() {
// add these dependencies to check that they are resolved to metadata // add these dependencies to check that they are resolved to metadata
api 'com.example:sample-lib:1.0' api 'com.example:sample-lib:1.0'
compileOnly 'com.example:sample-lib:1.0' compileOnly 'com.example:sample-lib:1.0'
runtimeOnly 'com.example:sample-lib:1.0'
} }
} }
} }
task('printMetadataFiles') { task('printMetadataFiles') {
doFirst { doFirst {
['Api', 'Implementation', 'CompileOnly', 'RuntimeOnly'].each { kind -> ['Api', 'Implementation', 'CompileOnly'].each { kind ->
def configuration = configurations.getByName("commonMain${'$'}kind" + '$METADATA_CONFIGURATION_NAME_SUFFIX') def configuration = configurations.getByName("commonMain${'$'}kind" + '$METADATA_CONFIGURATION_NAME_SUFFIX')
configuration.files.each { println '$pathPrefix' + configuration.name + '->' + it.name } configuration.files.each { println '$pathPrefix' + configuration.name + '->' + it.name }
} }
@@ -947,7 +946,7 @@ class NewMultiplatformIT : BaseGradleIT() {
.toSet() .toSet()
Assert.assertEquals( Assert.assertEquals(
listOf("Api", "Implementation", "CompileOnly", "RuntimeOnly").map { listOf("Api", "Implementation", "CompileOnly").map {
"commonMain$it$METADATA_CONFIGURATION_NAME_SUFFIX" to expectedFileName "commonMain$it$METADATA_CONFIGURATION_NAME_SUFFIX" to expectedFileName
}.toSet(), }.toSet(),
paths paths
@@ -999,14 +998,13 @@ class NewMultiplatformIT : BaseGradleIT() {
api 'com.example:sample-lib-nodejs:1.0' api 'com.example:sample-lib-nodejs:1.0'
implementation 'com.example:sample-lib-nodejs:1.0' implementation 'com.example:sample-lib-nodejs:1.0'
compileOnly 'com.example:sample-lib-nodejs:1.0' compileOnly 'com.example:sample-lib-nodejs:1.0'
runtimeOnly 'com.example:sample-lib-nodejs:1.0'
} }
} }
} }
task('printMetadataFiles') { task('printMetadataFiles') {
doFirst { doFirst {
['Api', 'Implementation', 'CompileOnly', 'RuntimeOnly'].each { kind -> ['Api', 'Implementation', 'CompileOnly'].each { kind ->
def configuration = configurations.getByName("nodeJsMain${'$'}kind" + '$METADATA_CONFIGURATION_NAME_SUFFIX') def configuration = configurations.getByName("nodeJsMain${'$'}kind" + '$METADATA_CONFIGURATION_NAME_SUFFIX')
configuration.files.each { println '$pathPrefix' + configuration.name + '->' + it.name } configuration.files.each { println '$pathPrefix' + configuration.name + '->' + it.name }
} }
@@ -1030,7 +1028,7 @@ class NewMultiplatformIT : BaseGradleIT() {
.toSet() .toSet()
Assert.assertEquals( Assert.assertEquals(
listOf("Api", "Implementation", "CompileOnly", "RuntimeOnly").map { listOf("Api", "Implementation", "CompileOnly").map {
"nodeJsMain$it$METADATA_CONFIGURATION_NAME_SUFFIX" to expectedFileName "nodeJsMain$it$METADATA_CONFIGURATION_NAME_SUFFIX" to expectedFileName
}.toSet(), }.toSet(),
paths paths
@@ -1541,10 +1539,10 @@ class NewMultiplatformIT : BaseGradleIT() {
.count() .count()
) )
// All scoped DependenciesMetadata should resolve consistently into the same version
assertContains(">> :app:testExplicitKotlinVersionApiDependenciesMetadata --> kotlin-reflect-1.3.0.jar") assertContains(">> :app:testExplicitKotlinVersionApiDependenciesMetadata --> kotlin-reflect-1.3.0.jar")
assertContains(">> :app:testExplicitKotlinVersionImplementationDependenciesMetadata --> kotlin-reflect-1.2.71.jar") assertContains(">> :app:testExplicitKotlinVersionImplementationDependenciesMetadata --> kotlin-reflect-1.3.0.jar")
assertContains(">> :app:testExplicitKotlinVersionCompileOnlyDependenciesMetadata --> kotlin-reflect-1.2.70.jar") assertContains(">> :app:testExplicitKotlinVersionCompileOnlyDependenciesMetadata --> kotlin-reflect-1.3.0.jar")
assertContains(">> :app:testExplicitKotlinVersionRuntimeOnlyDependenciesMetadata --> kotlin-reflect-1.2.60.jar")
assertContains(">> :app:testProjectWithConfigurationApiDependenciesMetadata --> output.txt") assertContains(">> :app:testProjectWithConfigurationApiDependenciesMetadata --> output.txt")
} }
@@ -162,7 +162,7 @@ abstract class DefaultKotlinSourceSet @Inject constructor(
fun getAdditionalVisibleSourceSets(): List<KotlinSourceSet> = getVisibleSourceSetsFromAssociateCompilations(this) fun getAdditionalVisibleSourceSets(): List<KotlinSourceSet> = getVisibleSourceSetsFromAssociateCompilations(this)
private fun getDependenciesTransformation(): Iterable<MetadataDependencyTransformation> { internal fun getDependenciesTransformation(): Iterable<MetadataDependencyTransformation> {
val metadataDependencyResolutionByModule = val metadataDependencyResolutionByModule =
compileDependenciesTransformation.metadataDependencyResolutions compileDependenciesTransformation.metadataDependencyResolutions
.associateBy { ModuleIds.fromComponent(project, it.dependency) } .associateBy { ModuleIds.fromComponent(project, it.dependency) }
@@ -76,12 +76,10 @@ class ConfigurationsTest : MultiplatformExtensionTest() {
"MainApiDependenciesMetadata", "MainApiDependenciesMetadata",
"MainCompileOnlyDependenciesMetadata", "MainCompileOnlyDependenciesMetadata",
"MainImplementationDependenciesMetadata", "MainImplementationDependenciesMetadata",
"MainRuntimeOnlyDependenciesMetadata",
"TestApiDependenciesMetadata", "TestApiDependenciesMetadata",
"TestCompileOnlyDependenciesMetadata", "TestCompileOnlyDependenciesMetadata",
"TestImplementationDependenciesMetadata", "TestImplementationDependenciesMetadata",
"TestRuntimeOnlyDependenciesMetadata",
) )
// WASM // WASM
@@ -99,7 +97,6 @@ class ConfigurationsTest : MultiplatformExtensionTest() {
"ApiDependenciesMetadata", "ApiDependenciesMetadata",
"CompileOnlyDependenciesMetadata", "CompileOnlyDependenciesMetadata",
"ImplementationDependenciesMetadata", "ImplementationDependenciesMetadata",
"RuntimeOnlyDependenciesMetadata",
) )
// allJs // allJs
@@ -41,8 +41,6 @@ class KT46273JvmTargetAndOrphanTestSourceSetTest : MultiplatformExtensionTest()
The dependencies' transformation will be called by the IDE during import. The dependencies' transformation will be called by the IDE during import.
*/ */
KotlinDependencyScope.values().forEach { scope -> orphanTestSourceSet.getDependenciesTransformation()
orphanTestSourceSet.getDependenciesTransformation(scope)
}
} }
} }