From 80a80aa61c01a2c8a1e84fccd9a3ead307be8b7f Mon Sep 17 00:00:00 2001 From: Wojtek Zieba Date: Tue, 20 Feb 2024 19:38:11 +0100 Subject: [PATCH] feat: specify correct `originatingFiles` to optimize ksp output invalidation --- .../processor/RemoteConfigProcessor.kt | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/libs/processors/src/main/java/org/wordpress/android/processor/RemoteConfigProcessor.kt b/libs/processors/src/main/java/org/wordpress/android/processor/RemoteConfigProcessor.kt index 3a325a1b6b3e..cbc88987ce91 100644 --- a/libs/processors/src/main/java/org/wordpress/android/processor/RemoteConfigProcessor.kt +++ b/libs/processors/src/main/java/org/wordpress/android/processor/RemoteConfigProcessor.kt @@ -4,6 +4,7 @@ package org.wordpress.android.processor import com.google.devtools.ksp.KspExperimental +import com.google.devtools.ksp.containingFile import com.google.devtools.ksp.getAnnotationsByType import com.google.devtools.ksp.processing.CodeGenerator import com.google.devtools.ksp.processing.Resolver @@ -65,40 +66,45 @@ class RemoteConfigProcessor( .writeTo( codeGenerator, aggregating = true, + originatingKSFiles = remoteFeatures.map { it.containingFile!! } ) } private fun generateRemoteFieldsConfigDefaults(resolver: Resolver) { - val remoteFieldDefaults = + val remoteFields = resolver.getSymbolsWithAnnotation("org.wordpress.android.annotation.RemoteFieldDefaultGenerater") .toList() - .associate { element: KSAnnotated -> - element.getAnnotationsByType(RemoteFieldDefaultGenerater::class) - .toList() - .first() - .let { annotation -> - annotation.remoteField to annotation.defaultValue - } - } + val remoteFieldDefaults = remoteFields + .associate { element: KSAnnotated -> + element.getAnnotationsByType(RemoteFieldDefaultGenerater::class) + .toList() + .first() + .let { annotation -> + annotation.remoteField to annotation.defaultValue + } + } RemoteFieldConfigDefaultsBuilder(remoteFieldDefaults).getContent() .writeTo( codeGenerator, aggregating = true, + originatingKSFiles = remoteFields.map { it.containingFile!! } ) } private fun generateFeaturesInDevelopment(resolver: Resolver) { - val featuresInDevelopmentDefaults = + val featuresInDevelopment = resolver.getSymbolsWithAnnotation("org.wordpress.android.annotation.FeatureInDevelopment") .filterIsInstance() .toList() - .map { it.simpleName.asString() } + val featuresInDevelopmentDefaults = featuresInDevelopment + .map { it.simpleName.asString() } FeaturesInDevelopmentDefaultsBuilder(featuresInDevelopmentDefaults).getContent() .writeTo( codeGenerator, aggregating = true, + originatingKSFiles = featuresInDevelopment.map { it.containingFile!! } ) } @@ -108,6 +114,7 @@ class RemoteConfigProcessor( ).getContent().writeTo( codeGenerator, aggregating = true, + originatingKSFiles = remoteFeatures.map { it.containingFile!! } ) } }