Usage

Recode

The following example recodes files from UTF-8 to ISO-8859-1, translating \r\n (DOS/Windows newlines with CR) to \n (Unix newlines without CR).

<plugin>
  <groupId>de.smartics.maven.plugin</groupId>
  <artifactId>recode-maven-plugin</artifactId>
  <version>0.1.5</version>
  <executions>
    <execution>
      <id>recode</id>
      <goals>
        <goal>recode</goal>
      </goals>
      <configuration>
        <resources>
          <resource>
            <dir>${basedir}/target/classes</dir>
            <sourceEncoding>UTF-8</sourceEncoding>
            <targetEncoding>ISO-8859-1</targetEncoding>
            <includes>
              <include>**/*.txt</include>
            </includes>
            <excludes>
              <exclude>notme.txt</exclude>
            </excludes>
            <fromDos>true</fromDos>
          </resource>
        </resources>
        <verbose>true</verbose>
      </configuration>
    </execution>
  </executions>
</plugin>

The recode takes place in the target folder after the resources plugin has copied them.

[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ sandbox-test ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO]
[INFO] --- recode-maven-plugin:0.1.0-SNAPSHOT:recode (recode) @ sandbox-test ---
[INFO] Processing resource for recode: C:\workspaces\sandbox-test\target\classes (includes: **/*.txt) (excludes: notme.txt): UTF-8->ISO-8859-1 (fromDos: true)
[INFO]  Recoding file UTF-8->ISO-8859-1: C:\workspaces\sandbox-test\target\classes\x.txt
[INFO]  File recoded: C:\workspaces\sandbox-test\target\classes\x.txt
[INFO] Resources recoded successfully.
[INFO]

List

The following example shows how the encodings suppored by the platform can be listed.

mvn de.smartics.maven.plugin:recode-maven-plugin:0.1.5:list
[INFO] Supported charsets: Big5
 ...
 ISO-8859-1
 ISO-8859-13
 ISO-8859-15
 ISO-8859-2
 ISO-8859-3
 ISO-8859-4
 ISO-8859-5
 ISO-8859-6
 ISO-8859-7
 ISO-8859-8
 ISO-8859-9
 ...
 US-ASCII
 UTF-16
 UTF-16BE
 UTF-16LE
 UTF-32
 UTF-32BE
 UTF-32LE
 UTF-8
 ...