From ded5f6191ff32e22f852c7adc03f7b07906632c8 Mon Sep 17 00:00:00 2001 From: Jens Klingenberg Date: Thu, 29 Aug 2024 22:55:35 +0200 Subject: [PATCH] Add check if "test" target exist #638 --- .../ktorfit/gradle/KtorfitGradlePlugin.kt | 32 +++++++------------ 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/ktorfit-gradle-plugin/src/main/java/de/jensklingenberg/ktorfit/gradle/KtorfitGradlePlugin.kt b/ktorfit-gradle-plugin/src/main/java/de/jensklingenberg/ktorfit/gradle/KtorfitGradlePlugin.kt index 8eb88a814..eb9eebb75 100644 --- a/ktorfit-gradle-plugin/src/main/java/de/jensklingenberg/ktorfit/gradle/KtorfitGradlePlugin.kt +++ b/ktorfit-gradle-plugin/src/main/java/de/jensklingenberg/ktorfit/gradle/KtorfitGradlePlugin.kt @@ -71,33 +71,25 @@ class KtorfitGradlePlugin : Plugin { kotlinExtension.targets.configureEach { if (targetName == "metadata") return@configureEach - dependencies.add( - "ksp${ - targetName.replaceFirstChar { - if (it.isLowerCase()) { - it.titlecase( - US, - ) - } else { - it.toString() - } + val capitalizedTargetName = + targetName.replaceFirstChar { + if (it.isLowerCase()) { + it.titlecase( + US, + ) + } else { + it.toString() } - }", + } + dependencies.add( + "ksp$capitalizedTargetName", dependency, ) if (this.compilations.any { it.name == "test" }) { dependencies.add( "ksp${ - targetName.replaceFirstChar { - if (it.isLowerCase()) { - it.titlecase( - US, - ) - } else { - it.toString() - } - } + capitalizedTargetName }Test", dependency, )