Skip to content

Instantly share code, notes, and snippets.

@baybatu
Last active June 30, 2020 20:31
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save baybatu/06d2db792496de1fd3cb to your computer and use it in GitHub Desktop.
Save baybatu/06d2db792496de1fd3cb to your computer and use it in GitHub Desktop.
Excluding Directory From War Package In maven-war-plugin

packagingExcludes configuration tag can be used to exclude certain files or directories from the war file. It is important to put '/' character at the end of the directory to be excluded. If there is no such '/' character, then the entry is interpreted as a regular file.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.3</version>
    <configuration>
        <packagingExcludes>static/build/node_modules/</packagingExcludes>
    </configuration>
</plugin>

It is possible to exclude more than one directory via comma-separated list.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.3</version>
    <configuration>
        <packagingExcludes>static/build/node_modules/,static/build/other_dir/</packagingExcludes>
    </configuration>
</plugin>

You can get more information from documentation of the maven-war-plugin itself.

@O-o-Ps
Copy link

O-o-Ps commented May 26, 2017

works fine with '/' character at the end of the directory to be excluded

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment