Logo Questions Linux Laravel Mysql Ubuntu Git Menu

Compile scala classes with debug info through Maven

I have a scala project that I use Maven and the maven-scala-plugin to compile. I need to include debug information in the compiled classes and I was wondering is there a way to ask Maven or the scala plugin to do this. I found this page that makes it sound possible but it's not clear where to put the params in the pom.xml.

If possible I'd like this option to be something specified in the pom.xml rather than on the command line.

like image 310
David Avatar asked Dec 29 '22 08:12


1 Answers

Compiling .class files with debugging information needs to be done at the maven-scala-plugin level. Doing it at the maven-compiler-plugin - which is by the way the default as we can see in the documentation of the debug option that defaults to true - is useless as it's not compiling your Scala sources.

Now, if we look at the scalac man page, the scalac compiler has a –g option that can take the following values:

"none" generates no debugging info,
"source" generates only the source file attribute,
"line" generates source and line number information,
"vars" generates source, line number and local variable information,
"notc" generates all of the above and will not perform tail call optimization.

The good news is that scala:compile has a nice args optional parameter that can be used to pass compiler additionnals arguments. So, to use it and pass the -g option to the scala compiler, you just need to configure the maven plugin as follow:


I'm skipping other parts of the configuration (such are repositories, pluginRepositories, etc) as this is not what you're asking for :)

like image 194
Pascal Thivent Avatar answered Jan 05 '23 05:01

Pascal Thivent