From 699903767721c5d28025f2c48b66e06f0bfb81cd Mon Sep 17 00:00:00 2001 From: Igor Escodro Date: Sun, 8 Feb 2026 16:49:09 -0500 Subject: [PATCH 1/9] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Refactor=20dependency?= =?UTF-8?q?=20configuration=20in=20`ProjectExtensions`=20for=20better=20re?= =?UTF-8?q?adability?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Simplified target name capitalization logic and replaced raw string construction with constants to improve maintainability. --- .../techdebt/gradle/extension/ProjectExtensions.kt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/techdebt-gradle-plugin/src/main/kotlin/com/escodro/techdebt/gradle/extension/ProjectExtensions.kt b/techdebt-gradle-plugin/src/main/kotlin/com/escodro/techdebt/gradle/extension/ProjectExtensions.kt index f360000..f1ea483 100644 --- a/techdebt-gradle-plugin/src/main/kotlin/com/escodro/techdebt/gradle/extension/ProjectExtensions.kt +++ b/techdebt-gradle-plugin/src/main/kotlin/com/escodro/techdebt/gradle/extension/ProjectExtensions.kt @@ -53,10 +53,11 @@ fun Project.configureKmpPlugins() { extensions.getByType(KotlinMultiplatformExtension::class.java).targets.all { target -> if (target.name == KMP_METADATA_TARGET) return@all - val configurationName = - "ksp${target.name.replaceFirstChar { + val target: String = + target.name.replaceFirstChar { if (it.isLowerCase()) it.titlecase(getDefault()) else it.toString() - }}" + } + val configurationName = "$KSP_PARAM$target" // Check if the configuration exists before adding the dependency if (configurations.findByName(configurationName) != null) { @@ -67,7 +68,7 @@ fun Project.configureKmpPlugins() { } else { // Fallback: Use the general 'ksp' configuration if the specific one doesn't // exist or just skip it if it's not applicable for this target. - dependencies.add("ksp", "$TECH_DEBT_PROCESSOR_DEPENDENCY:${getPluginVersion()}") + dependencies.add(KSP_PARAM, "$TECH_DEBT_PROCESSOR_DEPENDENCY:${getPluginVersion()}") } } dependencies.add( From d4f308f510afbdf7550b088e1ea23dbcf75eda75 Mon Sep 17 00:00:00 2001 From: Igor Escodro Date: Sun, 8 Feb 2026 16:54:41 -0500 Subject: [PATCH 2/9] =?UTF-8?q?=E2=9C=85=20Add=20validation=20for=20`getPl?= =?UTF-8?q?uginVersion`=20and=20improve=20test=20coverage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refactored `getPluginVersion` to include detailed validation for missing or blank versions, added unit tests for edge cases, and removed unnecessary `Logger` usage for cleaner code. --- .../gradle/extension/PropertiesExtensions.kt | 21 +++++------- .../extension/PropertiesExtensionsTest.kt | 33 +++++++++++++++++++ .../test/resources/blank_version.properties | 1 + .../src/test/resources/no_version.properties | 1 + .../src/test/resources/techdebt.properties | 1 + 5 files changed, 44 insertions(+), 13 deletions(-) create mode 100644 techdebt-gradle-plugin/src/test/kotlin/com/escodro/techdebt/gradle/extension/PropertiesExtensionsTest.kt create mode 100644 techdebt-gradle-plugin/src/test/resources/blank_version.properties create mode 100644 techdebt-gradle-plugin/src/test/resources/no_version.properties create mode 100644 techdebt-gradle-plugin/src/test/resources/techdebt.properties diff --git a/techdebt-gradle-plugin/src/main/kotlin/com/escodro/techdebt/gradle/extension/PropertiesExtensions.kt b/techdebt-gradle-plugin/src/main/kotlin/com/escodro/techdebt/gradle/extension/PropertiesExtensions.kt index 855fcca..4135df1 100644 --- a/techdebt-gradle-plugin/src/main/kotlin/com/escodro/techdebt/gradle/extension/PropertiesExtensions.kt +++ b/techdebt-gradle-plugin/src/main/kotlin/com/escodro/techdebt/gradle/extension/PropertiesExtensions.kt @@ -2,7 +2,6 @@ package com.escodro.techdebt.gradle.extension import com.escodro.techdebt.gradle.TechDebtPlugin import java.util.* -import org.apache.log4j.Logger private const val TECH_DEBT_PROPERTIES = "techdebt.properties" private const val VERSION_PROPERTY = "version" @@ -13,29 +12,25 @@ private const val VERSION_PROPERTY = "version" * * @return the plugin version */ -fun getPluginVersion(): String { +fun getPluginVersion( + resourceName: String = TECH_DEBT_PROPERTIES, +): String { val props = Properties().apply { val classLoader = TechDebtPlugin::class.java.classLoader val resourceStream = - classLoader?.getResourceAsStream(TECH_DEBT_PROPERTIES) - ?: Thread.currentThread() - .contextClassLoader - ?.getResourceAsStream(TECH_DEBT_PROPERTIES) + classLoader?.getResourceAsStream(resourceName) + ?: Thread.currentThread().contextClassLoader?.getResourceAsStream(resourceName) if (resourceStream == null) { - // Fallback for cases where the resource might not be in the classpath during - // tests or specific environments. - Logger.getLogger(TechDebtPlugin::class.java) - .warn("techdebt.properties not found, " + "defaulting version to 1.0.0") - return "1.0.0" + error("Could not find $resourceName in the classpath") } resourceStream.use { stream -> load(stream) } } val version: String = - props[VERSION_PROPERTY] as? String ?: error("Version not found in techdebt.properties") + props[VERSION_PROPERTY] as? String ?: error("Version not found in $resourceName") if (version.isBlank()) { - error("Version cannot be blank in techdebt.properties") + error("Version cannot be blank in $resourceName") } return version } diff --git a/techdebt-gradle-plugin/src/test/kotlin/com/escodro/techdebt/gradle/extension/PropertiesExtensionsTest.kt b/techdebt-gradle-plugin/src/test/kotlin/com/escodro/techdebt/gradle/extension/PropertiesExtensionsTest.kt new file mode 100644 index 0000000..fbe4878 --- /dev/null +++ b/techdebt-gradle-plugin/src/test/kotlin/com/escodro/techdebt/gradle/extension/PropertiesExtensionsTest.kt @@ -0,0 +1,33 @@ +package com.escodro.techdebt.gradle.extension + +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Assertions.assertThrows +import org.junit.jupiter.api.Test + +class PropertiesExtensionsTest { + + @Test + fun `test getPluginVersion returns version from properties file`() { + val version = getPluginVersion() + assertEquals("0.4.0", version) + } + + @Test + fun `test getPluginVersion throws exception when file is missing`() { + assertThrows(IllegalStateException::class.java) { getPluginVersion("missing.properties") } + } + + @Test + fun `test getPluginVersion throws error when version is missing`() { + assertThrows(IllegalStateException::class.java) { + getPluginVersion("no_version.properties") + } + } + + @Test + fun `test getPluginVersion throws error when version is blank`() { + assertThrows(IllegalStateException::class.java) { + getPluginVersion("blank_version.properties") + } + } +} diff --git a/techdebt-gradle-plugin/src/test/resources/blank_version.properties b/techdebt-gradle-plugin/src/test/resources/blank_version.properties new file mode 100644 index 0000000..8ed6a8c --- /dev/null +++ b/techdebt-gradle-plugin/src/test/resources/blank_version.properties @@ -0,0 +1 @@ +version= diff --git a/techdebt-gradle-plugin/src/test/resources/no_version.properties b/techdebt-gradle-plugin/src/test/resources/no_version.properties new file mode 100644 index 0000000..76a30c3 --- /dev/null +++ b/techdebt-gradle-plugin/src/test/resources/no_version.properties @@ -0,0 +1 @@ +# No version here diff --git a/techdebt-gradle-plugin/src/test/resources/techdebt.properties b/techdebt-gradle-plugin/src/test/resources/techdebt.properties new file mode 100644 index 0000000..b31ef9a --- /dev/null +++ b/techdebt-gradle-plugin/src/test/resources/techdebt.properties @@ -0,0 +1 @@ +version=0.4.0 From 2259214ec5ffc582ea8eab34c1cbdb5913ef7fca Mon Sep 17 00:00:00 2001 From: Igor Escodro Date: Sun, 8 Feb 2026 18:23:53 -0500 Subject: [PATCH 3/9] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Simplify=20`getSourceS?= =?UTF-8?q?etName`=20return=20logic?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Removed redundant variable assignment in `getSourceSetName` method to streamline code and improve readability. --- .../escodro/techdebt/gradle/parser/GeneratedTechDebtParser.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/techdebt-gradle-plugin/src/main/kotlin/com/escodro/techdebt/gradle/parser/GeneratedTechDebtParser.kt b/techdebt-gradle-plugin/src/main/kotlin/com/escodro/techdebt/gradle/parser/GeneratedTechDebtParser.kt index 8c55970..77ce065 100644 --- a/techdebt-gradle-plugin/src/main/kotlin/com/escodro/techdebt/gradle/parser/GeneratedTechDebtParser.kt +++ b/techdebt-gradle-plugin/src/main/kotlin/com/escodro/techdebt/gradle/parser/GeneratedTechDebtParser.kt @@ -41,8 +41,7 @@ internal class GeneratedTechDebtParser { val parts = path.split("/") val kspIndex = parts.indexOf("ksp") if (kspIndex != -1 && kspIndex + 1 < parts.size) { - val sourceSetName = parts[kspIndex + 1] - return sourceSetName + return parts[kspIndex + 1] } return SOURCE_SET_UNKNOWN } From d9afc48a936ca501061d2ef8626fbebe9ffcddbb Mon Sep 17 00:00:00 2001 From: Igor Escodro Date: Sun, 8 Feb 2026 18:25:50 -0500 Subject: [PATCH 4/9] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Move=20`SourceFileReso?= =?UTF-8?q?lver`=20to=20`extension`=20package=20and=20update=20imports?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Relocated `SourceFileResolver` from `parser` to `extension` package for improved module organization and updated affected imports and tests accordingly. --- .../techdebt/gradle/{parser => extension}/SourceFileResolver.kt | 2 +- .../main/kotlin/com/escodro/techdebt/gradle/parser/GitParser.kt | 1 + .../gradle/{parser => extension}/SourceFileResolverTest.kt | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) rename techdebt-gradle-plugin/src/main/kotlin/com/escodro/techdebt/gradle/{parser => extension}/SourceFileResolver.kt (97%) rename techdebt-gradle-plugin/src/test/kotlin/com/escodro/techdebt/gradle/{parser => extension}/SourceFileResolverTest.kt (98%) diff --git a/techdebt-gradle-plugin/src/main/kotlin/com/escodro/techdebt/gradle/parser/SourceFileResolver.kt b/techdebt-gradle-plugin/src/main/kotlin/com/escodro/techdebt/gradle/extension/SourceFileResolver.kt similarity index 97% rename from techdebt-gradle-plugin/src/main/kotlin/com/escodro/techdebt/gradle/parser/SourceFileResolver.kt rename to techdebt-gradle-plugin/src/main/kotlin/com/escodro/techdebt/gradle/extension/SourceFileResolver.kt index 5281f4b..27eaa95 100644 --- a/techdebt-gradle-plugin/src/main/kotlin/com/escodro/techdebt/gradle/parser/SourceFileResolver.kt +++ b/techdebt-gradle-plugin/src/main/kotlin/com/escodro/techdebt/gradle/extension/SourceFileResolver.kt @@ -1,4 +1,4 @@ -package com.escodro.techdebt.gradle.parser +package com.escodro.techdebt.gradle.extension import java.io.File diff --git a/techdebt-gradle-plugin/src/main/kotlin/com/escodro/techdebt/gradle/parser/GitParser.kt b/techdebt-gradle-plugin/src/main/kotlin/com/escodro/techdebt/gradle/parser/GitParser.kt index 552cb91..cc6b69f 100644 --- a/techdebt-gradle-plugin/src/main/kotlin/com/escodro/techdebt/gradle/parser/GitParser.kt +++ b/techdebt-gradle-plugin/src/main/kotlin/com/escodro/techdebt/gradle/parser/GitParser.kt @@ -1,5 +1,6 @@ package com.escodro.techdebt.gradle.parser +import com.escodro.techdebt.gradle.extension.SourceFileResolver import com.escodro.techdebt.gradle.model.TechDebtItem import java.io.File import java.io.IOException diff --git a/techdebt-gradle-plugin/src/test/kotlin/com/escodro/techdebt/gradle/parser/SourceFileResolverTest.kt b/techdebt-gradle-plugin/src/test/kotlin/com/escodro/techdebt/gradle/extension/SourceFileResolverTest.kt similarity index 98% rename from techdebt-gradle-plugin/src/test/kotlin/com/escodro/techdebt/gradle/parser/SourceFileResolverTest.kt rename to techdebt-gradle-plugin/src/test/kotlin/com/escodro/techdebt/gradle/extension/SourceFileResolverTest.kt index 3b753f8..36e29b9 100644 --- a/techdebt-gradle-plugin/src/test/kotlin/com/escodro/techdebt/gradle/parser/SourceFileResolverTest.kt +++ b/techdebt-gradle-plugin/src/test/kotlin/com/escodro/techdebt/gradle/extension/SourceFileResolverTest.kt @@ -1,4 +1,4 @@ -package com.escodro.techdebt.gradle.parser +package com.escodro.techdebt.gradle.extension import java.io.File import org.junit.jupiter.api.Assertions.assertEquals From 3bc3797e84b2c7ed15d0945006e4b4377e2a7d68 Mon Sep 17 00:00:00 2001 From: Igor Escodro Date: Sun, 8 Feb 2026 18:27:12 -0500 Subject: [PATCH 5/9] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Move=20`TechDebtExtens?= =?UTF-8?q?ion`=20to=20`extension`=20package=20for=20better=20organization?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Relocated the `TechDebtExtension` class to the `extension` package to align with the module's logical structure. --- .../main/kotlin/com/escodro/techdebt/gradle/TechDebtPlugin.kt | 1 + .../com/escodro/techdebt/gradle/extension/ProjectExtensions.kt | 1 - .../techdebt/gradle/{ => extension}/TechDebtExtension.kt | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename techdebt-gradle-plugin/src/main/kotlin/com/escodro/techdebt/gradle/{ => extension}/TechDebtExtension.kt (95%) diff --git a/techdebt-gradle-plugin/src/main/kotlin/com/escodro/techdebt/gradle/TechDebtPlugin.kt b/techdebt-gradle-plugin/src/main/kotlin/com/escodro/techdebt/gradle/TechDebtPlugin.kt index fcf7ce1..d145bcc 100644 --- a/techdebt-gradle-plugin/src/main/kotlin/com/escodro/techdebt/gradle/TechDebtPlugin.kt +++ b/techdebt-gradle-plugin/src/main/kotlin/com/escodro/techdebt/gradle/TechDebtPlugin.kt @@ -1,5 +1,6 @@ package com.escodro.techdebt.gradle +import com.escodro.techdebt.gradle.extension.TechDebtExtension import com.escodro.techdebt.gradle.extension.configureAndroidPlugins import com.escodro.techdebt.gradle.extension.configureJvmPlugins import com.escodro.techdebt.gradle.extension.configureKmpPlugins diff --git a/techdebt-gradle-plugin/src/main/kotlin/com/escodro/techdebt/gradle/extension/ProjectExtensions.kt b/techdebt-gradle-plugin/src/main/kotlin/com/escodro/techdebt/gradle/extension/ProjectExtensions.kt index f1ea483..c00933d 100644 --- a/techdebt-gradle-plugin/src/main/kotlin/com/escodro/techdebt/gradle/extension/ProjectExtensions.kt +++ b/techdebt-gradle-plugin/src/main/kotlin/com/escodro/techdebt/gradle/extension/ProjectExtensions.kt @@ -1,7 +1,6 @@ package com.escodro.techdebt.gradle.extension import com.escodro.techdebt.gradle.GenerateTechDebtReportTask -import com.escodro.techdebt.gradle.TechDebtExtension import com.google.devtools.ksp.gradle.KspExtension import java.util.Locale.getDefault import org.gradle.api.Project diff --git a/techdebt-gradle-plugin/src/main/kotlin/com/escodro/techdebt/gradle/TechDebtExtension.kt b/techdebt-gradle-plugin/src/main/kotlin/com/escodro/techdebt/gradle/extension/TechDebtExtension.kt similarity index 95% rename from techdebt-gradle-plugin/src/main/kotlin/com/escodro/techdebt/gradle/TechDebtExtension.kt rename to techdebt-gradle-plugin/src/main/kotlin/com/escodro/techdebt/gradle/extension/TechDebtExtension.kt index f3fd7ae..0e6c041 100644 --- a/techdebt-gradle-plugin/src/main/kotlin/com/escodro/techdebt/gradle/TechDebtExtension.kt +++ b/techdebt-gradle-plugin/src/main/kotlin/com/escodro/techdebt/gradle/extension/TechDebtExtension.kt @@ -1,4 +1,4 @@ -package com.escodro.techdebt.gradle +package com.escodro.techdebt.gradle.extension import org.gradle.api.file.RegularFileProperty import org.gradle.api.provider.Property From 942c2e73ba06b2a4419517c5e04f90b6d5d02b6d Mon Sep 17 00:00:00 2001 From: Igor Escodro Date: Sun, 8 Feb 2026 18:31:47 -0500 Subject: [PATCH 6/9] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Simplify=20`getAnnotat?= =?UTF-8?q?ionLocation`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refactored `getAnnotationLocation` to streamline logic by inlining the `location` variable and removed the unused `getLocation` method to clean up the code. --- .../escodro/techdebt/extension/KSAnnotationExtensions.kt | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/techdebt-processor/src/main/kotlin/com/escodro/techdebt/extension/KSAnnotationExtensions.kt b/techdebt-processor/src/main/kotlin/com/escodro/techdebt/extension/KSAnnotationExtensions.kt index 985c702..1f915d1 100644 --- a/techdebt-processor/src/main/kotlin/com/escodro/techdebt/extension/KSAnnotationExtensions.kt +++ b/techdebt-processor/src/main/kotlin/com/escodro/techdebt/extension/KSAnnotationExtensions.kt @@ -5,7 +5,6 @@ import com.google.devtools.ksp.symbol.KSAnnotated import com.google.devtools.ksp.symbol.KSAnnotation import com.google.devtools.ksp.symbol.KSDeclaration import com.google.devtools.ksp.symbol.KSFile -import com.google.devtools.ksp.symbol.Location /** * Returns the name of the given symbol, which can be a declaration or a file. @@ -27,10 +26,8 @@ fun getSymbolName(symbol: KSAnnotated): String = * @param sourceSet the source set name * @return the source location */ -fun getAnnotationLocation(annotation: KSAnnotation, sourceSet: String): String = - getLocation(annotation.location, sourceSet) - -private fun getLocation(location: Location, sourceSet: String): String { +fun getAnnotationLocation(annotation: KSAnnotation, sourceSet: String): String { + val location = annotation.location val sourceLocation = if (location is FileLocation) { "${location.filePath}:${location.lineNumber}" From f3907e3fab9759710f84f9464194d56a16618d28 Mon Sep 17 00:00:00 2001 From: Igor Escodro Date: Sun, 8 Feb 2026 18:35:09 -0500 Subject: [PATCH 7/9] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Refactor=20`SuppressSy?= =?UTF-8?q?mbolProcessor`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaced duplicate occurrences of `Suppress::class.qualifiedName` with a companion object constant `SuppressName` for improved readability and maintainability. --- .../techdebt/processor/SuppressSymbolProcessor.kt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/techdebt-processor/src/main/kotlin/com/escodro/techdebt/processor/SuppressSymbolProcessor.kt b/techdebt-processor/src/main/kotlin/com/escodro/techdebt/processor/SuppressSymbolProcessor.kt index a2187ee..c0e1067 100644 --- a/techdebt-processor/src/main/kotlin/com/escodro/techdebt/processor/SuppressSymbolProcessor.kt +++ b/techdebt-processor/src/main/kotlin/com/escodro/techdebt/processor/SuppressSymbolProcessor.kt @@ -29,14 +29,14 @@ internal class SuppressSymbolProcessor { moduleName: String, sourceSet: String ) { - resolver.getSymbolsWithAnnotation(Suppress::class.qualifiedName!!).forEach { symbol -> + resolver.getSymbolsWithAnnotation(SuppressName).forEach { symbol -> if (!symbol.validate()) return@forEach val suppressAnnotations = symbol.annotations - .filter { - it.annotationType.resolve().declaration.qualifiedName?.asString() == - Suppress::class.qualifiedName + .filter { annotation -> + annotation.annotationType.resolve().declaration.qualifiedName?.asString() == + SuppressName } .toList() if (suppressAnnotations.isEmpty()) return@forEach @@ -76,4 +76,8 @@ internal class SuppressSymbolProcessor { } } } + + companion object { + private val SuppressName: String = Suppress::class.qualifiedName!! + } } From 83975e88a4724730c33d663e027e2211735355c2 Mon Sep 17 00:00:00 2001 From: Igor Escodro Date: Sun, 8 Feb 2026 18:36:30 -0500 Subject: [PATCH 8/9] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Refactor=20`TechDebtSy?= =?UTF-8?q?mbolProcessor`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaced inline `TechDebt::class.qualifiedName` with a companion object constant `TechDebtAnnotationName` for improved readability and maintainability. --- .../techdebt/processor/TechDebtSymbolProcessor.kt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/techdebt-processor/src/main/kotlin/com/escodro/techdebt/processor/TechDebtSymbolProcessor.kt b/techdebt-processor/src/main/kotlin/com/escodro/techdebt/processor/TechDebtSymbolProcessor.kt index 4b6474a..ef0ac92 100644 --- a/techdebt-processor/src/main/kotlin/com/escodro/techdebt/processor/TechDebtSymbolProcessor.kt +++ b/techdebt-processor/src/main/kotlin/com/escodro/techdebt/processor/TechDebtSymbolProcessor.kt @@ -35,16 +35,15 @@ internal class TechDebtSymbolProcessor { sourceSet: String, unableToProcess: MutableList ) { - resolver.getSymbolsWithAnnotation(TechDebt::class.qualifiedName!!).forEach { symbol -> + resolver.getSymbolsWithAnnotation(TechDebtAnnotationName).forEach { symbol -> if (!symbol.validate()) { unableToProcess.add(symbol) return@forEach } val annotation = - symbol.annotations.firstOrNull { - it.annotationType.resolve().declaration.qualifiedName?.asString() == - TechDebt::class.qualifiedName + symbol.annotations.firstOrNull { annotation -> + annotation.annotationType.resolve().declaration.qualifiedName?.asString() == TechDebtAnnotationName } ?: return@forEach val args = annotation.arguments.associate { it.name!!.asString() to it.value } @@ -75,4 +74,8 @@ internal class TechDebtSymbolProcessor { ) } } + + companion object { + private val TechDebtAnnotationName: String = TechDebt::class.qualifiedName!! + } } From 8c94cf1d8c334b6d2fae8146d9f4351dadd51d10 Mon Sep 17 00:00:00 2001 From: Igor Escodro Date: Sun, 8 Feb 2026 18:45:58 -0500 Subject: [PATCH 9/9] =?UTF-8?q?=F0=9F=90=8A=20Fix=20build=20and=20code=20r?= =?UTF-8?q?eview=20comments?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../escodro/techdebt/gradle/extension/ProjectExtensions.kt | 4 ++-- .../escodro/techdebt/gradle/extension/PropertiesExtensions.kt | 1 + .../techdebt/gradle/extension/PropertiesExtensionsTest.kt | 2 +- .../com/escodro/techdebt/processor/TechDebtSymbolProcessor.kt | 3 ++- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/techdebt-gradle-plugin/src/main/kotlin/com/escodro/techdebt/gradle/extension/ProjectExtensions.kt b/techdebt-gradle-plugin/src/main/kotlin/com/escodro/techdebt/gradle/extension/ProjectExtensions.kt index c00933d..2c9dd93 100644 --- a/techdebt-gradle-plugin/src/main/kotlin/com/escodro/techdebt/gradle/extension/ProjectExtensions.kt +++ b/techdebt-gradle-plugin/src/main/kotlin/com/escodro/techdebt/gradle/extension/ProjectExtensions.kt @@ -52,11 +52,11 @@ fun Project.configureKmpPlugins() { extensions.getByType(KotlinMultiplatformExtension::class.java).targets.all { target -> if (target.name == KMP_METADATA_TARGET) return@all - val target: String = + val targetName: String = target.name.replaceFirstChar { if (it.isLowerCase()) it.titlecase(getDefault()) else it.toString() } - val configurationName = "$KSP_PARAM$target" + val configurationName = "$KSP_PARAM$targetName" // Check if the configuration exists before adding the dependency if (configurations.findByName(configurationName) != null) { diff --git a/techdebt-gradle-plugin/src/main/kotlin/com/escodro/techdebt/gradle/extension/PropertiesExtensions.kt b/techdebt-gradle-plugin/src/main/kotlin/com/escodro/techdebt/gradle/extension/PropertiesExtensions.kt index 4135df1..a915d25 100644 --- a/techdebt-gradle-plugin/src/main/kotlin/com/escodro/techdebt/gradle/extension/PropertiesExtensions.kt +++ b/techdebt-gradle-plugin/src/main/kotlin/com/escodro/techdebt/gradle/extension/PropertiesExtensions.kt @@ -10,6 +10,7 @@ private const val VERSION_PROPERTY = "version" * Returns the current version of the plugin. The version is loaded from the `techdebt.properties` * file. * + * @param resourceName the resource name to load the version from. Defaults to `techdebt.properties` * @return the plugin version */ fun getPluginVersion( diff --git a/techdebt-gradle-plugin/src/test/kotlin/com/escodro/techdebt/gradle/extension/PropertiesExtensionsTest.kt b/techdebt-gradle-plugin/src/test/kotlin/com/escodro/techdebt/gradle/extension/PropertiesExtensionsTest.kt index fbe4878..cf05e07 100644 --- a/techdebt-gradle-plugin/src/test/kotlin/com/escodro/techdebt/gradle/extension/PropertiesExtensionsTest.kt +++ b/techdebt-gradle-plugin/src/test/kotlin/com/escodro/techdebt/gradle/extension/PropertiesExtensionsTest.kt @@ -8,7 +8,7 @@ class PropertiesExtensionsTest { @Test fun `test getPluginVersion returns version from properties file`() { - val version = getPluginVersion() + val version = getPluginVersion("techdebt.properties") assertEquals("0.4.0", version) } diff --git a/techdebt-processor/src/main/kotlin/com/escodro/techdebt/processor/TechDebtSymbolProcessor.kt b/techdebt-processor/src/main/kotlin/com/escodro/techdebt/processor/TechDebtSymbolProcessor.kt index ef0ac92..fe6c002 100644 --- a/techdebt-processor/src/main/kotlin/com/escodro/techdebt/processor/TechDebtSymbolProcessor.kt +++ b/techdebt-processor/src/main/kotlin/com/escodro/techdebt/processor/TechDebtSymbolProcessor.kt @@ -43,7 +43,8 @@ internal class TechDebtSymbolProcessor { val annotation = symbol.annotations.firstOrNull { annotation -> - annotation.annotationType.resolve().declaration.qualifiedName?.asString() == TechDebtAnnotationName + annotation.annotationType.resolve().declaration.qualifiedName?.asString() == + TechDebtAnnotationName } ?: return@forEach val args = annotation.arguments.associate { it.name!!.asString() to it.value }