Is it possible to replace all annotation processin...
# arrow-meta
j
Is it possible to replace all annotation processing done in kapt, with arrow-meta?
s
That is the end goal AFAIK, but not there yet
r
actually it´s already there…
Transform.newSources generates code in separate files before analisys without generating stubs
but it’s not tied up to annotations per se, you can intercept any shape including annotations
now if you are looking for TypeElement and other things kapt has from stubs, those are not obviously the same so a kapt processor in meta would need to be rewritten to use the meta apis or compiler apis
Transform.newSources was contributed by @bloder to meta to offer kapt like source generation support
arrow 2
t
Kapt can run Java annotation processors though, which arrow-meta will probably never do. So you will still need kapt for that.
m
Forgive my ignorance, but why would you want to handle annotation processing in arrow-meta vs kapt?
j
It would give you multi platform support for meta programming, which Kapt doesn’t provide.
👍 1
Thanks for the replies everyone. I now have a vector for next stage exploration.
r
Just to clarify meta won't try to replace kapt because as @tschuchort mentioned our API is focused in the Kotlin compiler which is far more rich and powerful that what you get through TypeElement and what kapt can do. If you are writing a new annotation processor from scratch you can use Transform.newSources to accomplish code generation based on annotations or any other psi element but we don't intend on supporting programs based on the kapt apis. You can intermix them in the same project though
👍 1
a
Is there some way to change path where Transform.newSources generates files? I can’t find any example for this.
r
@androidcactus You can control where output files go to by changing the following environment variable
Copy code
System.getProperty("arrow.meta.generated.source.output", "build/generated/source/kapt/main")
that is the default value we place generated sources by default, but you can’t change it wherever your plugin inits
Here is a place where we override it in our test
a
@raulraja I just modified helloWorld plugin to use Transform.newSources and all files are generated to ~/Library/Application Support/kotlin/daemon/*build/generated/source/kapt/main* Even when I change environment variable that path just appends to ~/Library/Application Support/kotlin/daemon/ Not sure if this is intended behaviour or just missing something. I would expect those files to be generated in build folder within my project (same as kapt generators work) and not in global ~/Library path.
r
not sure what is going on. Can you create an issue and tag @Rachel and @bloder
👍 2
r
🙌 and please, it would be great if you include a repository where it can be reviewed. Thanks!
a