English 中文(简体)
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.

最佳回答

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:

  <plugin>
    <groupId>org.scala-tools</groupId>
    <artifactId>maven-scala-plugin</artifactId>
    <version>2.9.1</version>
    <executions>
      <execution>
        <goals>
          <goal>compile</goal>
          <goal>testCompile</goal>
        </goals>
      </execution>
    </executions>
    <configuration>
      <args>
        <arg>-g:notc</arg>
      </args>
      ...
    </configuration>
  </plugin>

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

问题回答

暂无回答




相关问题
Derby gets stuck closing?

I ve got unit tests (in maven) that use derby. At the end of the test run, there is a very long pause, with these log messages before the pause. INFO: Closing Hibernate SessionFactory Nov 16, 2009 8:...

Execute goal on parent after children complete

I have a multi-module maven project (several levels of nesting). Normally, when I execute a maven build (like mvn install or whatever), maven will run all the goals for the parent project before ...

Including dependencies in a jar with Maven

Is there a way to force maven(2.0.9) to include all the dependencies in a single jar file? I have a project the builds into a single jar file. I want the classes from dependencies to be copied into ...

Java Equivalent of distcc

Distcc makes it easy to distribute a C or C++ compile job across a number of machines, and is a godsend for working with large, frequently-built codebases. An increasing number of our large projects ...

Maven Assembly Problem

I have a maven multiple-module project, which is giving me headaches in the assembly:assembly phase. I have a module which has an assembly defined in it which works fine when I invoke mvn assembly:...

热门标签