views:

504

answers:

1

Is there any way to force Maven 2 (>2.0.10) to print the actual javac commands it's executing. We keep running out of memory even though we've bumped up the max using MAVEN_OPTS. I'd like to be able to see the actual command being executed that is running out of memory.

I've tried using the verbose setting below in the pom file's plugin management section but that doesn't seem to give me the javac command:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
        <source>1.5</source>
        <target>1.5</target>
        <maxmem>1024m</maxmem>
        <compilerArguments>
            <verbose/>
        </compilerArguments>
    </configuration>
</plugin>
+3  A: 

Have you tried running Maven with the -X command to print debugging information?

$ mvn -?
...
 -X,--debug      Produce execution debug output

The maven-javac-plugin should then print out the classpath being used, the source directories/path, etc.

matt b
Hmm. That doesn't give me the javac command but it does show me that the maxmem being passed to the command isn't paying attention to what's set in MAVEN_OPTS.. It's also not paying attention to maxmem set in the compiler plugin config section of the pom file either.
Chris Williams
I think you want to use `M2_OPTS`
matt b
The correct envvar is MAVEN_OPTS for example MAVEN_OPTS=-Xmx1024m.The maxmem configuration in the pom only applies to when you set the compiler plugin to fork the javac into a new jdk. Otherwise the plugin runs inside the same Jdk as Maven and thus within the memory passed on the cli via the MAVEN_OPTS.
Brian Fox
@Brian Fox, using MAVEN_OPTS with a ridiculously high value still wasn't working. I ended up having to set the compiler plugin to fork as you mentioned above. From my limited testing of the situation, something appears to be using up most of Maven's memory footprint so that when it tries to compile (unforked) it fails. We'll have to do more research on our side to figure out what part of the build process is hogging so much memory..
Chris Williams
You could try to enable the JVM parameter for "HeapDumpOnOutOfMemoryError" (http://java.sun.com/javase/6/webnotes/trouble/TSG-VM/html/clopts.html) and then run the heap dump through any of the analyzer tools (I like Eclipse Memory Analyzer for this)
matt b