Fork me on GitHub

clean:purge-check

Full name:

org.apache.maven.plugins:maven-clean-plugin:4.0.0-beta-3:purge-check

Description:

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.

Attributes:

  • Requires a Maven project to be executed.
  • The goal is not marked as thread-safe and thus does not support parallel builds.
  • Since version: 4.0.0-beta-3.
  • Binds by default to the lifecycle phase: initialize.

Optional Parameters

Name Type Since Description
<failOnError> boolean - Indicates whether the build will continue even if there are errors while deleting orphaned build directories.
<force> boolean - Whether to force the deletion of read-only files inside orphaned build directories.
<retryOnError> boolean - Indicates whether the plugin should undertake additional attempts (after a short delay) to delete a file if the first attempt failed.
<skip> boolean - Disables the plugin execution.
<verbose> Boolean - Sets whether the plugin runs in verbose mode.

Parameter Details

<failOnError>

Indicates whether the build will continue even if there are errors while deleting orphaned build directories.
  • Type: boolean
  • Required: No

<force>

Whether to force the deletion of read-only files inside orphaned build directories.
  • Type: boolean
  • Required: No

<retryOnError>

Indicates whether the plugin should undertake additional attempts (after a short delay) to delete a file if the first attempt failed.
  • Type: boolean
  • Required: No

<skip>

Disables the plugin execution.
  • Type: boolean
  • Required: No

<verbose>

Sets whether the plugin runs in verbose mode.
  • Type: java.lang.Boolean
  • Required: No