diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/native/GeneralNativeIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/native/GeneralNativeIT.kt index 0e707a235d7..e99f1246264 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/native/GeneralNativeIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/native/GeneralNativeIT.kt @@ -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( diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-binaries/export-published-lib/lib/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-binaries/export-published-lib/lib/build.gradle.kts new file mode 100644 index 00000000000..0b6c8d2c417 --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-binaries/export-published-lib/lib/build.gradle.kts @@ -0,0 +1,24 @@ +plugins { + kotlin("multiplatform").version("") + `maven-publish` +} + +repositories { + mavenLocal() + maven("../repo") + mavenCentral() +} + +group = "com.example" +version = "1.0" + +kotlin { + jvm() + linuxX64() +} + +publishing { + repositories { + maven("../repo") + } +} diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-binaries/export-published-lib/lib/src/commonMain/kotlin/test.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-binaries/export-published-lib/lib/src/commonMain/kotlin/test.kt new file mode 100644 index 00000000000..57959d65da5 --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-binaries/export-published-lib/lib/src/commonMain/kotlin/test.kt @@ -0,0 +1 @@ +fun funToExport() {} diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-binaries/export-published-lib/settings.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-binaries/export-published-lib/settings.gradle.kts new file mode 100644 index 00000000000..18e97784334 --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-binaries/export-published-lib/settings.gradle.kts @@ -0,0 +1,2 @@ +include("lib") +include("shared") diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-binaries/export-published-lib/shared/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-binaries/export-published-lib/shared/build.gradle.kts new file mode 100644 index 00000000000..62dcc10847c --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-binaries/export-published-lib/shared/build.gradle.kts @@ -0,0 +1,26 @@ +plugins { + kotlin("multiplatform").version("") +} + +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") + } + } + } +} diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-binaries/export-published-lib/shared/src/commonMain/kotlin/shared.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-binaries/export-published-lib/shared/src/commonMain/kotlin/shared.kt new file mode 100644 index 00000000000..e56eb1b443b --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-binaries/export-published-lib/shared/src/commonMain/kotlin/shared.kt @@ -0,0 +1 @@ +fun funInShared() {}