Howto use maven in a heterogenous environment with different encodings?

I've created a svn repositoy on a linux server (Debian) and used a client on a windows machine to check my java sources in.

Now I've set up a Hudson server on a different linux server (Ubuntu) to periodically run tests on my code. But the tests fail with a compiler error:

Error: unmappable character for encoding ASCII

On my windows machine I've used the default encoding Cp1252. On my svn server I can do a local checkout of my sources and they look good. On my Hudson server the checkout contains illegal characters.

What are the parameters I have to adjust so that all three systems use a working encoding?

EDIT 2009-10-15:

I changed the default encoding of my Ubuntu system to latin1. Now I can open the checkedout files with an editor and they look good (thanks to @John-T at superuser.com).

But Hudson still complained about unmappable character for encoding ASCII and I found that this is caused by maven. I found an explantion, but the suggested solution didn't work. Now maven tells me that it uses latin1 when copying some resources, but the compiler (not using this setting?) still complains with the same error message.

13.10.2009 20:56:29
3 ОТВЕТА
РЕШЕНИЕ

No, the maven compiler plugin doesn't use the project.build.sourceEncoding property. So you need to configure the file encoding for it (I'd use UTF-8):

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-compiler-plugin</artifactId>
  <configuration>
    <encoding>UTF-8</encoding>
  </configuration>
</plugin>
18
15.10.2009 13:09:26
alternatively, you could use <encoding>${project.build.sourceEncoding}</encoding>
sfussenegger 11.08.2010 11:01:55
Since plugin ver 2.0, the default value is: ${project.build.sourceEncoding}.
Olivier Refalo 23.09.2011 18:01:41

The first thing to identify is which character is causing the problem. It may be that the broken char can be replaced by some pure-ASCII entity. SVN itself is encoding agnostic: it'll just store byte-for-byte what's passed in.

If Hudson requires 7-bit ASCII, then this is all you can do. Otherwise, find out what Hudson supports and save your files in this format instead. UTF-8 would probaby be the way to go.

0
13.10.2009 21:02:28
I have hundreds of files and I always used german as the language for comments. So it's not reasonable to manually change all occurences.
tangens 13.10.2009 21:15:20
See if Hudson accepts one of UTF-8, ISO-8859-1 or ISO-8859-15. And see if you can save your files in one of those formats...
Chris J 13.10.2009 21:21:22
You can use iconv to convert a file from one character set to another, you could script this to convert the files from CP1252 to UTF8.
caf 13.10.2009 22:16:54

I don't think there is a way to change the encoding of a file with SVN. You can set the encoding for a commit message with the --encoding flag, but not the contents of files themselves. Text files are stored in the same format they appear on your local disk. The only conversion is a translation of line endings according to the svn:eol-style property.

0
13.10.2009 21:03:48