[Gradle][Native] Implement "kt-55071-compileSharedNative-withDefaultParameters" IT

^KT-55071 Verification Pending
This commit is contained in:
Sebastian Sellmair
2022-11-23 10:39:32 +01:00
committed by Space Team
parent 752ff04245
commit 4c62b3b46b
13 changed files with 171 additions and 0 deletions
@@ -979,6 +979,24 @@ class HierarchicalMppIT : KGPBaseTest() {
}
}
@GradleTest
@DisplayName("KT-55071: Shared Native Compilations: Use default parameters declared in dependsOn source set")
fun `test shared native compilation with default parameters declared in dependsOn source set`(gradleVersion: GradleVersion) {
with(project("kt-55071-compileSharedNative-withDefaultParameters", gradleVersion = gradleVersion)) {
build(":producer:publish") {
assertTasksExecuted(":producer:compileCommonMainKotlinMetadata")
assertTasksExecuted(":producer:compileSecondCommonMainKotlinMetadata")
assertTasksExecuted(":producer:compileNativeMainKotlinMetadata")
}
build(":consumer:assemble") {
assertTasksExecuted(":consumer:compileCommonMainKotlinMetadata")
assertTasksExecuted(":consumer:compileNativeMainKotlinMetadata")
}
}
}
private fun TestProject.testDependencyTransformations(
subproject: String? = null,
check: BuildResult.(reports: Iterable<DependencyTransformationReport>) -> Unit
@@ -0,0 +1,6 @@
allprojects {
repositories {
mavenLocal()
mavenCentral()
}
}
@@ -0,0 +1,45 @@
@file:Suppress("OPT_IN_USAGE")
plugins {
kotlin("multiplatform")
}
repositories {
mavenLocal()
maven(project(":producer").buildDir.resolve("repository"))
mavenCentral()
}
kotlin {
jvm()
js().browser()
linuxX64()
linuxArm64()
val commonMain by sourceSets.getting
val nativeMain by sourceSets.creating
val jvmAndJsMain by sourceSets.creating
val jvmMain by sourceSets.getting
val jsMain by sourceSets.getting
val linuxX64Main by sourceSets.getting
val linuxArm64Main by sourceSets.getting
commonMain.let {
nativeMain.dependsOn(it)
jvmAndJsMain.dependsOn(it)
}
nativeMain.let {
linuxArm64Main.dependsOn(it)
linuxX64Main.dependsOn(it)
}
jvmAndJsMain.let {
jvmMain.dependsOn(it)
jsMain.dependsOn(it)
}
commonMain.dependencies {
implementation("org.jetbrains.sample:producer:1.0.0")
}
}
@@ -0,0 +1,3 @@
kotlin.code.style=official
kotlin.js.generate.executable.default=false
kotlin.js.compiler=ir
@@ -0,0 +1,59 @@
@file:Suppress("OPT_IN_USAGE")
plugins {
kotlin("multiplatform")
`maven-publish`
}
repositories {
mavenLocal()
mavenCentral()
}
kotlin {
jvm()
js().browser()
linuxX64()
linuxArm64()
val commonMain by sourceSets.getting
val nativeMain by sourceSets.creating
val secondCommonMain by sourceSets.creating
val jvmAndJsMain by sourceSets.creating
val jvmMain by sourceSets.getting
val jsMain by sourceSets.getting
val linuxX64Main by sourceSets.getting
val linuxArm64Main by sourceSets.getting
commonMain.let {
secondCommonMain.dependsOn(it)
}
secondCommonMain.let {
nativeMain.dependsOn(it)
jvmAndJsMain.dependsOn(it)
}
nativeMain.let {
linuxArm64Main.dependsOn(it)
linuxX64Main.dependsOn(it)
}
jvmAndJsMain.let {
jvmMain.dependsOn(it)
jsMain.dependsOn(it)
}
}
group = "org.jetbrains.sample"
version = "1.0.0"
publishing {
repositories {
maven(buildDir.resolve("repository")) {
name = "build"
}
}
}
@@ -0,0 +1,5 @@
package producer
expect class Producer constructor() {
fun foo(value: String, optionalParameter: Boolean = false)
}
@@ -0,0 +1,5 @@
package producer
actual class Producer {
actual fun foo(value: String, optionalParameter: Boolean) = Unit
}
@@ -0,0 +1,10 @@
package producer
actual class Producer {
actual fun foo(value: String, optionalParameter: Boolean) = Unit
}
fun inProducerNativeMain() {
producerSecondCommonMain()
Producer().foo("") // <- No value passed for parameter 'optionalParameter'
}