22

I have a following maven configuration:

        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
                <excludes>
                    <exclude>keystore.jks</exclude>
                </excludes>
            </resource>
        </resources>

I want keystore.jks to be included in my classes/war application but not to be processed by Maven filtering.

How to change this configuration ?

alexanoid
  • 24,051
  • 54
  • 210
  • 410

2 Answers2

38

According to the Maven Resource Filtering Documentation, this should work:

<resources>
    <resource>
        <directory>src/main/resources</directory>
        <filtering>true</filtering>
        <excludes>
            <exclude>keystore.jks</exclude>
        </excludes>
    </resource>
    <resource>
        <directory>src/main/resources</directory>
        <filtering>false</filtering>
        <includes>
            <include>keystore.jks</include>
        </includes>
    </resource>
</resources>
Isabella Almeida
  • 789
  • 7
  • 12
  • 1
    The [answer from Charels Hu](https://stackoverflow.com/a/44965768/525036) seems to be a better approach as you don't have to duplicate your includes/excludes and directory definitions with it. – Didier L Aug 03 '21 at 13:58
  • This did not work for me, also the documentation in the link has changed ... suggests to keep filtered/unfiltered resources in separate folders – krenkz Jul 12 '23 at 08:38
23

Binary filtering

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-resources-plugin</artifactId>
  <version>3.0.2</version>
  <configuration>
    <nonFilteredFileExtensions>
      <nonFilteredFileExtension>jks</nonFilteredFileExtension>
    </nonFilteredFileExtensions>
  </configuration>
</plugin>
Charles Hu
  • 582
  • 5
  • 9