0


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 Answer 1

1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.