Use KOTLIN_API usage in cinterop dependencies.
Issue #KT-27803 fixed.
This commit is contained in:
committed by
Ilya Matveev
parent
d28c6559b8
commit
e0a83b6159
+50
-32
@@ -819,44 +819,62 @@ class NewMultiplatformIT : BaseGradleIT() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testCinterop() = with(Project("new-mpp-native-cinterop", gradleVersion)) {
|
fun testCinterop() {
|
||||||
val host = nativeHostTargetName
|
val libProject = Project("sample-lib", gradleVersion, "new-mpp-lib-and-app")
|
||||||
build(":projectLibrary:build") {
|
libProject.build("publish") {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
assertTasksExecuted(":projectLibrary:cinteropStdio${host.capitalize()}")
|
|
||||||
assertTrue(output.contains("Project test"), "No test output found")
|
|
||||||
assertFileExists("projectLibrary/build/classes/kotlin/$host/main/projectLibrary-cinterop-stdio.klib")
|
|
||||||
}
|
}
|
||||||
|
val repo = libProject.projectDir.resolve("repo").absolutePath.replace('\\', '/')
|
||||||
|
|
||||||
build(":publishedLibrary:build", ":publishedLibrary:publish") {
|
with(Project("new-mpp-native-cinterop", gradleVersion)) {
|
||||||
assertSuccessful()
|
|
||||||
assertTasksExecuted(":publishedLibrary:cinteropStdio${host.capitalize()}")
|
|
||||||
assertTrue(output.contains("Published test"), "No test output found")
|
|
||||||
assertFileExists("publishedLibrary/build/classes/kotlin/$host/main/publishedLibrary-cinterop-stdio.klib")
|
|
||||||
assertFileExists("repo/org/example/publishedLibrary-$host/1.0/publishedLibrary-$host-1.0-cinterop-stdio.klib")
|
|
||||||
}
|
|
||||||
|
|
||||||
build(":build") {
|
setupWorkingDir()
|
||||||
assertSuccessful()
|
listOf(gradleBuildScript(), gradleBuildScript("publishedLibrary")).forEach {
|
||||||
assertTrue(output.contains("Dependent: Project print"), "No test output found")
|
it.appendText("""
|
||||||
assertTrue(output.contains("Dependent: Published print"), "No test output found")
|
repositories {
|
||||||
}
|
maven { url '$repo' }
|
||||||
|
}
|
||||||
|
""".trimIndent())
|
||||||
|
}
|
||||||
|
|
||||||
// Check that changing the compiler version in properties causes interop reprocessing and source recompilation.
|
val host = nativeHostTargetName
|
||||||
build(":projectLibrary:build") {
|
build(":projectLibrary:build") {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
assertTasksUpToDate(
|
assertTasksExecuted(":projectLibrary:cinteropStdio${host.capitalize()}")
|
||||||
":projectLibrary:cinteropStdio${host.capitalize()}",
|
assertTrue(output.contains("Project test"), "No test output found")
|
||||||
":projectLibrary:compileKotlin${host.capitalize()}"
|
assertFileExists("projectLibrary/build/classes/kotlin/$host/main/projectLibrary-cinterop-stdio.klib")
|
||||||
)
|
}
|
||||||
}
|
|
||||||
|
|
||||||
build(":projectLibrary:build", "-Porg.jetbrains.kotlin.native.version=0.9.2") {
|
build(":publishedLibrary:build", ":publishedLibrary:publish") {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
assertTasksExecuted(
|
assertTasksExecuted(":publishedLibrary:cinteropStdio${host.capitalize()}")
|
||||||
":projectLibrary:cinteropStdio${host.capitalize()}",
|
assertTrue(output.contains("Published test"), "No test output found")
|
||||||
":projectLibrary:compileKotlin${host.capitalize()}"
|
assertFileExists("publishedLibrary/build/classes/kotlin/$host/main/publishedLibrary-cinterop-stdio.klib")
|
||||||
)
|
assertFileExists("repo/org/example/publishedLibrary-$host/1.0/publishedLibrary-$host-1.0-cinterop-stdio.klib")
|
||||||
|
}
|
||||||
|
|
||||||
|
build(":build") {
|
||||||
|
assertSuccessful()
|
||||||
|
assertTrue(output.contains("Dependent: Project print"), "No test output found")
|
||||||
|
assertTrue(output.contains("Dependent: Published print"), "No test output found")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check that changing the compiler version in properties causes interop reprocessing and source recompilation.
|
||||||
|
build(":projectLibrary:build") {
|
||||||
|
assertSuccessful()
|
||||||
|
assertTasksUpToDate(
|
||||||
|
":projectLibrary:cinteropStdio${host.capitalize()}",
|
||||||
|
":projectLibrary:compileKotlin${host.capitalize()}"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
build(":projectLibrary:build", "-Porg.jetbrains.kotlin.native.version=0.9.2") {
|
||||||
|
assertSuccessful()
|
||||||
|
assertTasksExecuted(
|
||||||
|
":projectLibrary:cinteropStdio${host.capitalize()}",
|
||||||
|
":projectLibrary:compileKotlin${host.capitalize()}"
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-2
@@ -12,7 +12,11 @@ repositories {
|
|||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
sourceSets {
|
sourceSets {
|
||||||
allNative
|
allNative {
|
||||||
|
dependencies {
|
||||||
|
implementation 'com.example:sample-lib:1.0'
|
||||||
|
}
|
||||||
|
}
|
||||||
nativeTest
|
nativeTest
|
||||||
|
|
||||||
macos64Main { dependsOn sourceSets.allNative }
|
macos64Main { dependsOn sourceSets.allNative }
|
||||||
@@ -41,7 +45,6 @@ kotlin {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
publishing {
|
publishing {
|
||||||
repositories {
|
repositories {
|
||||||
maven {
|
maven {
|
||||||
|
|||||||
+2
@@ -6,7 +6,9 @@
|
|||||||
package example.cinterop.published
|
package example.cinterop.published
|
||||||
|
|
||||||
import example.cinterop.published.stdio.*
|
import example.cinterop.published.stdio.*
|
||||||
|
import com.example.lib.*
|
||||||
|
|
||||||
fun publishedPrint(str: String) {
|
fun publishedPrint(str: String) {
|
||||||
printf(str + '\n')
|
printf(str + '\n')
|
||||||
|
println(id(42))
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -705,7 +705,7 @@ open class KotlinNativeTargetConfigurator(
|
|||||||
usesPlatformOf(target)
|
usesPlatformOf(target)
|
||||||
isVisible = false
|
isVisible = false
|
||||||
isCanBeConsumed = false
|
isCanBeConsumed = false
|
||||||
attributes.attribute(USAGE_ATTRIBUTE, compilation.target.project.usageByName(Usage.JAVA_API))
|
attributes.attribute(USAGE_ATTRIBUTE, compilation.target.project.usageByName(KotlinUsages.KOTLIN_API))
|
||||||
description = "Dependencies for cinterop '${cinterop.name}' (compilation '${compilation.name}')."
|
description = "Dependencies for cinterop '${cinterop.name}' (compilation '${compilation.name}')."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user