Maven2: native2ascii conversion from UTF-8 to ASCII

Sometime it’s necessary to convert .properties files which have been saved as UTF-8 to the native ascii format so they can be loaded by Java applications later on. If you use Maven2 you will run into some nasty problems. Whatever you do, the files seems to never be converted…

Let’s assume we want to convert the file i18n/lift-core_de_DE.properties to the .properties ascii format (escaped unicode characters). You need this section in your POM file:

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>native2ascii-maven-plugin</artifactId>
<configuration>
<src>src/main/resources/i18n</src>
<dest>target/classes/i18n</dest>
</configuration>
<executions>
<execution>
<id>native2ascii-utf8</id>
<goals>
<goal>native2ascii</goal>
</goals>
<configuration>
<encoding>UTF8</encoding>
<includes>lift-core_de_DE.properties</includes>
</configuration>
</execution>
</executions>
</plugin>

But if you look into target/classes/i18n/ after a compile you still can see the old data… The problem is that the maven resource plugin overwrites the converted file. Use this in your pom.xml file :

<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
<excludes>
<exclude>**/lift-core_de_DE.properties</exclude>
</excludes>
</resource>
</resources>

Posted

in

,

by

Tags:

Comments

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.