MAVEN_OPTS
Thursday, 26 December 2013, 14:31
Tags: Maven
The MAVEN_OPTS environment variable can be used to set options that will be used every time the mvn command is executed. To understand how these MAVEN_OPTS are used you can take a look at the mvn.bat file in the bin directory of your maven installation. Maven is written in Java and is executed as shown in the next code snippet, which is an extract from mvn.bat.
Here you can see that the MAVEN_OPTS are passed to java.exe every time the mvn command is executed. Thus if there are environment variables you have to set each time maven is executed you can add them to MAVEN_OPTS instead of manually inserting them repeatedly when executing maven.
Next follow two code snippets that are functionally equivalent. The difference is that in the last snippet you only have to set the environment variable once via MAVEN_OPTS.