简体   繁体   中英

Maven exclude resources not working as expected


I am trying to exclude from a build all YAML resource files, but the ones with a prod clause within the filename.
For example, given that my resource directory contains application-dev.yaml , application-test.yaml and application-prod.yaml , I would like application-dev.yaml and application-test.yaml to be excluded and application-prod.yaml to be kept.

The portion of my POM that deals with the resources is below:

<build>
  <resources>
    <resource>
      <directory>${project.basedir}/src/main/resources</directory>
      <excludes>
        <exclude>**/*-!(prod).yaml</exclude>
      </excludes>
    </resource>
    <resource>
      <directory>${project.basedir}/web/WEB-INF</directory>
    </resource>
  </resources>

However, exclusion does not work and all YAML files are copied, including application-dev.yaml and application-test.yaml .
I tested the exclusion pattern in Bash shell by ls *-.(prod).yaml and it worked as expected.

At this point I am lost and am looking for the community assistance.
I thank you all in advance for your thoughts and comments.

In order to solve that I would go with maven profiles and resource plugin maven resource plugin You can have variables to the resource file name according to what you need (prod, dev, etc)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM