Maven资源过滤排除

时间:2016-01-12 17:12:37

标签: maven

我有以下maven配置:

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

我希望keystore.jks包含在我的类/ war应用程序中,但不要由Maven过滤处理。

如何更改此配置?

2 个答案:

答案 0 :(得分:21)

根据Maven Resource Filtering Documentation,这应该有效:

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

答案 1 :(得分:4)

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>