Generate Kapt task name for random KotlinCompile task name

We had false assumption that KotlinCompile tasks name will always start
with "compile" prefix, but our exposed api allows to create tasks with
random names. I've adjusted method to calculate kapt task names for any
KotlinCompile task name.

^KT-54468
This commit is contained in:
Yahor Berdnikau
2023-04-25 14:27:29 +02:00
committed by Space Team
parent 552e640517
commit c64a7068d9
@@ -498,9 +498,14 @@ internal fun getKaptTaskName(
kotlinCompileName: String,
prefix: String
): String {
// Replace compile*Kotlin to kapt*Kotlin
assert(kotlinCompileName.startsWith("compile"))
return kotlinCompileName.replaceFirst("compile", prefix)
return if (kotlinCompileName.startsWith("compile")) {
// Replace compile*Kotlin to kapt*Kotlin
kotlinCompileName.replaceFirst("compile", prefix)
} else {
// Task was created via exposed apis (KotlinJvmFactory or MPP) with random name
// in such case adding 'kapt' prefix to name
"$prefix${kotlinCompileName.capitalizeAsciiOnly()}"
}
}
internal fun buildKaptSubpluginOptions(