Open oooplz opened 3 years ago
There is no such function currently. We'll evaluate and provide a solution.
There is no such function currently. We'll evaluate and provide a solution.
Thanks you very much for replying. The issue should be closed?
Can we keep this open to track the task?
Any updates here? It hasn't been touched for quite a while.
Any update? SPI really needs this support.
Any update?
curious to hear from someone familiar with the project... is this more of a technical blocker than it seems? it doesn't seem like a big ask, but seeing as this issue is 3 years old, wondering if there is a technical limitation here.
Any news here?
I try with the code, and it work.
class XSpiProcessor(private val env: SymbolProcessorEnvironment, private val fileName: String) :
SymbolProcessor {
override fun process(resolver: Resolver): List<KSAnnotated> {
val symbols = resolver.getSymbolsWithAnnotation(StartupNode::class.qualifiedName!!)
val providers = symbols.filterIsInstance<KSClassDeclaration>().map { symbol ->
symbol.qualifiedName?.asString().orEmpty()
}.toList()
generateConfigFiles(providers)
return emptyList()
}
private fun generateConfigFiles(list: List<String>) {
if (list.isEmpty()) {
return
}
val resourceStream = env.codeGenerator.createNewFile(
Dependencies.ALL_FILES,
"META-INF/services",
fileName,
""
)
resourceStream.bufferedWriter().use { writer ->
list.forEach { providerImplementer ->
writer.write(providerImplementer)
writer.newLine()
}
}
}
}
Using the Java annotation processing API. We can be using
javax.annotation.processing.Filer.getResource
method reading files.Can
SymbolProcessor API
does the same work?I searched the code playground, but not found read resource file API.
And can you provide a code example of read resource file API?