Package org.apache.maven.plugins.clean
Class CleanMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- org.apache.maven.plugins.clean.CleanMojo
-
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled,org.apache.maven.plugin.Mojo
@Mojo(name="clean", threadSafe=true) public class CleanMojo extends org.apache.maven.plugin.AbstractMojoGoal 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, andproject.reporting.outputDirectory.Files outside the default may also be included in the deletion by configuring the
filesetstag.- Since:
- 2.0
- Version:
- $Id$
- See Also:
Fileset
-
-
Field Summary
Fields Modifier and Type Field Description private java.io.FiledirectoryThis is where build results go.private booleanexcludeDefaultDirectoriesDisables the deletion of the default output directories configured for a project.private booleanfailOnErrorIndicates whether the build will continue even if there are clean errors.private Fileset[]filesetsThe list of file sets to delete, in addition to the default directories.private booleanfollowSymLinksSets whether the plugin should follow symbolic links while deleting files from the default output directories of the project.private java.io.FileoutputDirectoryThis is where compiled classes go.private java.io.FilereportDirectoryThis is where the site plugin generates its pages.private booleanretryOnErrorIndicates whether the plugin should undertake additional attempts (after a short delay) to delete a file if the first attempt failed.private booleanskipDisables the plugin execution.private java.io.FiletestOutputDirectoryThis is where compiled test classes go.private java.lang.BooleanverboseSets whether the plugin runs in verbose mode.
-
Constructor Summary
Constructors Constructor Description CleanMojo()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidexecute()Deletes file-sets in the following project build directory order: (source) directory, output directory, test directory, report directory, and then the additional file-sets.private java.io.File[]getDirectories()Gets the directories to clean (if any).private booleanisVerbose()Indicates whether verbose output is enabled.
-
-
-
Field Detail
-
directory
@Parameter(defaultValue="${project.build.directory}", readonly=true, required=true) private java.io.File directoryThis is where build results go.
-
outputDirectory
@Parameter(defaultValue="${project.build.outputDirectory}", readonly=true, required=true) private java.io.File outputDirectoryThis is where compiled classes go.
-
testOutputDirectory
@Parameter(defaultValue="${project.build.testOutputDirectory}", readonly=true, required=true) private java.io.File testOutputDirectoryThis is where compiled test classes go.
-
reportDirectory
@Parameter(defaultValue="${project.build.outputDirectory}", readonly=true, required=true) private java.io.File reportDirectoryThis is where the site plugin generates its pages.- Since:
- 2.1.1
-
verbose
@Parameter(property="maven.clean.verbose") private java.lang.Boolean verbose
Sets whether the plugin runs in verbose mode. As of plugin version 2.3, the default value is derived from Maven's global debug flag (compare command line switch-X).
Starting with 3.0.0 the property has been renamed fromclean.verbosetomaven.clean.verbose.- Since:
- 2.1
-
filesets
@Parameter private Fileset[] filesets
The list of file sets to delete, in addition to the default directories. For example:<filesets> <fileset> <directory>src/main/generated</directory> <followSymlinks>false</followSymlinks> <useDefaultExcludes>true</useDefaultExcludes> <includes> <include>*.java</include> </includes> <excludes> <exclude>Template*</exclude> </excludes> </fileset> </filesets>- Since:
- 2.1
-
followSymLinks
@Parameter(property="maven.clean.followSymLinks", defaultValue="false") private boolean followSymLinksSets whether the plugin should follow symbolic links while deleting files from the default output directories of the project. Not following symlinks requires more IO operations and heap memory, regardless whether symlinks are actually present. So projects with a huge output directory that knowingly does not contain symlinks can improve performance by setting this parameter totrue.
Starting with3.0.0the property has been renamed fromclean.followSymLinkstomaven.clean.followSymLinks.- Since:
- 2.1
-
skip
@Parameter(property="maven.clean.skip", defaultValue="false") private boolean skipDisables the plugin execution.
Starting with3.0.0the property has been renamed fromclean.skiptomaven.clean.skip.- Since:
- 2.2
-
failOnError
@Parameter(property="maven.clean.failOnError", defaultValue="true") private boolean failOnErrorIndicates whether the build will continue even if there are clean errors.- Since:
- 2.2
-
retryOnError
@Parameter(property="maven.clean.retryOnError", defaultValue="true") private boolean retryOnErrorIndicates whether the plugin should undertake additional attempts (after a short delay) to delete a file if the first attempt failed. This is meant to help deleting files that are temporarily locked by third-party tools like virus scanners or search indexing.- Since:
- 2.4.2
-
excludeDefaultDirectories
@Parameter(property="maven.clean.excludeDefaultDirectories", defaultValue="false") private boolean excludeDefaultDirectoriesDisables the deletion of the default output directories configured for a project. If set totrue, only the files/directories selected via the parameterfilesetswill be deleted.
Starting with 3.0.0 the property has been renamed fromclean.excludeDefaultDirectoriestomaven.clean.excludeDefaultDirectories.- Since:
- 2.3
-
-
Method Detail
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionExceptionDeletes file-sets in the following project build directory order: (source) directory, output directory, test directory, report directory, and then the additional file-sets.- Throws:
org.apache.maven.plugin.MojoExecutionException- When a directory failed to get deleted.- See Also:
Mojo.execute()
-
isVerbose
private boolean isVerbose()
Indicates whether verbose output is enabled.- Returns:
trueif verbose output is enabled,falseotherwise.
-
getDirectories
private java.io.File[] getDirectories()
Gets the directories to clean (if any). The returned array may contain null entries.- Returns:
- The directories to clean or an empty array if none, never
null.
-
-