3

How to exclude files from src/main/resources, for ex : I have a folder named "map" in there, which I wanna keep and I want to delete everything from war(or not to package it inside at firstplace).

Or alternative but same result, exclude all *.resources files from src/main/resources and put in war everything else?

Thank you

ant
  • 22,634
  • 36
  • 132
  • 182

3 Answers3

10

You may configure your resources like this:

<build>
    <resources>
        <resource>
           <directory>src/main/resources/map</directory>
        </resource>
    </resources>
</build>

or this:

<build>
    <resources>
        <resource>
           <directory>src/main/resources</directory>
           <excludes>
               <exclude>**/*.log</exclude>
           </excludes>
        </resource>
    </resources>
</build>

For more details, click here.

edrabc
  • 1,259
  • 1
  • 14
  • 23
Péter Török
  • 114,404
  • 31
  • 268
  • 329
4

If you don't want some resources to be copied into target/classes, you can define includes or excludes in the resource element as documented in Including and excluding files and directories. For example:

<build>
  <resources>
    <resource>
      <directory>src/main/resources</directory>
      <excludes>
        <exclude>**/map/*.*</exclude>
      </excludes>
    </resource>
  </resources>
</build>

If you want resources to be still copied into target/classes but for some reason don't want them to be packaged in the final artifact, then configure the maven war plugin to use packagingExcludes.

Pascal Thivent
  • 562,542
  • 136
  • 1,062
  • 1,124
0

The official documentation for the maven resources plugin describes how you can perform includes and excludes.

http://maven.apache.org/plugins/maven-resources-plugin/examples/include-exclude.html

Geoff
  • 3,129
  • 23
  • 11