0

I would like to modify some Java options when Maven is run. Where does Maven store these options?

Answer:

In my case, it was stored in the environment variable $MAVEN_OPTS:

export MAVEN_OPTS='-Xmx1g -XX:MaxPermSize=256m -Duser.language=en -Duser.country=us'

Options can also be set in POM files:

<argLine>-Xmx512M -XX:MaxPermSize=256M</argLine>

(dupe note)This question is close, but not a duplicate of the referenced question. I'm interested in an exact enumeration of places where the configuration options can be stored. Fixing a warning is merely a side effect. (end note)

Mark Harrison
  • 297,451
  • 125
  • 333
  • 465
  • The accepted answer on the dupe target explicitely says, quoting: "So in order to remove this message edit MAVEN_OPTS Environment User Variable". How is this not a duplicate? – Tunaki Nov 20 '15 at 17:09
  • The question asks for the location where mvn sets java options. There are no other places where java options can be set in a mvn project? – Mark Harrison Nov 20 '15 at 17:12
  • No, there is not. Note that MAVEN_OPTS control Java argument of the `mvn` executable itself. – Tunaki Nov 20 '15 at 17:12
  • I think you may be incorrect? I see this in an included POM file: -Xmx512M -XX:MaxPermSize=256M – Mark Harrison Nov 20 '15 at 17:14
  • Well actually there is, you can use maven-compile-plugin as stated here: https://maven.apache.org/plugins/maven-compiler-plugin/examples/pass-compiler-arguments.html – Jorge Campos Nov 20 '15 at 17:16
  • That's what I hinted in my previous comment. There's a difference between Java arguments of Maven itself (your question, and this is MAVEN_OPTS always) and Java arguments to executable Maven launches (or Maven plugins). This part of your configuration is for the latter case. – Tunaki Nov 20 '15 at 17:17
  • @JorgeCampos No, these are Java arguments given the Maven Compiler Plugin, not to Maven itself. – Tunaki Nov 20 '15 at 17:18
  • 1
    I see, I agree now. Then the only other place you can set the options for maven is editing the mvn.bat or mvn.sh file ! But i'm sure that this isn't what you want. – Jorge Campos Nov 20 '15 at 17:20
  • 1
    Please read my comment above: "That's what I hinted in my previous comment. There's a difference between Java arguments of Maven itself (your question, and this is MAVEN_OPTS always) and Java arguments to executable Maven launches (or Maven plugins). This part of your configuration is for the latter case.". The answer to the question "I would like to modify some Java options when Maven is run. Where does Maven store these options?" is MAVEN_OPTS. – Tunaki Nov 20 '15 at 17:24
  • I recommend reading the release notes for [Maven 3.3.1+](http://blog.soebes.de/blog/2015/03/17/apache-maven-3-dot-3-1-features/) – khmarbaise Nov 20 '15 at 17:39

0 Answers0