Maven: vm args in MAVEN_OPTS arent working, but they are if specified in the command line

918 Views Asked by At

I have a particular test case that is run by surefire which fails when this vm arg is not set.

I am able to get the test to successfully pass if i run:

mvn test -Dtest=TestClass -Djava.net.preferIPv4Stack=true

This works great. Now I want to generalize this so that the vm arg is set for all maven builds.

In my .bashrc I've added

MAVEN_OPTS='-Djava.net.preferIPv4Stack=true'

I have confirmed via echoing the env variable that it is set. This unfortunately does not make a difference for my test case. What other considerations am I missing that would interfere here?

Thanks! R

1

There are 1 best solutions below

0
On

Based on the documentation you can give a supplemental configuration to the maven-surefire-plugin:

<configuration>
  <argLine>-Djava.net.preferIPv4Stack=true</argLine>
  ...
</configuration>