How to exclude separate files with nonFilteredFileExtension

Refresh

December 2018

Views

967 time

6

I have this bundle.

admin.common.upper_case=Uma ou mais letras maiúsculas

During building project this bundle becomes corrupted.

admin.common.upper_case=Uma ou mais letras mai�sculas

In order to fix issue we use this configuration for maven-resources-plugin Namely we added nonFilteredFileExtension tag for properties extension.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-resources-plugin</artifactId>
    <version>2.6</version>
    <configuration>
        <nonFilteredFileExtensions>
            <nonFilteredFileExtension>properties</nonFilteredFileExtension>
        </nonFilteredFileExtensions>
    </configuration>
</plugin>

This configuration caused issue with another property file like build.properties :

build.version=${project.version}
static.url.version=${project.build.timestamp}

We tried to use this configuration(namely added filter tag in order to filter build.properties file):

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-resources-plugin</artifactId>
    <version>2.6</version>
    <configuration>
        <filters>
            <filter>properties/build.properties</filter>
        </filters>
        <nonFilteredFileExtensions>
            <nonFilteredFileExtension>properties</nonFilteredFileExtension>
        </nonFilteredFileExtensions>
    </configuration>
</plugin>

Also we tried with this configuration in order to avoid filtering for current bundles:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-resources-plugin</artifactId>
    <version>2.6</version>
    <configuration>
        <webResources>
            <resource>
                <directory>src/main/resources</directory>
                <!-- enable filtering -->
                <filtering>true</filtering>
                <excludes>
                    <exclude>${basedir}/src/main/resources/one.properties</exclude>
                    <exclude>${basedir}/src/main/resources/two.properties</exclude>
                </excludes>
            </resource>
        </webResources>
    </configuration>
</plugin>

The question is how to allow filtering only for this property file build.properties

1 answers

0

Прежде всего, вы должны попытаться исправить корень вашей проблемы Указания схемы кодировки символов :

<project ...>
 ...
 <properties>
   <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
   ...
 </properties>
 ..
</project>

Один из способов сделать то , что вы хотите, чтобы указать файлы для включения и файлы исключают. Из документации :

<project>
  ...
  <name>My Resources Plugin Practice Project</name>
  ...
  <build>
    ...
    <resources>
      <resource>
        <directory>src/my-resources</directory>
        <includes>
          <include>**/*.txt</include>
        </includes>
        <excludes>
          <exclude>**/*test*.*</exclude>
        </excludes>
      </resource>
      ...
    </resources>
    ...
  </build>
  ...
</project>

Элементы includeи excludeдолжны также работает с конкретными файлами , такими как path/to/abc.properties.