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?
MAVEN_OPTS environment variable:This variable contains parameters used to start up the JVM running Maven and can be used to supply additional options to it. E.g. JVM memory settings could be defined with the value -Xms256m -Xmx512m .
MAVEN_OPTS is an environment variable used by the shell scripts that launch the Java Virtual Machine (JVM) that runs Maven. Using MAVEN_OPTS you can pass options to the JVM when it's launched.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With