Zoltán Kollár Zoltán Kollár - 6 months ago 73
Scala Question

Debug Scala compiler plugin in IntelliJ IDEA

I would like to write my compiler plugin for scalac, but I get a problem in early state in development because I cannot run and debug my code from IntelliJ IDEA.

I use these tutorials for implementing a dummy plugin:

My goal is to run my plugin somehow in debug mode in IDEA to encounter breakpoints.


The answer below helped me a lot but actually, I added arguments for debugging for JAVA_OPTS environment variable with suspending until remote debugger connection option. Then I started scalac and run remote debugger described below.


To debug a java process in IntelliJ IDEA you need to create a Remote run configuration first.

Remote run configuration

Specify an available port number. If you select Listen debugger mode your java process will be suspended on the start until you connect to it with the debugger.

Remote run configuration 2

Run your process with additional command line arguments and start this remote configuration in the debug mode.

If you run scala compiler from IDEA, these command line arguments should be added to Scala Compile Server:

Scala Compile Server