From 11a90ab03a014e324e991cab6745a83255581d73 Mon Sep 17 00:00:00 2001 From: rootkiller6788 Date: Thu, 3 Sep 2026 22:10:38 +0800 Subject: [PATCH 1/2] Fix binary name computation for default-package classes in the KSP processor The KSP processor built binary names by assuming the qualified name always starts with '.'. For a class in the default package the package is empty, so the length+1 offset skipped the first character of the class name and the generated service file ended up with a leading dot and a truncated name ('.oo' instead of 'Foo'). The APT processor already handles this by returning the plain (nested) class name for the unnamed package; mirror that here. --- .../google/auto/service/processor/AutoServiceKspProcessor.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/service/processor_ksp/src/main/kotlin/com/google/auto/service/processor/AutoServiceKspProcessor.kt b/service/processor_ksp/src/main/kotlin/com/google/auto/service/processor/AutoServiceKspProcessor.kt index aca436d2cd..7547d4ce93 100644 --- a/service/processor_ksp/src/main/kotlin/com/google/auto/service/processor/AutoServiceKspProcessor.kt +++ b/service/processor_ksp/src/main/kotlin/com/google/auto/service/processor/AutoServiceKspProcessor.kt @@ -246,6 +246,9 @@ class AutoServiceKspProcessor(val environment: SymbolProcessorEnvironment) : Sym } private fun KSClassDeclaration.getBinaryName(qualifiedName: String): String { + if (packageName.asString().isEmpty()) { + return qualifiedName.replace('.', '$') + } val packageSeparatorIndex = packageName.asString().length + 1 // plus the '.' val nameAfterPackage = qualifiedName.substring(packageSeparatorIndex) return "${packageName.asString()}.${nameAfterPackage.replace('.', '$')}" From cf6ade9e380f40a1e298b96dac4812f83ff56181 Mon Sep 17 00:00:00 2001 From: rootkiller6788 Date: Thu, 3 Sep 2026 22:10:47 +0800 Subject: [PATCH 2/2] Mark generated service files as aggregating KSP outputs Each META-INF/services/ file is built from every @AutoService provider of that interface in the module, not just from the sources listed on the call. With aggregating=false KSP won't regenerate the file when a new provider source is added to an incremental build, so the new provider is missing from the output. This matches how the generated resource files are also aggregated for KAPT. --- .../google/auto/service/processor/AutoServiceKspProcessor.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/service/processor_ksp/src/main/kotlin/com/google/auto/service/processor/AutoServiceKspProcessor.kt b/service/processor_ksp/src/main/kotlin/com/google/auto/service/processor/AutoServiceKspProcessor.kt index 7547d4ce93..27d82d92d1 100644 --- a/service/processor_ksp/src/main/kotlin/com/google/auto/service/processor/AutoServiceKspProcessor.kt +++ b/service/processor_ksp/src/main/kotlin/com/google/auto/service/processor/AutoServiceKspProcessor.kt @@ -191,7 +191,7 @@ class AutoServiceKspProcessor(val environment: SymbolProcessorEnvironment) : Sym val lines = impls.map { it.binaryName } generator .createNewFileByPath( - dependencies = Dependencies(aggregating = false, sources = sourceFiles), + dependencies = Dependencies(aggregating = true, sources = sourceFiles), path = filePath, extensionName = "", )