Filed under: Java, Maven, — Tags: MacRoman, Platform dependent, Platform encoding, UTF-8 — Thomas Sundberg — 2011-02-22
Chasing the warning:
[WARNING] Using platform encoding (MacRoman actually) to copy filtered resources, i.e. build is platform dependent!
happens too often when you use Maven as a build tool. It is so frequent that it has made it to Maven Official FAQ
how you fix it. The simple solution is to add the property project.build.sourceEncoding
and set it to
the file encoding you want. This often tends to be UTF-8
for me.
It is very annoying when you have set the file encoding using the property project.build.sourceEncoding
and run the build again and notice the warning below:
[WARNING] File encoding has not been set, using platform encoding MacRoman, i.e. build is platform dependent!
Didn't I just fix that warning? It turns out that this is another warning about the same thing. It is generated by
some plugins, in this case by the maven-failsafe-plugin
. How can this warning be removed? Simple, just
set the file encoding you want for the reports by using the property project.reporting.outputEncoding
.
A working pom could look like this:
<?xml version="1.0" encoding="UTF-8"?> <project> <modelVersion>4.0.0</modelVersion> <groupId>se.sigma.educational.maven</groupId> <artifactId>platform-dependant</artifactId> <version>1.0</version> <packaging>jar</packaging> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> </properties> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.7.2</version> <configuration> <skip>true</skip> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-failsafe-plugin</artifactId> <version>2.7.2</version> <configuration> <includes> <include>**</include> </includes> </configuration> <executions> <execution> <id>integration-test</id> <phase>integration-test</phase> <goals> <goal>integration-test</goal> <goal>verify</goal> </goals> </execution> </executions> </plugin> </plugins> </build> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.8.2</version> </dependency> </dependencies> </project>