[gradle-plugin] Make dependency export non-transitive by default
Fix for KT-28936.
This commit is contained in:
committed by
Ilya Matveev
parent
8e97c94005
commit
8bc172b9c1
+1
-5
@@ -43,11 +43,7 @@ open class KotlinNativeDependenciesImpl @Inject constructor(
|
|||||||
implementationDependencies.extendsFrom(this)
|
implementationDependencies.extendsFrom(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
override var transitiveExport: Boolean
|
override var transitiveExport: Boolean = false
|
||||||
get() = exportDependencies.isTransitive
|
|
||||||
set(value) {
|
|
||||||
exportDependencies.isTransitive = value
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun export(notation: Any) {
|
override fun export(notation: Any) {
|
||||||
exportDependencies.dependencies.add(dependencyHandler.create(notation))
|
exportDependencies.dependencies.add(dependencyHandler.create(notation))
|
||||||
|
|||||||
+1
@@ -60,6 +60,7 @@ open class KotlinNativeFrameworkImpl @Inject constructor(
|
|||||||
// A configuration containing exported klibs.
|
// A configuration containing exported klibs.
|
||||||
override val export = configurations.create(names.withPrefix("export")).apply {
|
override val export = configurations.create(names.withPrefix("export")).apply {
|
||||||
isCanBeConsumed = false
|
isCanBeConsumed = false
|
||||||
|
isTransitive = component.dependencies.transitiveExport
|
||||||
attributes.attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage::class.java, KotlinUsages.KOTLIN_API))
|
attributes.attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage::class.java, KotlinUsages.KOTLIN_API))
|
||||||
attributes.attribute(CppBinary.DEBUGGABLE_ATTRIBUTE, debuggable)
|
attributes.attribute(CppBinary.DEBUGGABLE_ATTRIBUTE, debuggable)
|
||||||
attributes.attribute(CppBinary.OPTIMIZED_ATTRIBUTE, optimized)
|
attributes.attribute(CppBinary.OPTIMIZED_ATTRIBUTE, optimized)
|
||||||
|
|||||||
@@ -1143,18 +1143,32 @@ class ExperimentalPluginTests {
|
|||||||
@Test
|
@Test
|
||||||
fun `Plugin should support symbol exporting for frameworks`() {
|
fun `Plugin should support symbol exporting for frameworks`() {
|
||||||
assumeTrue(HostManager.hostIsMac)
|
assumeTrue(HostManager.hostIsMac)
|
||||||
|
val transitiveDir = tmpFolder.newFolder("transitive")
|
||||||
|
val transitiveProject = KonanProject.createEmpty(transitiveDir).apply {
|
||||||
|
buildFile.writeText("""
|
||||||
|
plugins { id 'kotlin-native' }
|
||||||
|
components.main.targets = [ 'ios_x64' ]
|
||||||
|
""")
|
||||||
|
generateSrcFile("transitive.kt", "fun transitive() = 42")
|
||||||
|
}
|
||||||
|
|
||||||
val libraryDir = tmpFolder.newFolder("library")
|
val libraryDir = tmpFolder.newFolder("library")
|
||||||
val libraryProject = KonanProject.createEmpty(libraryDir).apply {
|
val libraryProject = KonanProject.createEmpty(libraryDir).apply {
|
||||||
buildFile.writeText("""
|
buildFile.writeText("""
|
||||||
plugins { id 'kotlin-native' }
|
plugins { id 'kotlin-native' }
|
||||||
components.main.targets = [ 'ios_x64' ]
|
components.main.targets = [ 'ios_x64' ]
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation project(':transitive')
|
||||||
|
}
|
||||||
""".trimIndent())
|
""".trimIndent())
|
||||||
generateSrcFile("library.kt", "fun foo() = 42")
|
generateSrcFile("library.kt", "fun foo() = transitive()")
|
||||||
}
|
}
|
||||||
|
|
||||||
val project = KonanProject.createEmpty(projectDirectory).apply {
|
val project = KonanProject.createEmpty(projectDirectory).apply {
|
||||||
settingsFile.writeText("""
|
settingsFile.writeText("""
|
||||||
include ':library'
|
include ':library'
|
||||||
|
include ':transitive'
|
||||||
rootProject.name = 'test'
|
rootProject.name = 'test'
|
||||||
""".trimIndent())
|
""".trimIndent())
|
||||||
buildFile.writeText("""
|
buildFile.writeText("""
|
||||||
@@ -1176,9 +1190,12 @@ class ExperimentalPluginTests {
|
|||||||
assertEquals(TaskOutcome.SUCCESS, task(":compileDebugKotlinNative")?.outcome)
|
assertEquals(TaskOutcome.SUCCESS, task(":compileDebugKotlinNative")?.outcome)
|
||||||
assertEquals(TaskOutcome.SUCCESS, task(":library:compileDebugKotlinNative")?.outcome)
|
assertEquals(TaskOutcome.SUCCESS, task(":library:compileDebugKotlinNative")?.outcome)
|
||||||
assertTrue(projectDirectory.resolve("build/lib/main/debug/test.framework").exists())
|
assertTrue(projectDirectory.resolve("build/lib/main/debug/test.framework").exists())
|
||||||
|
|
||||||
val header = projectDirectory.resolve("build/lib/main/debug/test.framework/Headers/test.h")
|
val header = projectDirectory.resolve("build/lib/main/debug/test.framework/Headers/test.h")
|
||||||
assertTrue(header.exists())
|
assertTrue(header.exists())
|
||||||
assertTrue(header.readText().contains("+ (int32_t)foo "))
|
assertTrue(header.readText().contains("+ (int32_t)foo "))
|
||||||
|
assertFalse(header.readText().contains("+ (int32_t)transitive")) // By default export is non-transitive.
|
||||||
|
|
||||||
checkFrameworkCompilationCommandLine {
|
checkFrameworkCompilationCommandLine {
|
||||||
assertTrue(it.contains("-Xembed-bitcode-marker"))
|
assertTrue(it.contains("-Xembed-bitcode-marker"))
|
||||||
assertTrue(it.contains("-g"))
|
assertTrue(it.contains("-g"))
|
||||||
@@ -1192,5 +1209,14 @@ class ExperimentalPluginTests {
|
|||||||
assertTrue(it.contains("-opt"))
|
assertTrue(it.contains("-opt"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check that transitive export works too.
|
||||||
|
project.buildFile.appendText("\ncomponents.main.dependencies.transitiveExport = true")
|
||||||
|
with(project.createRunner().withArguments("compileDebugKotlinNative").build()) {
|
||||||
|
val header = projectDirectory.resolve("build/lib/main/debug/test.framework/Headers/test.h")
|
||||||
|
assertTrue(header.exists())
|
||||||
|
assertTrue(header.readText().contains("+ (int32_t)foo "))
|
||||||
|
assertTrue(header.readText().contains("+ (int32_t)transitive"))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user