What are Maven Plugins
In this tutorial we are going to learn about Maven Plugins in detail.
Maven is actually a plugin execution framework where every task is actually done by plugins. Maven Plugins are generally used to −
- create jar file
- create war file
- compile code files
- unit testing of code
- create project documentation
- create project reports
Maven plugins enable you to add your own actions to the build process. You do so by creating a simple Java class that extends a special Maven class, and then create a POM for the project. The plugin should be located in its own project. Maven Plugins are generally used to : create jar file, create war file, compile code files, unit testing of code, create project documentation, create project reports
A plugin generally provides a set of goals and which can be executed using following syntax:
mvn [plugin-name]:[goal-name]
For example, a Java project can be compiled with the maven-compiler-plugin’s compile-goal by running following command
mvn compiler:compile
Plugin Types :
Build plugins: They execute during the build and should be configured in the
Reporting plugins: They will be executed during the site generation and they should be configured in the
Here follows the list of few common plugins:
- clean: Clean up target after the build. Deletes the target directory.
- compiler: Compiles Java source files.
- surefile: Run the JUnit unit tests. Creates test reports.
- jar: Builds a JAR file from the current project.
- war: Builds a WAR file from the current project.
- javadoc: Generates Javadoc for the project.
- antrun: Runs a set of ant tasks from any phase mentioned of the build.