Member-only story
Beginner’s Guide to Creating a Maven Plugin
Maven plugins are nothing but software components that allow reuse of common build logic across multiple projects or modules. In this article, I would like to demonstrate how to build a maven plugin and test it.
Creating a Maven Plugin Project
This article assumes that you have already installed Maven. In this article, I am going to create small plugin which creates a zip file for multiple files listed in a directory. Create a Maven project using maven-archetype-mojo.
Provide a suitable GroupId and ArtifactId. Make sure your GroupId and ArtifactId follows the guidelines provided here. This is important if you want to publish your plugin to Maven Central repository.
Continue by clicking Next. Once you click Finish, you will see that a POM file and a Mojo class has been created. Mojo is nothing but a goal in Maven. We can define metadata such as goal name, lifecycle phase and so on within a Mojo.