[Gradle] KT-56729: Implement 'commonize-kt-56729-consume-library-with-two-roots' test
... to cover KT-56729
This commit is contained in:
committed by
Space Team
parent
477d092bb8
commit
7026ca9952
+16
-1
@@ -675,7 +675,8 @@ class CommonizerIT : BaseGradleIT() {
|
|||||||
fun `test KT-52243 cinterop caching`() {
|
fun `test KT-52243 cinterop caching`() {
|
||||||
with(preparedProject("commonizeCurlInterop")) {
|
with(preparedProject("commonizeCurlInterop")) {
|
||||||
val localBuildCacheDir = projectDir.resolve("local-build-cache-dir").also { assertTrue(it.mkdirs()) }
|
val localBuildCacheDir = projectDir.resolve("local-build-cache-dir").also { assertTrue(it.mkdirs()) }
|
||||||
gradleSettingsScript().appendText("""
|
gradleSettingsScript().appendText(
|
||||||
|
"""
|
||||||
|
|
||||||
buildCache {
|
buildCache {
|
||||||
local {
|
local {
|
||||||
@@ -708,6 +709,20 @@ class CommonizerIT : BaseGradleIT() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `test KT-56729 commonization with library containing two roots`() {
|
||||||
|
with(Project("commonize-kt-56729-consume-library-with-two-roots")) {
|
||||||
|
build("publish") {
|
||||||
|
assertSuccessful()
|
||||||
|
}
|
||||||
|
|
||||||
|
build(":consumer:assemble") {
|
||||||
|
assertSuccessful()
|
||||||
|
assertTasksExecuted(":consumer:compileCommonMainKotlinMetadata")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun preparedProject(name: String): Project {
|
private fun preparedProject(name: String): Project {
|
||||||
return Project(name).apply {
|
return Project(name).apply {
|
||||||
setupWorkingDir()
|
setupWorkingDir()
|
||||||
|
|||||||
+30
@@ -0,0 +1,30 @@
|
|||||||
|
@file:Suppress("OPT_IN_USAGE")
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
kotlin("multiplatform")
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
maven(project(":producer").buildDir.resolve("repo"))
|
||||||
|
mavenLocal()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
linuxArm64()
|
||||||
|
linuxX64()
|
||||||
|
|
||||||
|
targetHierarchy.default()
|
||||||
|
|
||||||
|
sourceSets.commonMain.get().dependencies {
|
||||||
|
implementation("org.jetbrains.sample:producer:1.0.0-SNAPSHOT")
|
||||||
|
}
|
||||||
|
|
||||||
|
targets.withType<KotlinNativeTarget>().all {
|
||||||
|
compilations.getByName("main").cinterops.create("consumer-c-library") {
|
||||||
|
header("src/consumer-c-library.h")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
object CommonMain {
|
||||||
|
init {
|
||||||
|
ProducerNativeCommonMain.fromCInterop().value
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
void myConsumerCLibraryFunction();
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
kotlin.mpp.enableCInteropCommonization=true
|
||||||
+34
@@ -0,0 +1,34 @@
|
|||||||
|
@file:Suppress("OPT_IN_USAGE")
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
kotlin("multiplatform")
|
||||||
|
`maven-publish`
|
||||||
|
}
|
||||||
|
|
||||||
|
version = "1.0.0-SNAPSHOT"
|
||||||
|
group = "org.jetbrains.sample"
|
||||||
|
|
||||||
|
publishing {
|
||||||
|
repositories {
|
||||||
|
maven(buildDir.resolve("repo"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
linuxX64()
|
||||||
|
linuxArm64()
|
||||||
|
|
||||||
|
targetHierarchy.custom {
|
||||||
|
group("nativeCommon") {
|
||||||
|
withNative()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
targets.withType<KotlinNativeTarget>().all {
|
||||||
|
compilations.getByName("main").cinterops.create("producer-cinterop-library") {
|
||||||
|
header("src/producer-c-library.h")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
import `producer-cinterop-library`.ProducerCLibraryStruct
|
||||||
|
|
||||||
|
object ProducerNativeCommonMain {
|
||||||
|
fun fromCInterop(): ProducerCLibraryStruct = error("Stub!")
|
||||||
|
}
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
struct ProducerCLibraryStruct {
|
||||||
|
int value;
|
||||||
|
};
|
||||||
+9
@@ -0,0 +1,9 @@
|
|||||||
|
dependencyResolutionManagement {
|
||||||
|
repositories {
|
||||||
|
mavenLocal()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
include(":producer")
|
||||||
|
include(":consumer")
|
||||||
Reference in New Issue
Block a user