in src/main/java/org/apache/maven/plugins/clean/CleanMojo.java [218:270]
public void execute() throws MojoExecutionException {
if (skip) {
getLog().info("Clean is skipped.");
return;
}
String multiModuleProjectDirectory =
session != null ? session.getSystemProperties().getProperty("maven.multiModuleProjectDirectory") : null;
File fastDir;
if (fast && this.fastDir != null) {
fastDir = this.fastDir;
} else if (fast && multiModuleProjectDirectory != null) {
fastDir = new File(multiModuleProjectDirectory, "target/.clean");
} else {
fastDir = null;
if (fast) {
getLog().warn("Fast clean requires maven 3.3.1 or newer, "
+ "or an explicit directory to be specified with the 'fastDir' configuration of "
+ "this plugin, or the 'maven.clean.fastDir' user property to be set.");
}
}
if (fast
&& !FAST_MODE_BACKGROUND.equals(fastMode)
&& !FAST_MODE_AT_END.equals(fastMode)
&& !FAST_MODE_DEFER.equals(fastMode)) {
throw new IllegalArgumentException("Illegal value '" + fastMode + "' for fastMode. Allowed values are '"
+ FAST_MODE_BACKGROUND + "', '" + FAST_MODE_AT_END + "' and '" + FAST_MODE_DEFER + "'.");
}
Cleaner cleaner = new Cleaner(session, getLog(), isVerbose(), fastDir, fastMode);
try {
for (File directoryItem : getDirectories()) {
if (directoryItem != null) {
cleaner.delete(directoryItem, null, followSymLinks, failOnError, retryOnError);
}
}
if (filesets != null) {
for (Fileset fileset : filesets) {
if (fileset.getDirectory() == null) {
throw new MojoExecutionException("Missing base directory for " + fileset);
}
GlobSelector selector = new GlobSelector(
fileset.getIncludes(), fileset.getExcludes(), fileset.isUseDefaultExcludes());
cleaner.delete(
fileset.getDirectory(), selector, fileset.isFollowSymlinks(), failOnError, retryOnError);
}
}
} catch (IOException e) {
throw new MojoExecutionException("Failed to clean project: " + e.getMessage(), e);
}
}