Wednesday, April 22, 2009

Encoding warning with Maven 2.1.0

Recently I updated Maven to newest release (2.1.0) for a new project. Upgrade from 2.0.9 was smooth and all existing build scripts were working fine. While glancing at the logs emitted by Maven found this warning message-

[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!

This warning message was not emitted by Maven 2.0.9. Reason of this warning message is that maven (plugins) use platform default encoding and it notifies the users about the build being platform dependent. This article (http://docs.codehaus.org/display/MAVENUSER/POM+Element+for+Source+File+Encoding) has detailed information about this change. Instead of using platform default encoding, Maven can be instructed to use any encoding by adding following property in the pom.xml

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>


and it no longer emits the warning message.

12 Comments:

Chris Baker said...

Ditto. Thanks a lot.

Rajesh Koilpillai said...

Thanks, ran into the same issue.

Shadowcat said...

Thanks a ton for posting this!

Tym said...

Thanks for the post, big help.

Ulf said...

11 PM Just what I was looking for, thanks.

Treboul said...

Also, thanks. Was a good help.

Gennady said...

Thanks a lot. Resolved my confusion after maven upgrade.

Unknown said...

Alternatively, use this to keep maven's default behaviour, i.e. to use the platform's default encoding. This is what Eclipse (and many other editors) by default does, so this might not be a bad idea:

<properties>
<project.build.sourceEncoding>${file.encoding}</project.build.sourceEncoding>
</properties>

joshejosh said...

This is covered in the Maven docos here:

http://maven.apache.org/general.html#encoding-warning

Unknown said...

Hey, Thanks a lot!

Anonymous said...

Really thank you for this hint! *thumps up*

Anonymous said...

Thank you, this tamed the ERROR/WARNING output of MAVEN's verbosity. MAVEN is finally silent now. Even remains silent, when removing the -Tag.