The Maven Clean Plugin, as the name implies, attempts to clean the files and directories generated by Maven during its build. While there are plugins that generate additional files, the Clean Plugin assumes that these files are generated inside the target directory.
The Clean Plugin can be called to execute in the command-line without any additional configurations. Like the other plugins, to run the Clean Plugin, you use:
mvn clean:clean
where the first clean refers to the plugin's alias, and the second clean refers to the plugin goal.
However, the Clean Plugin is a special plugin and is bound to its own special lifecycyle phase called clean. Thus, for simplicity, it can also be executed by using:
mvn clean
or with other phases/goals like:
mvn clean package site
If for some reason, adding clean to the command-line is not option, the Clean Plugin can be put into a project's pom.xml so that it gets executed everytime the project is built. Below is a sample pom.xml for running the Clean Plugin in the initialize phase everytime the project is built:
<project> [...] <build> <plugins> <plugin> <artifactId>maven-clean-plugin</artifactId> <version>2.4</version> <executions> <execution> <id>auto-clean</id> <phase>initialize</phase> <goals> <goal>clean</goal> </goals> </execution> </executions> </plugin> </plugins> </build> [...] </project>