[Gradle] Explicitly forbid an interop-binding self-dependency in CocoaPods plugin

This commit is contained in:
Artem Daugel-Dauge
2023-05-17 15:45:02 +02:00
committed by Space Team
parent bff1520c9e
commit f7acbb5252
2 changed files with 19 additions and 0 deletions
@@ -1334,6 +1334,21 @@ class CocoaPodsIT : BaseGradleIT() {
}
}
@Test
fun `configuration fails when pod depends on itself`() = with(getProjectByName("native-cocoapods-dependant-pods")) {
gradleBuildScript().appendToCocoapodsBlock("""
pod("Foo") { useInteropBindingFrom("Foo") }
""".trimIndent())
build(
":help",
"-Pkotlin.native.cocoapods.generate.wrapper=true",
) {
assertFailed()
assertContains("Pod 'Foo' has an interop-binding dependency on itself")
}
}
// test configuration phase
private class CustomHooks {
@@ -378,6 +378,10 @@ open class KotlinCocoapodsPlugin : Plugin<Project> {
interop: DefaultCInteropSettings,
dependencyName: String,
) {
if (pod.name == dependencyName) {
error("Pod '${pod.name}' has an interop-binding dependency on itself")
}
val dependencyPod = cocoapodsExtension.pods.findByName(dependencyName)
?: error("Couldn't find declaration of pod '$dependencyName' (interop-binding dependency of pod '${pod.name}')")