[Gradle, Native, IT] Add test for exporting published lib

This test checks that `transitiveExport = true` is no longer required
for exporting a published multiplatform library in a native library.
This commit is contained in:
Svyatoslav Scherbina
2022-05-25 15:43:30 +03:00
committed by Space
parent 045528e643
commit c45a3d39b1
6 changed files with 82 additions and 0 deletions
@@ -459,6 +459,34 @@ class GeneralNativeIT : BaseGradleIT() {
}
}
@Test
fun testTransitiveExportIsNotRequiredForExportingVariant() = with(
transformNativeTestProjectWithPluginDsl(
wrapperVersion = GradleVersionRequired.AtLeast("6.8"), // See https://youtrack.jetbrains.com/issue/KT-52447
projectName = "export-published-lib",
directoryPrefix = "native-binaries"
)
) {
val binaryName = "shared"
val headerPath = "shared/build/bin/linuxX64/debugStatic/lib${binaryName}_api.h"
val binaryBuildTask = "linkDebugStaticLinuxX64"
build(":lib:publish") {
assertSuccessful()
}
build(":shared:$binaryBuildTask") {
assertSuccessful()
assertFileExists(headerPath)
val headerContents = fileInWorkingDir(headerPath).readText()
assertTrue(headerContents.contains("funInShared"))
// Check that the function from exported published library (:lib) is included to the header:
assertTrue(headerContents.contains("funToExport"))
}
}
@Test
fun testNativeExecutables() = with(transformNativeTestProjectWithPluginDsl("executables", directoryPrefix = "native-binaries")) {
val binaries = mutableListOf(
@@ -0,0 +1,24 @@
plugins {
kotlin("multiplatform").version("<pluginMarkerVersion>")
`maven-publish`
}
repositories {
mavenLocal()
maven("../repo")
mavenCentral()
}
group = "com.example"
version = "1.0"
kotlin {
jvm()
linuxX64()
}
publishing {
repositories {
maven("../repo")
}
}
@@ -0,0 +1,26 @@
plugins {
kotlin("multiplatform").version("<pluginMarkerVersion>")
}
repositories {
mavenLocal()
maven("../repo")
mavenCentral()
}
kotlin {
jvm()
linuxX64 {
binaries.staticLib {
export("com.example:lib:1.0")
}
}
sourceSets {
val commonMain by getting {
dependencies {
api("com.example:lib:1.0")
}
}
}
}