From ae68eee16bcd84c30329846ee4a00e18b05a1082 Mon Sep 17 00:00:00 2001 From: Vadim Mishenev Date: Fri, 29 Nov 2024 18:15:21 +0200 Subject: [PATCH] Add a test for #3702 (#3941) --- .../src/test/kotlin/translators/KMPTest.kt | 69 ++++++++++++++++++ .../resources/jars/jvmAndroidLib-jvm-copy.jar | Bin 0 -> 996 bytes .../test/resources/jars/jvmAndroidLib-jvm.jar | Bin 0 -> 996 bytes 3 files changed, 69 insertions(+) create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/translators/KMPTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/resources/jars/jvmAndroidLib-jvm-copy.jar create mode 100644 dokka-subprojects/plugin-base/src/test/resources/jars/jvmAndroidLib-jvm.jar diff --git a/dokka-subprojects/plugin-base/src/test/kotlin/translators/KMPTest.kt b/dokka-subprojects/plugin-base/src/test/kotlin/translators/KMPTest.kt new file mode 100644 index 0000000000..cfa1ec1a4c --- /dev/null +++ b/dokka-subprojects/plugin-base/src/test/kotlin/translators/KMPTest.kt @@ -0,0 +1,69 @@ +/* + * Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + */ + +package translators + +import org.jetbrains.dokka.model.* +import utils.AbstractModelTest +import java.io.File +import kotlin.test.Test +import kotlin.test.assertTrue + +class KMPTest : AbstractModelTest("/src/main/kotlin/kmp/Test.kt", "kmp") { + + // copy-pasted org.jetbrains.dokka.analysis.test.api.util.getResourceAbsolutePath + private fun getResourceAbsolutePath(resourcePath: String): String { + val resource = object {}.javaClass.classLoader.getResource(resourcePath)?.file + ?: throw IllegalArgumentException("Resource not found: $resourcePath") + + return File(resource).absolutePath + } + + val configuration = dokkaConfiguration { + sourceSets { + sourceSet { + sourceRoots = listOf("src/androidMain/kotlin") + analysisPlatform = "jvm" + name = "android-example" + // contains only `class Firebase` + classpath = listOf(getResourceAbsolutePath("jars/jvmAndroidLib-jvm-copy.jar")) + } + sourceSet { + sourceRoots = listOf("src/jvmMain/kotlin") + analysisPlatform = "jvm" + name = "jvm-example" + // contains only `class Firebase` + classpath = listOf(getResourceAbsolutePath("jars/jvmAndroidLib-jvm.jar")) + } + + } + } + + @Test + fun `should resolve Firebase from the same renamed jars #3702`() { + inlineModelTest( + """ + |/src/androidMain/kotlin/main.kt + |package example + |import Firebase + | + |fun android(f: Firebase){} + | + |/src/jvmMain/kotlin/main.kt + |package example + |import Firebase + | + |fun jvm(f: Firebase){} + """, + configuration = configuration + ) { + with((this / "example" / "android").cast()) { + assertTrue(parameters[0].type is GenericTypeConstructor) + } + with((this / "example" / "jvm").cast()) { + assertTrue(parameters[0].type is GenericTypeConstructor) + } + } + } +} diff --git a/dokka-subprojects/plugin-base/src/test/resources/jars/jvmAndroidLib-jvm-copy.jar b/dokka-subprojects/plugin-base/src/test/resources/jars/jvmAndroidLib-jvm-copy.jar new file mode 100644 index 0000000000000000000000000000000000000000..d1dc7d1386051520ba03ecc79bcb7b7b2b1ec70e GIT binary patch literal 996 zcmWIWW@Zs#VBp|jU|?_rVg?2#Fv-Bc38Z~pLmYKI{oM4K83IrgZmMT`Ck<2}3B*9{ z2!+0mex7cw!6ACSZl8V6oc8h7)w{^+t*dqJ%=yhh23L$9Jbm<(3C*z9j2fLYj0_BA zK&$zHhPh=Hr6wg7r|Ko=Bo-H^2KeS*b`Y5pYu)#Fhl#Gduf~1WPJYhqwoZ;*qEmGw zn=?c?pKkG+wy87O`Z;RVM_5=^#uc;u}s)w_d7)ko8ck1-9WJ+9HT%&Ml zp2n1irx%vb@b7N431};sc5LteoQ=+vH?Phw^QpPAUbuM0b|0=U*R;x-BN9F>h}&Jy z^?ixezMUe{&Cwx$?=zX4;3~NIr@FHF%CpQm*7{c`EFh?B+XJ!Cqk557X literal 0 HcmV?d00001 diff --git a/dokka-subprojects/plugin-base/src/test/resources/jars/jvmAndroidLib-jvm.jar b/dokka-subprojects/plugin-base/src/test/resources/jars/jvmAndroidLib-jvm.jar new file mode 100644 index 0000000000000000000000000000000000000000..d1dc7d1386051520ba03ecc79bcb7b7b2b1ec70e GIT binary patch literal 996 zcmWIWW@Zs#VBp|jU|?_rVg?2#Fv-Bc38Z~pLmYKI{oM4K83IrgZmMT`Ck<2}3B*9{ z2!+0mex7cw!6ACSZl8V6oc8h7)w{^+t*dqJ%=yhh23L$9Jbm<(3C*z9j2fLYj0_BA zK&$zHhPh=Hr6wg7r|Ko=Bo-H^2KeS*b`Y5pYu)#Fhl#Gduf~1WPJYhqwoZ;*qEmGw zn=?c?pKkG+wy87O`Z;RVM_5=^#uc;u}s)w_d7)ko8ck1-9WJ+9HT%&Ml zp2n1irx%vb@b7N431};sc5LteoQ=+vH?Phw^QpPAUbuM0b|0=U*R;x-BN9F>h}&Jy z^?ixezMUe{&Cwx$?=zX4;3~NIr@FHF%CpQm*7{c`EFh?B+XJ!Cqk557X literal 0 HcmV?d00001