3

mvn command, among others, have following options:

  • -f,--file <arg> Force the use of an alternate POM file. (This is for pointing file instead of default pom.xml file.)
  • -gs,--global-settings <arg> Alternate path for the global settings file. (This one is for pointing the settings.xml file, which is by default in .m2 directory.)

Still there is yet one config file uncovered by these options - .mavenrc

So, my question is - Is there a way to tell maven from which file it should get MAVEN_OPTS?

shabunc
  • 23,119
  • 19
  • 77
  • 102
  • 1
    It looks that nothing changed still: http://stackoverflow.com/questions/4826128/maven-property-overloading – Andriy Plokhotnyuk Jul 19 '12 at 20:33
  • @AndriyPlokhotnyuk - it would be sad if it is true, but still tolerable ) let's wait a bit. – shabunc Jul 19 '12 at 20:46
  • @AndriyPlokhotnyuk that's not related to this issue. The question you're referring to is converting java system properties to maven build properties. That's a different story. – GeertPt Jul 19 '12 at 21:45
  • @greyfairer, it's a pity we can not just write something like blablabla in pom.xml, just like we can do it with "regular" properties. – shabunc Jul 20 '12 at 11:40

2 Answers2

7

MAVEN_OPTS is a environment variable from the OS. You can set it anyway you want before launching maven.

In bash (linux):

export MAVEN_OPTS=...

On windows:

set MAVEN_OPTS=...

I think you could even edit the 'mvn' of 'mvn.bat' shell script to get different variables.

GeertPt
  • 16,398
  • 2
  • 37
  • 61
  • sure, I worth to mention this, than you. Exporting this variable directly is slightly less convenient. Almost indistinguishably, but lest convenient. – shabunc Jul 19 '12 at 22:08
  • let consider this an answer, since, helas, nothing more relevant can be expected. – shabunc Jul 20 '12 at 11:50
6

Starting with Maven 3.3.1, you can put these settings into the .mvn/maven.config file in your project repository.

References:

joschi
  • 12,746
  • 4
  • 44
  • 50