Set surefire plugin Locale in Maven pom file

JHollanti picture JHollanti · Jan 17, 2012 · Viewed 9.6k times · Source

I read in maven-surefire-plugin and default locale that Maven runs tests forked and thus might lose any locale you might have set.

Is there a way to run tests in Maven in forked mode and still retain locale?

-- EDIT --

So, to clarify a bit: It is fully possible to set language and region in System Properties using:

<systemPropertyVariables>
  <user.language>en</user.language>
  <user.region>GB</user.region>
</systemPropertyVariables>

And they are actually passed to the running process. This does not however set locale accordingly; locale remains as System Default.

Answer

MIURA Toru picture MIURA Toru · Jul 26, 2013

Try this:

   <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
            <argLine>-Duser.language=en -Duser.region=GB</argLine>
        </configuration>
   </plugin>