Skip to content

Instantly share code, notes, and snippets.

@Morfly
Last active April 16, 2022 05:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Morfly/ebf3df3aa874af6c93faac968e7e6a7d to your computer and use it in GitHub Desktop.
Save Morfly/ebf3df3aa874af6c93faac968e7e6a7d to your computer and use it in GitHub Desktop.
KSP function processor, process function, file
class FunctionProcessor(...) : SymbolProcessor {
override fun process(resolver: Resolver): List<KSAnnotated> {
...
val file: OutputStream = codeGenerator.createNewFile(
// Make sure to associate the generated file with sources to keep/maintain it across incremental builds.
// Learn more about incremental processing in KSP from the official docs:
// https://kotlinlang.org/docs/ksp-incremental.html
dependencies = Dependencies(false, *resolver.getAllFiles().toList().toTypedArray()),
packageName = "com.morfly",
fileName = "GeneratedFunctions"
)
file += "package com.morfly\n"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment