[ 
https://issues.apache.org/jira/browse/MRESOURCES-171?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16765910#comment-16765910
 ] 

Dennis Lundberg edited comment on MRESOURCES-171 at 2/13/19 9:47 AM:
---------------------------------------------------------------------

Hi,
 We stumbled across this issue today for one of our projects that has 
{{project.build.sourceEncoding=UTF-8}} and includes properties files that use 
ISO-8859-1 encoding. The properties files are filtered. We have both regular 
properties files and properties files that are used as ResourceBundles. There 
are also non-properties files in the resources directory that needs to be 
filtered.

Here is a proposal on how such a situation can be handled.
{code:xml}
  <build>
    <resources>
      <resource>
        <directory>src/main/resources</directory>
        <filtering>true</filtering>
        <excludes>
          <exclude>**/*.properties</exclude>
        </excludes>
      </resource>
    </resources>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-resources-plugin</artifactId>
        <executions>
          <execution>
            <id>resources-properties</id>
            <goals>
              <goal>resources</goal>
            </goals>
            <configuration>
              <encoding>ISO-8859-1</encoding>
              <resources>
                <resource>
                  <directory>src/main/resources</directory>
                  <filtering>true</filtering>
                  <includes>
                    <include>**/*.properties</include>
                  </includes>
                </resource>
              </resources>
            </configuration>
          </execution>
        </executions>
      </plugin>
{code}

The <build>/<resources> part takes care of all the resources, except properties 
files. They will be filtered using whatever encoding is specified by 
project.build.sourceEncoding.

The execution with id=resources-properties will filter all the properties files 
using ISO-8859-1 encoding, but will not touch any other resource file.


was (Author: [email protected]):
Hi,
 We stumbled across this issue today for one of our projects that has 
{{project.build.sourceEncoding=UTF-8}} and includes properties files that use 
ISO-8859-1 encoding. The properties files are filtered. We have both regular 
properties files and properties files that are used as ResourceBundles. There 
are also non-properties files in the resources directory that needs to be 
filtered.

Here is a proposal on how such a situation can be handled.
{code:xml}
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-resources-plugin</artifactId>
        <executions>
          <execution>
            <id>default-resources</id>
            <goals>
              <goal>resources</goal>
            </goals>
            <configuration>
              <encoding>UTF-8</encoding>
              <resources>
                <resource>
                  <directory>src/main/resources</directory>
                  <filtering>true</filtering>
                  <excludes>
                    <exclude>**/*.properties</exclude>
                  </excludes>
                </resource>
              </resources>
            </configuration>
          </execution>
          <execution>
            <id>resources-properties</id>
            <goals>
              <goal>resources</goal>
            </goals>
            <configuration>
              <encoding>ISO-8859-1</encoding>
              <resources>
                <resource>
                  <directory>src/main/resources</directory>
                  <filtering>true</filtering>
                  <includes>
                    <include>**/*.properties</include>
                  </includes>
                </resource>
              </resources>
            </configuration>
          </execution>
        </executions>
      </plugin>
{code}

> ISO8859-1 properties files get changed into UTF-8 when filtered
> ---------------------------------------------------------------
>
>                 Key: MRESOURCES-171
>                 URL: https://issues.apache.org/jira/browse/MRESOURCES-171
>             Project: Maven Resources Plugin
>          Issue Type: Bug
>          Components: filtering
>            Reporter: Alex Collins
>            Priority: Minor
>         Attachments: filtering-bug.zip
>
>
> Create:
> src/main/resources/test.properties
> And add a ISO8859-1 character that is not ASCII or UTF-8, do not use \uXXXX 
> formatting.
> When adding this line:
> <resource><directory>src/main/resources</directory><filtering>true</filtering></resource>
> Expected:
> ISO8859-1 encoded file in jar.
> Actual:
> UTF-8 encoded file in jar.
> ---
> If there are any property files (which can only be ISO8859-1) they appear to 
> be converted into UTF-8 in the jar.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to