Hi there, I’ve been using kapt for a few weeks n...
# kapt
m
Hi there, I’ve been using kapt for a few weeks now and even though I managed to finish what I wanted, I still want to ask a kapt-gradle related question to fill in some gaps I have. Basically, when I’m working with an annotation processor and gradle (3.0), and I make some changes in the annotation processor’s code, the changes are sometimes applied and sometimes aren’t. When they aren’t, I search for all gradle processes (daemons) and kill them; rebuild the project and everything works again. Does anyone know why do I have to do this?
y
Looks like a bug in kapt+incremental compilation. Do you have any reproducible sample? Or at least some cases in mind when kapt is not re-launched after changes in annotation processor?
m
Here I am! Although I thought it happens more often its probably only related to loading resources and changing resource files.
I created a simple processor that loads a resource file, reads its content and writes it in the console
If you run
./gradlew clean assembleDebug
you’ll get the content of the
test.txt
file
change the content, rerun the command and you’ll get the old content
restart the gradle daemon and rerun, everything should be ok
side-note: To get the output in the console I had to use
Diagnostic.Kind.MANDATORY_WARNING
, if I use
Diagnostic.Kind.NOTE
nothing is printed. It doesn’t look like intended behavior.
Also, I don’t think is related but, when I create a new android project the auto-generated gradle file has
Copy code
task clean(type: Delete) {
    delete rootProject.buildDir
}
This causes an error:
Copy code
Error:(26, 0) Declaring custom 'clean' task when using the standard Gradle lifecycle plugins is not allowed.
<a href="openFile:/Users/markotron/Documents/experiments/KaptSampleProject/build.gradle">Open File</a>
I commented out this clean tasks. And even tried to manually delete the
rootProject.buildDir
before running
./gradlew clean assembleDebug
y
Ok! One note: if you see something like this in the future, please do not hesitate to file new issues :) The link is kotl.in/issue. Slack comments will disappear in a month, but the issue will stay forever.
It would be also very nice if you could post this as a new issue.
The latter problem (issue with “clean”) is not connected with kapt or Kotlin, it looks like that it’s about Android Studio integration
m
Yup, I just started with annotation processing, and it seemed more likely that I was doing something wrong… I’ll post it as an issue right now.
y
Thanks!