https://kotlinlang.org logo
#kapt
Title
# kapt
s

Stephan Schroeder

04/26/2021, 11:36 AM
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

tddmonkey

04/26/2021, 12:47 PM
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

TwoClocks

04/26/2021, 4:03 PM
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

Stephan Schroeder

04/27/2021, 3:54 PM
@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

tddmonkey

04/27/2021, 4:07 PM
ah! I open sourced one a while back - https://github.com/Masabi/kotlinbuilder
that might be more useful
s

Stephan Schroeder

04/27/2021, 4:33 PM
I'll take a look 🙂
t

TwoClocks

04/27/2021, 7:37 PM
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.
3 Views