As of today, my maven compile fails.
[INFO] [ERROR] Unexpected
[INFO] java.lang.OutOfMemoryError: Java heap space
[INFO] at java.util.Arrays.copyOfRange(Arr
Answering late to mention yet another option rather than the common MAVEN_OPTS environment variable to pass to the Maven build the required JVM options.
Since Maven 3.3.1, you could have an .mvn
folder as part of the concerned project and a jvm.config
file as perfect place for such an option.
two new optional configuration files
.mvn/jvm.config
and.mvn/maven.config
, located at the base directory of project source tree. If present, these files will provide default jvm and maven options. Because these files are part of the project source tree, they will be present in all project checkouts and will be automatically used every time the project is build.
As part of the official release notes
In Maven it is not simple to define JVM configuration on a per project base. The existing mechanism based on an environment variable
MAVEN_OPTS
and the usage of${user.home}/.mavenrc
is an other option with the drawback of not being part of the project.Starting with this release you can define JVM configuration via
${maven.projectBasedir}/.mvn/jvm.config
file which means you can define the options for your build on a per project base. This file will become part of your project and will be checked in along with your project. So no need anymore forMAVEN_OPTS
,.mavenrc
files. So for example if you put the following JVM options into the${maven.projectBasedir}/.mvn/jvm.config
file:-Xmx2048m -Xms1024m -XX:MaxPermSize=512m -Djava.awt.headless=true
The main advantage of this approach is that the configuration is isolated to the concerned project and applied to the whole build as well, and less fragile than MAVEN_OPTS
for other developers working on the same project (forgetting to setting it).
Moreover, the options will be applied to all modules in case of a multi-module project.