how do you debug java annotation processors using intellij?

后端 未结 8 955
春和景丽
春和景丽 2020-12-07 13:47

How do you debug java annotation processors using intellij?

Preferably using IDEA IntelliJ. I tried setting a breakpoint inside the processor and running but it did

8条回答
  •  死守一世寂寞
    2020-12-07 14:29

    Debugging an annotation processor with IntelliJ IDEA and Gradle

    1. Set a custom VM option -Dcompiler.process.debug.port=5005: press Ctrl + Shift + A and select Edit Custom VM Options... in the list of actions to add a custom VM option then restart the IDE.
    2. Create a remote debug configuration with default parameters: Run -> Edit Configurations... -> Add New Configuration (Alt + Insert) -> Remote.
    3. Set breakpoints.
    4. Build with Gradle from the terminal: $ ./gradlew --no-daemon -Dorg.gradle.debug=true clean build (it's okay if the execution of the command is frozen, don't terminate a process).
    5. Debug the remote debug configuration within the IDE (see step 3): select a suitable remote debug configuration and press Shift + F9.

    Hope it helps somebody :)

提交回复
热议问题