maven-clean-plugin
The Maven Clean Plugin
1. Overview
For an overview of the other core plugins, refer to this article.
2. Plugin Goal
The clean lifecycle has only one phase named clean that is automatically bound to the only goal of the plugin with the same name. This goal can, therefore, be executed with the command mvn clean.
The clean plugin is already included in the super POM, thus we can use it without specifying anything in the project’s POM.
This plugin, as its name implies, cleans the files and directories generated during the previous build. By default, the plugin removes the target directory.
3. Configuration
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<filesets>
<fileset>
<directory>output-resources</directory>
</fileset>
</filesets>
</configuration>
</plugin>
The latest version of this plugin is listed here.
If the output-resources directory contains some generated resources, it cannot be removed with the default settings. The change we’ve just made instructs the clean plugin to delete that directory in addition to the default one.
4. Conclusion
The complete source code for this tutorial can be found over on GitHub.