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.4.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>/Users/slawomir.jaranowski/repos/apache/maven-clean-plugin/target/checkout/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.

Note: The fast delete method will not work for any fileset which defines any includes or excludes, or sets followSymlinks to false, or sets useDefaultExcludes to true.