[Commonizer] Add CommonizerHierarchicalIT
Test platform dependencies on leaf source sets ^KT-46716 Verification pending
This commit is contained in:
committed by
Space
parent
5f7576e546
commit
d76bb45716
+17
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.gradle
|
|||||||
|
|
||||||
import org.gradle.api.logging.configuration.WarningMode
|
import org.gradle.api.logging.configuration.WarningMode
|
||||||
import org.gradle.internal.os.OperatingSystem
|
import org.gradle.internal.os.OperatingSystem
|
||||||
|
import org.jetbrains.kotlin.konan.file.File
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
|
||||||
class CommonizerHierarchicalIT : BaseGradleIT() {
|
class CommonizerHierarchicalIT : BaseGradleIT() {
|
||||||
@@ -111,6 +112,22 @@ class CommonizerHierarchicalIT : BaseGradleIT() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `test platform dependencies on leaf source sets`() {
|
||||||
|
with(Project("commonizeHierarchicallyPlatformDependencies")) {
|
||||||
|
build(":checkPlatformDependencies") {
|
||||||
|
val klibPlatform = "${File.separator}klib${File.separator}platform${File.separator}".replace("\\", "\\\\")
|
||||||
|
|
||||||
|
assertSuccessful()
|
||||||
|
assertTasksExecuted(":commonizeNativeDistribution")
|
||||||
|
assertTasksExecuted(":checkLinuxX64MainPlatformDependencies")
|
||||||
|
assertTasksExecuted(":checkLinuxArm64MainPlatformDependencies")
|
||||||
|
assertContainsRegex(Regex(""".*linuxX64Main.*$klibPlatform.*[Pp]osix.*"""))
|
||||||
|
assertContainsRegex(Regex(""".*linuxArm64Main.*$klibPlatform.*[Pp]osix.*"""))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private object Os {
|
private object Os {
|
||||||
private val os = OperatingSystem.current()
|
private val os = OperatingSystem.current()
|
||||||
val canCompileApple get() = os.isMacOsX
|
val canCompileApple get() = os.isMacOsX
|
||||||
|
|||||||
+53
@@ -0,0 +1,53 @@
|
|||||||
|
import org.jetbrains.kotlin.gradle.plugin.sources.DefaultKotlinSourceSet
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
kotlin("multiplatform")
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenLocal()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun createPlatformDependenciesTestTask(sourceSet: DefaultKotlinSourceSet) {
|
||||||
|
tasks.create("check${sourceSet.name.capitalize()}PlatformDependencies") {
|
||||||
|
tasks.maybeCreate("checkPlatformDependencies").dependsOn(this)
|
||||||
|
|
||||||
|
// Dependencies forwarded to the IDE will be attached to the intransitiveMetadataConfiguration
|
||||||
|
val dependenciesConfiguration = configurations.getByName(sourceSet.intransitiveMetadataConfigurationName)
|
||||||
|
dependsOn("commonize")
|
||||||
|
|
||||||
|
doLast {
|
||||||
|
val dependencies = dependenciesConfiguration.files
|
||||||
|
|
||||||
|
dependencies.forEach { dependency ->
|
||||||
|
logger.quiet("${sourceSet.name} dependency: ${dependency.path}")
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies.forEach { dependency ->
|
||||||
|
if ("klib${File.separator}commonized" in dependency.path) {
|
||||||
|
throw AssertionError(
|
||||||
|
"${sourceSet.name}: Found unexpected commonized dependency ${dependency.path}"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dependencies.isEmpty()) {
|
||||||
|
throw AssertionError("${sourceSet.name}: Expected at least one platform dependency")
|
||||||
|
}
|
||||||
|
|
||||||
|
val platformKlibPattern = "klib${File.separator}platform"
|
||||||
|
if (dependencies.none { dependency -> platformKlibPattern in dependency.path }) {
|
||||||
|
throw AssertionError("${sourceSet.name}: Expected at least one dependency from '$platformKlibPattern'")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
linuxX64()
|
||||||
|
linuxArm64()
|
||||||
|
|
||||||
|
createPlatformDependenciesTestTask(sourceSets.getByName("linuxX64Main") as DefaultKotlinSourceSet)
|
||||||
|
createPlatformDependenciesTestTask(sourceSets.getByName("linuxArm64Main") as DefaultKotlinSourceSet)
|
||||||
|
}
|
||||||
+4
@@ -0,0 +1,4 @@
|
|||||||
|
kotlin.mpp.enableGranularSourceSetsMetadata=true
|
||||||
|
kotlin.native.enableDependencyPropagation=false
|
||||||
|
kotlin.mpp.enableHierarchicalCommonization=true
|
||||||
|
kotlin.mpp.enableIntransitiveMetadataConfiguration=true
|
||||||
+10
@@ -0,0 +1,10 @@
|
|||||||
|
pluginManagement {
|
||||||
|
repositories {
|
||||||
|
mavenLocal()
|
||||||
|
gradlePluginPortal()
|
||||||
|
}
|
||||||
|
val kotlin_version: String by settings
|
||||||
|
plugins {
|
||||||
|
kotlin("multiplatform").version(kotlin_version)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user