Skip to content

Commit 7389abb

Browse files
committed
Enhance GradleTaskNamesBuilder to support dynamic task detection using GradleUtils
1 parent 4f2eaa7 commit 7389abb

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/main/kotlin/io/kotest/plugin/intellij/run/GradleTaskNamesBuilder.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package io.kotest.plugin.intellij.run
22

33
import com.intellij.openapi.module.Module
44
import io.kotest.plugin.intellij.Test
5+
import io.kotest.plugin.intellij.gradle.GradleUtils
56
import org.jetbrains.kotlin.psi.KtClassOrObject
67

78
/**
@@ -24,10 +25,14 @@ data class GradleTaskNamesBuilder(
2425
return copy(test = test)
2526
}
2627

28+
@Suppress("UnstableApiUsage")
2729
fun build(): List<String> {
2830
// the debug settings do not propagate from kotest to the other test tasks yet,
2931
// so if we think we're in a jvm test we can just invoke jvmKotest directly, and then debug will work
30-
val task = if (module.name.endsWith(".test")) "jvmKotest" else "kotest"
32+
val task = if (module.name.endsWith(".test")) {
33+
val tasks = GradleUtils.listTasks(module).map { it.getFqnTaskName() }
34+
if (tasks.any { it.endsWith(":jvmKotest") }) "jvmKotest" else "kotest"
35+
} else "kotest"
3136
return listOfNotNull(task, includeArg())
3237
}
3338

0 commit comments

Comments
 (0)