Skip to content

Commit

Permalink
introduce processorName option for KSP.
Browse files Browse the repository at this point in the history
This option will allow users to specify certain processors(s) to be
executed, if not specified, all processors found in apclasspath will be
executed.
  • Loading branch information
neetopia committed Aug 10, 2022
1 parent 54b1d48 commit baab3d6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Expand Up @@ -189,6 +189,13 @@ enum class KspCliOption(
false
),

PROCESSOR_NAME_OPTION(
"processorNames",
"<processorNames>",
"only executes following processor(s)",
false
),

KNOWN_MODIFIED_OPTION(
"knownModified",
"<knownModified>",
Expand Down Expand Up @@ -259,6 +266,7 @@ fun KspOptions.Builder.processOption(option: KspCliOption, value: String) = when
KspCliOption.PROCESSOR_CLASSPATH_OPTION -> processingClasspath += value.split(File.pathSeparator).map {
File(it)
}
KspCliOption.PROCESSOR_NAME_OPTION -> processors += value.split(File.pathSeparator)
KspCliOption.CLASS_OUTPUT_DIR_OPTION -> classOutputDir = File(value)
KspCliOption.JAVA_OUTPUT_DIR_OPTION -> javaOutputDir = File(value)
KspCliOption.KOTLIN_OUTPUT_DIR_OPTION -> kotlinOutputDir = File(value)
Expand Down
Expand Up @@ -74,7 +74,9 @@ class KotlinSymbolProcessingExtension(
val classLoader =
URLClassLoader(processingClasspath.map { it.toURI().toURL() }.toTypedArray(), javaClass.classLoader)

ServiceLoaderLite.loadImplementations(SymbolProcessorProvider::class.java, classLoader)
ServiceLoaderLite.loadImplementations(SymbolProcessorProvider::class.java, classLoader).filter {
options.processors.isEmpty() || it.javaClass.name in options.processors
}
}
if (providers.isEmpty()) {
logger.error("No providers found in processor classpath.")
Expand Down

0 comments on commit baab3d6

Please sign in to comment.