I'm building an annotation processor, and I recently switched from using the default annotationProcessor type to kapt, using the kotlin-kapt plugin.
I was debugging my processor by using the command
./gradlew --no-daemon -Dorg.gradle.debug=true :app:clean :app:compileDebugJavaWithJavac
(full instructions here: https://stackoverflow.com/a/42488641/502463 )
And then running a Remote debugging configuration. When I used annotationProcessor, I could hit breakpoints, and debug fine. with kapt, my processor runs, but I can't debug it. No breakpoints are triggered.
My kotlin version is 1.1.2-3
Kapt is the Kotlin Annotation Processing Tool, and it's in pretty good shape these days. If you want to be able to reference generated code from Kotlin, you need to use kapt. To do that, simply include the plugin in your build.gradle file with the line: apply plugin: 'kotlin-kapt'
Is kapt deprecated? app: Original kapt is deprecated. Please add "apply plugin: 'kotlin-kapt'" to your build. gradle.
Annotation processing is a Java compilation option which has been around since Java 5. It enables the generation of additional files during compilation, such as classes or documentation.
You actually want to debug the Kotlin compiler daemon, not the Gradle daemon. Here is how you can pass the required JVM arguments:
./gradlew <tasks> -Dkotlin.daemon.jvm.options="-Xdebug,-Xrunjdwp:transport=dt_socket\,address=5005\,server=y\,suspend=n"
I just tried to debug a Kotlin annotation processor and found this post. You can tell the JVM to wait for the debugger by passing suspend=y
What I do now is starting the build from command line:
./gradlew --no-daemon clean build -Dkotlin.daemon.jvm.options="-Xdebug,-Xrunjdwp:transport=dt_socket\,address=5005\,server=y\,suspend=y"
and then attaching with Intellij via remote configuration.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With