when you run mvn --version
part of the output includes the locale and pratform encoding.
For example: Default locale: en_GB, platform encoding: Cp1252
I would like to know where it picks these up from and how they can be set
maven picking these values from Java system properties. Here is how you could set encoding:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
Or:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
Or pass parameter to maven command line:
mvn -Dproject.build.sourceEncoding=UTF-8
You could set environment information for maven (on a windows system) with
set "MAVEN_OPTS=-Duser.language=fr -Dfile.encoding=UTF-8"
set MAVEN_OPTS= -Dfile.encoding="UTF-8"
Actually it won't work, you need to remove the quotes ("") :
set MAVEN_OPTS= -Dfile.encoding=UTF-8
Best solution is:
<project>
...
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
...
</properties>
...
</project>
More: http://www.sonatype.com/people/2009/11/special-character-encoding-properties/
I had the same problem. The only thing that works is to set the appropriate MAVEN_OPTS. So if you use windows you can adapt mvn.bat in %MAVEN_HOME%/bin as follows:
set MAVEN_OPTS=%MAVEN_OPTS% -Dfile.encoding="UTF-8"
Following this mvn -v shows this:
..
Default locale: de_DE, platform encoding: UTF-8
..