has someone a good tip for a kapt tutorial for serverside annotation processing? (Android is not inv...
s
has someone a good tip for a kapt tutorial for serverside annotation processing? (Android is not involved in any way. The task is to generate a documentation file containing which classes contain certain annotations. Since it's Kotlin files we're talking about, I guess that kapt is the right tool for the job!?)
t
Setting up an annotation processor isnโ€™t too hard and there should be plenty of tutorials on that. The android specific stuff is generally around packaging. Writing an actual annotation processor requires something a lot deeper and the best thing Iโ€™ve found to do is to look at existing open source projects, experiment a lot and prepare to be frustrated
โ˜๏ธ 1
t
here is the one I followed when I setup my server side annotation processor. It's got some android stuff in it, but you can just ignore it.
s
@tddmonkey I literally only have to write the name of the class and annotated methods together with the content of a specific annotation into a file. This must be the easiest use-case possible, so I hope to avoid the "being frustrated" part.
It's less tutorials than you think, it's basically only android specific tutorials from 2017/18. (the one from Jonross is new, though ๐Ÿ™‚ ) The problem/inconvinience(๐Ÿ˜…) is that I don't know Android at all, which means it's hard for me to identify/remove the android specific part. Well, nobody said it'd be easy ๐Ÿ˜‚
t
ah! I open sourced one a while back - https://github.com/Masabi/kotlinbuilder
that might be more useful
s
I'll take a look ๐Ÿ™‚
t
I found it was more gradle work than kotlin code. for the kotlin stuff I just implemented
javax.annotation.processing.AbstractProcessor
The gradle work is kinda a dark art (to me anyway). Marking sure it's in a different project (or sub-project). Making sure the right thing in the the META file, etc.