Fork me on GitHub

Plugin Details

This report describes goals, parameters details, requirements and sample usage of this plugin.

Goals

Goals available for this plugin:

Goal Description
clean:clean Goal which cleans the build. This attempts to clean a project's working directory of the files that were generated at build-time. By default, it discovers and deletes the directories configured in project.build.directory, project.build.outputDirectory, project.build.testOutputDirectory, and project.reporting.outputDirectory.

Files outside the default may also be included in the deletion by configuring the filesets tag.


See also: Fileset
clean:help Display help information on maven-clean-plugin.
Call mvn clean:help -Ddetail=true -Dgoal=<goal-name> to display parameter details.
clean:purge-check Removes orphaned build output directories left behind by sub-projects that have been deleted or renamed since the last build.

When a sub-project is removed from the reactor (e.g. after a git pull or a branch switch), its target/ directory may remain on disk even though its pom.xml is gone. Because the sub-project is no longer part of the reactor, mvn clean cannot know about it and will skip it. This goal detects such orphaned directories and removes them.

Detection heuristic: a direct child directory of the current project's basedir is considered orphaned when its only non-hidden child is the build output directory (typically target/). A freshly checked-out or live sub-project always has at least a pom.xml alongside its build directory, so a directory whose sole visible content is a target/ folder can safely be assumed to be a leftover. The entire child directory (not just its build output subdirectory) is removed, since an orphaned directory with no source files has no reason to remain on disk.

System Requirements

The following specifies the minimum requirements to run this Maven plugin:

Maven 4.0.0-rc-7
JDK 17

System Requirements History

The following specifies the minimum requirements to run this Maven plugin for historical versions:

Plugin Version Maven JDK
4.0.0-beta-3 4.0.0-rc-7 17
4.0.0-beta-2 4.0.0-rc-2 17
4.0.0-beta-1 4.0.0-beta-3 -
from 3.4.0 to 3.5.0 3.6.3 8
from 3.2.0 to 3.3.2 3.2.5 8
3.1.0 3.0 7
3.0.0 3.0 6
from 2.6 to 2.6.1 2.2.1 5
2.5 2.0.6 5
from 2.3 to 2.4.1 2.0.6 1.4
2.2 2.0 1.4
2.1.1 2.0 -
from 2.0-beta-1 to 2.1 - -

Usage

You should specify the version in your project's plugin configuration:

<project>
  ...
  <build>
    <!-- To define the plugin version in your parent POM -->
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-clean-plugin</artifactId>
          <version>4.0.0-beta-3</version>
        </plugin>
        ...
      </plugins>
    </pluginManagement>
    <!-- To use the plugin goals in your POM or parent POM -->
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-clean-plugin</artifactId>
      </plugin>
      ...
    </plugins>
  </build>
  ...
</project>

For more information, see "Guide to Configuring Plug-ins"