hudson compiler and source character encoding

We recently has a strange problem occurring on our continuous integration server (which uses the hudson) on a specific maven build.
Some code was checked in which included the following line

final protected static char CONCATENATION_SEPERATOR = '§';

Nothing very special you would assume, and all compiled fine locally (on two systems I might add).

Hudson however reported errors like


Blabla.java :[24,58] unclosed character literal
Blabla.java :[24,60] illegal character: \65533
Blabla.java :[24,61] unclosed character literal
no more tokens - could not parse error message: Blabla.java :122: ';' expected

It was clearly not handling the character (encoding). Now all our source files are UTF-8, but hudson doesn’t seem to pick this up.

To fix it, we explicitly told the java compiler (javac) what the file encoding is. This was done using the following excerpt from the master pom file (note that this also ensures java 5 is used for compilation – that bit was already in there).

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <encoding>utf8</encoding>
                <source>1.5</source>
                <target>1.5</target>
            </configuration>
        </plugin>
     </plugins>
</build>

Leave a Reply

Your email address will not be published. Required fields are marked *

question razz sad evil exclaim smile redface biggrin surprised eek confused cool lol mad twisted rolleyes wink idea arrow neutral cry mrgreen

*