mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 15:19:59 +07:00
[Kotlin, Gradle] Fix legacy Android projects do not have associated test tasks for Android unit tests
The logic was relying on the 'KotlinTarget.presetName' value, which became always 'null' since the Kotlin 2.2.0 release. Fortunately, we could rely on the 'KotlinTarget.platformType' value, which has a specific value for Android projects: "androidJvm". The new Android external plugin uses "jvm" for this property. ^KTIJ-34139 Verification Pending (cherry picked from commit 9fdb1a1cdd056027d6fae2dfdda7342b6a00eaef) IJ-MR-167142 GitOrigin-RevId: b1c6340053e413bea11cf44377919ff3c1f4dad0
This commit is contained in:
committed by
intellij-monorepo-bot
parent
fc67d0a684
commit
49bad69936
@@ -148,11 +148,12 @@ object KotlinTargetBuilder : KotlinMultiplatformComponentBuilder<KotlinTargetRef
|
||||
val getJvmTargetName = jvmTestTaskClass.getDeclaredMethodOrNull("getTargetName") ?: return emptyList()
|
||||
|
||||
/**
|
||||
* Only run this branch for the 'KotlinAndroidTarget' maintained in KGP:
|
||||
* This target can be identified checking the 'presetName' here.
|
||||
* Only run this branch for the 'KotlinAndroidTarget' maintained in KGP:
|
||||
* This target can be identified by checking the 'presetName' here.
|
||||
* The External Android target will not have any presetName as it is using the external target API instead of presets.
|
||||
* 'KotlinTargetReflection.presetName' is always 'null' starting Kotlin 2.2.0 release.
|
||||
*/
|
||||
if (target.presetName == "android") {
|
||||
if (target.presetName == "android" || target.platformType == "androidJvm") {
|
||||
val androidUnitTestClass = gradleTarget.testTaskClass("com.android.build.gradle.tasks.factory.AndroidUnitTest")
|
||||
?: return emptyList()
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ my-app.commonMain
|
||||
|
||||
my-app.commonTest
|
||||
commonMain (friend, TEST)
|
||||
org.jetbrains.kotlin:kotlin-stdlib:commonMain:{{KGP_VERSION}} (TEST)
|
||||
|
||||
my-app.jsMain
|
||||
commonMain (refines, COMPILE)
|
||||
|
||||
Reference in New Issue
Block a user