Delete Additional Files Not Exposed to Maven
The Maven Clean Plugin will delete the target
directory by default. You may configure it to delete additional directories and files. The following example shows how:
<build> [...] <plugin> <artifactId>maven-clean-plugin</artifactId> <version>3.2.0</version> <configuration> <filesets> <fileset> <directory>some/relative/path</directory> <includes> <include>**/*.tmp</include> <include>**/*.log</include> </includes> <excludes> <exclude>**/important.log</exclude> <exclude>**/another-important.log</exclude> </excludes> <followSymlinks>false</followSymlinks> </fileset> </filesets> </configuration> </plugin> [...] </build>
Note: The directory
in the fileset
is a relative path inside a project, in other words,
<directory>some/relative/path</directory>
is equivalent to:
<directory>${basedir}/some/relative/path</directory>
You could also define file set rules in a parent POM. In this case, the clean plugin adds the subproject basedir to the defined relative path.