maven-eclipse-plugin and encoding file

1k views Asked by At


How do we force the Eclipse project to use a specific encoding format for a specific type of file ?

Example : UTF-8 for *.sql and ISO-8859-1 for *.java

I can do that in Eclipse of course.
But for the benefit of the team and any new comer, i would like to automatize this task in the build process.

Thankls in advance.

1

There are 1 answers

0
hubbardr On

Assuming your sql files are located in a folder identified as a resource (eg /src/main/resources), you can specify a different encoding using the maven-resource plugin.

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-resources-plugin</artifactId>
      <version>2.5</version>
      <configuration>
        <encoding>UTF-8</encoding>
      </configuration>
    </plugin>
  </plugins>
  ... 
</build>

And source encoding is specified by the system or manually by something like:

<properties>
  <project.build.sourceEncoding>ISO-8859-1</project.build.sourceEncoding>
</properties>

For others that don't know how to do this in Eclipse:

  1. Window >> Preferences >> General >> Content Types
  2. Select appropriate content type.
  3. Specify specific encoding for that content type at bottom of window.