How to configure Maven tests with more Java heap space?
Environment
- maven-surefire-plugin, all versions
- Maven, all versions
Issue
How to configure Maven test runs with more Java heap space?
Can an individual Java heap space be configured for Maven the tests?
Resolution
An individual Java heap space can be configured for any Maven tests by configuring the maven-surefire-plugin as follows:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<argLine>-Xmx512m</argLine>
</configuration>
</plugin>
Notice the JVMs maximum heap size configuration. Other JVM properties can be passed in as well using the
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
3 Comments
fact:
All Supported Operating Systems
fact:
Maven
note:
The Maven shell environment variable MAVEN_OPTS which can be used to configure the Java heap for Maven itself is not used when creating a JVM to run the Maven tests. So whatever JVM arguments are in MAVEN_OPTS, these will not be passed on to the JVM running the tests itself!
Also see the Maven Surefire Plugin [documentation](http://maven.apache.org/plugins/maven-surefire-plugin/index.html).