@Mojo(name="clean",
threadSafe=true)
public class CleanMojo
extends org.apache.maven.plugin.AbstractMojo
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.
Fileset
Modifier and Type | Field and Description |
---|---|
private java.io.File |
directory
This is where build results go.
|
private boolean |
excludeDefaultDirectories
Disables the deletion of the default output directories configured for a project.
|
private boolean |
failOnError
Indicates whether the build will continue even if there are clean errors.
|
private Fileset[] |
filesets
The list of file sets to delete, in addition to the default directories.
|
private boolean |
followSymLinks
Sets whether the plugin should follow symbolic links while deleting files from the default output directories of
the project.
|
private java.io.File |
outputDirectory
This is where compiled classes go.
|
private java.io.File |
reportDirectory
This is where the site plugin generates its pages.
|
private boolean |
retryOnError
Indicates whether the plugin should undertake additional attempts (after a short delay) to delete a file if the
first attempt failed.
|
private boolean |
skip
Disables the plugin execution.
|
private java.io.File |
testOutputDirectory
This is where compiled test classes go.
|
private java.lang.Boolean |
verbose
Sets whether the plugin runs in verbose mode.
|
Constructor and Description |
---|
CleanMojo() |
Modifier and Type | Method and Description |
---|---|
void |
execute()
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 boolean |
isVerbose()
Indicates whether verbose output is enabled.
|
@Parameter(defaultValue="${project.build.directory}", readonly=true, required=true) private java.io.File directory
@Parameter(defaultValue="${project.build.outputDirectory}", readonly=true, required=true) private java.io.File outputDirectory
@Parameter(defaultValue="${project.build.testOutputDirectory}", readonly=true, required=true) private java.io.File testOutputDirectory
@Parameter(defaultValue="${project.build.outputDirectory}", readonly=true, required=true) private java.io.File reportDirectory
@Parameter(property="maven.clean.verbose") private java.lang.Boolean verbose
-X
). clean.verbose
to
maven.clean.verbose
.@Parameter private Fileset[] filesets
<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>
@Parameter(property="maven.clean.followSymLinks", defaultValue="false") private boolean followSymLinks
true
. 3.0.0
the property has been renamed from clean.followSymLinks
to
maven.clean.followSymLinks
.@Parameter(property="maven.clean.skip", defaultValue="false") private boolean skip
3.0.0
the property has been renamed from clean.skip
to
maven.clean.skip
.@Parameter(property="maven.clean.failOnError", defaultValue="true") private boolean failOnError
@Parameter(property="maven.clean.retryOnError", defaultValue="true") private boolean retryOnError
@Parameter(property="maven.clean.excludeDefaultDirectories", defaultValue="false") private boolean excludeDefaultDirectories
true
,
only the files/directories selected via the parameter filesets
will be deleted. clean.excludeDefaultDirectories
to
maven.clean.excludeDefaultDirectories
.public void execute() throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionException
- When a directory failed to get deleted.Mojo.execute()
private boolean isVerbose()
true
if verbose output is enabled, false
otherwise.private java.io.File[] getDirectories()
null
.