Member-only story

Beginner’s Guide to Creating a Maven Plugin

Swathi Prasad
6 min readMay 26, 2019

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.

Maven

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.

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.

GoupId and ArtifactId for new project

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.

--

--

Swathi Prasad
Swathi Prasad

Written by Swathi Prasad

Software architect and developer living in Germany. Sharing my opinion and what I learn.

No responses yet