Maven compile UTF-8 & properties files

Viewed 2491

I am using maven to compile my project using this configuration:

    <resources>
        <resource>
            <directory>src/main/resources</directory>
            <filtering>true</filtering>
        </resource>
    </resources>
<plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <encoding>UTF-8</encoding>
                        <source>${java.version}</source>
                        <target>${java.version}</target>
                        <showDeprecation>true</showDeprecation>
                        <showWarnings>true</showWarnings>
                    </configuration>
                </plugin>
            </plugins>

The project should be in UTF-8, but by convention .properties files should be latin1 (ISO 8859-1) and Eclipse treats them that way (I know I can change how Eclipse behaves, but that's not the point). I use .properties files for internationalization.

The problem is that, using Eclipse to deploy to Tomcat, I can see my special chars well, but when compiling through maven (for instance, through Jenkins), I get all messed characters, like somehow Maven is translating all my .properties into UTF-8, thus screwing all my i18n messages.

What is the proper way to solve this? It feels like this should be a very common problem but I haven't found a valid solution online.

1 Answers
Related