Question

Long story short, I have a maven project which runs fine if I use:

export MAVEN_OPTS=-Xmx1024m

but without it I get:

[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ project ---

...

An annotation processor threw an uncaught exception.
Consult the following stack trace for details.
java.lang.OutOfMemoryError: Java heap space

Now I would like to move that configuration to the pom file. I have tried two possibilities:

<plugin>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.1</version>
    <configuration>
        <meminitial>512m</meminitial>
        <maxmem>2048m</maxmem>
        <source>1.6</source>
        <target>1.6</target>
    </configuration>
</plugin>

...

<plugin>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.1</version>
    <configuration>
        <argLine>-Xmx1024m</argLine>
        <source>1.6</source>
        <target>1.6</target>
    </configuration>
</plugin>

None of this worked.

Is there another way of handling the -Xmx parameter from the pom file?

Was it helpful?

Solution

You must use <fork>true</fork> in your configuration as you cannot influence the memory settings in the process you are currently running in.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top