Question

I must increase java heap space to compile my project. The only way I found is modify mvn.bat and set:

set MAVEN_OPTS=-XX:PermSize=256m -XX:MaxPermSize=256m -Xms1300M -Xmx1300M

than all colleagues must change the file localy. I want keep all inside my project, not localy. Can I insert in the POM.xml or other file?

Was it helpful?

Solution

Setting MAVEN_OPTS usually provides arguments to the JVM running the build, and these are passed down to the compiler because it runs inline. You have probably already noted that the maven-surefire-plugin used for test usually fork a separate process so passing options to the plugin is bound inside the pom.xml.

What if you fork the compilation process also and add the flags there, such as the below example.

Notice the fork and the compiler args

<project>
  [...]
  <build>
    [...]
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version>
        <configuration>
          <fork>true</fork>
          <meminitial>128m</meminitial>
          <maxmem>512m</maxmem>
          <compilerArgument>-verbose -bootclasspath ${java.home}\lib\rt.jar</compilerArgument>
        </configuration>
      </plugin>
    </plugins>
    [...]
  </build>
  [...]
</project>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top