How can I attach a debugger to the javac process (for debugging annotation processor)

(Sam Sieber) #1

I’m working on an annotation processor. Both the annotation processor and the code I use it on are in the same gradle project (but different modules). I’d like to attach a debugger as part of implementing the annotation processor is a little exploratory at this point.

The project structure is basically:

core // the shared annotations
example // the exploratory project
plugin // the annotation processor

I do have everything wired up for the annotation processor to kick in (yay System.out.println statements), and properly, since gradle doesn't complain (I'm on 4.8).  I just haven't figured out a way to attach a debugger to the javac code so I can poke around the inputs to the plugin.

I've tried using the following under the compileJava block in the project using the annotation processor:

compileJava {
    options.compilerArgs << "-Xdebug"
    options.compilerArgs << "-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=7999"
compileJava {
    options.compilerArgs << "-J-Xdebug"
    options.compilerArgs << "-J-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000"

And both of them throw an error of > invalid flag:, and then the first flag used in each each attempt.

Any ideas on how I can do this?