Implement CommonizerIT.test KT-46234 intermediate source set with only one native target to cover KT-46234
^KT-46234
This commit is contained in:
committed by
Space
parent
e2786197ff
commit
5fb30b05ff
+51
@@ -242,6 +242,57 @@ class CommonizerIT : BaseGradleIT() {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test KT-46234 intermediate source set with only one native target`() {
|
||||
|
||||
val posixInImplementationMetadataConfigurationRegex = Regex(""".*implementationMetadataConfiguration:.*([pP])osix""")
|
||||
val posixInIntransitiveMetadataConfigurationRegex = Regex(""".*intransitiveMetadataConfiguration:.*([pP])osix""")
|
||||
|
||||
fun CompiledProject.containsPosixInImplementationMetadataConfiguration(): Boolean =
|
||||
output.lineSequence().any { line ->
|
||||
line.matches(posixInImplementationMetadataConfigurationRegex)
|
||||
}
|
||||
|
||||
fun CompiledProject.containsPosixInIntransitiveMetadataConfiguration(): Boolean =
|
||||
output.lineSequence().any { line ->
|
||||
line.matches(posixInIntransitiveMetadataConfigurationRegex)
|
||||
}
|
||||
|
||||
with(Project("commonize-kt-46234-singleNativeTarget")) {
|
||||
build(":p1:listNativePlatformMainDependencies", "-Pkotlin.mpp.enableIntransitiveMetadataConfiguration=false") {
|
||||
assertSuccessful()
|
||||
|
||||
assertTrue(
|
||||
containsPosixInImplementationMetadataConfiguration(),
|
||||
"Expected dependency on posix in implementationMetadataConfiguration"
|
||||
)
|
||||
|
||||
assertFalse(
|
||||
containsPosixInIntransitiveMetadataConfiguration(),
|
||||
"Expected **no** dependency on posix in intransitiveMetadataConfiguration"
|
||||
)
|
||||
}
|
||||
|
||||
build(":p1:listNativePlatformMainDependencies", "-Pkotlin.mpp.enableIntransitiveMetadataConfiguration=true") {
|
||||
assertSuccessful()
|
||||
|
||||
assertFalse(
|
||||
containsPosixInImplementationMetadataConfiguration(),
|
||||
"Expected **no** posix dependency in implementationMetadataConfiguration"
|
||||
)
|
||||
|
||||
assertTrue(
|
||||
containsPosixInIntransitiveMetadataConfiguration(),
|
||||
"Expected dependency on posix in intransitiveMetadataConfiguration"
|
||||
)
|
||||
}
|
||||
|
||||
build("assemble") {
|
||||
assertSuccessful()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun preparedProject(name: String): Project {
|
||||
return Project(name).apply {
|
||||
setupWorkingDir()
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
plugins {
|
||||
kotlin("multiplatform") apply false
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
kotlin.mpp.enableGranularSourceSetsMetadata=true
|
||||
kotlin.native.enableDependencyPropagation=false
|
||||
kotlin.mpp.enableIntransitiveMetadataConfiguration=true
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
import org.jetbrains.kotlin.com.intellij.openapi.util.SystemInfo.*
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
|
||||
|
||||
operator fun KotlinSourceSet.invoke(builder: SourceSetHierarchyBuilder.() -> Unit): KotlinSourceSet {
|
||||
SourceSetHierarchyBuilder(this).builder()
|
||||
return this
|
||||
}
|
||||
|
||||
class SourceSetHierarchyBuilder(private val node: KotlinSourceSet) {
|
||||
operator fun KotlinSourceSet.unaryMinus() = this.dependsOn(node)
|
||||
}
|
||||
|
||||
plugins {
|
||||
kotlin("multiplatform")
|
||||
}
|
||||
|
||||
kotlin {
|
||||
|
||||
val nativePlatform = when {
|
||||
isMac -> macosX64("nativePlatform")
|
||||
isLinux -> linuxX64("nativePlatform")
|
||||
isWindows -> mingwX64("nativePlatform")
|
||||
else -> throw IllegalStateException("Unsupported host")
|
||||
}
|
||||
|
||||
val commonMain by sourceSets.getting
|
||||
val nativeMain by sourceSets.creating
|
||||
val nativePlatformMain by sourceSets.getting
|
||||
|
||||
commonMain {
|
||||
-nativeMain {
|
||||
-nativePlatformMain
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register("listNativePlatformMainDependencies") {
|
||||
doLast {
|
||||
|
||||
val implementationMetadataConfigurationDependencies = project.configurations.getByName(
|
||||
nativePlatformMain.implementationMetadataConfigurationName
|
||||
).files
|
||||
|
||||
val intransitiveMetadataConfigurationDependencies = project.configurations.findByName(
|
||||
"nativePlatformMainIntransitiveDependenciesMetadata"
|
||||
)?.files.orEmpty()
|
||||
|
||||
val dependencies = implementationMetadataConfigurationDependencies +
|
||||
intransitiveMetadataConfigurationDependencies
|
||||
|
||||
logger.quiet("NativePlatformMainDependency | Count: ${dependencies.size}")
|
||||
|
||||
implementationMetadataConfigurationDependencies.forEach { dependencyFile ->
|
||||
logger.quiet("implementationMetadataConfiguration: ${dependencyFile.path}")
|
||||
}
|
||||
|
||||
intransitiveMetadataConfigurationDependencies.forEach { dependencyFile ->
|
||||
logger.quiet("intransitiveMetadataConfiguration: ${dependencyFile.path}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
@file:Suppress("unused")
|
||||
|
||||
import platform.posix.usleep
|
||||
|
||||
fun main() {
|
||||
usleep(100)
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
gradlePluginPortal()
|
||||
}
|
||||
val kotlin_version: String by settings
|
||||
plugins {
|
||||
kotlin("multiplatform").version(kotlin_version)
|
||||
}
|
||||
}
|
||||
|
||||
include(":p1")
|
||||
Reference in New Issue
Block a user