5

How to debug KSP using Idea and Gradle?

Running build task from IDE in debug mode does not attach IDE to the process.

Is there any command-line way to make the processor wait until IDE attach to thte process?

(I'm using KSP 1.5.31-1.0.0)

Max Farsikov
  • 2,451
  • 19
  • 25

1 Answers1

6

./gradlew :sample:build --no-daemon -Dorg.gradle.debug=true -Dkotlin.compiler.execution.strategy=in-process

If debugging without daemon is too slow (it has to start jvm everytime), ./gradlew -Dkotlin.daemon.jvm.options="-Xdebug,-Xrunjdwp:transport=dt_socket\,address=8765\,server=y\,suspend=n" ... and attach to the KotlinCompileDaemon process in the debugger.

More info here: https://github.com/google/ksp/issues/31

Kikiwa
  • 1,213
  • 2
  • 13
  • 20
  • Thank you for the response. I saw that conversation and none of those commands work for me. The first one just hangs, the second does not wait for a debugger to attach. – Max Farsikov Nov 04 '21 at 10:51
  • 2
    I also uses unit test from Idea with a breakpoint and the 2 options in Idea related to gradle debug and compiler in process. – Kikiwa Nov 06 '21 at 20:10