how do you debug java annotation processors using intellij?

后端 未结 8 940
春和景丽
春和景丽 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:25

    For a Maven project, this post, which explains the following steps in a little more detail, worked for me:

    1. Add "Remote" run configuration and set "port" to 8000.

    2. Issue the command mvnDebug clean install from the project's directory (on the command line).

    3. Run the run configuration. In order to start a new session after the processes quit, repeat from (2).

    Remember to run mvn install on the project's dependencies when they change (e.g. if the annotation processor is in a different artifact than the project you are debugging it from).

    0 讨论(0)
  • 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 :)

    0 讨论(0)
提交回复
热议问题