Skip to content

soujava/pom-editor-maven-plugin

Repository files navigation

POM Editor Maven Plugin

Documentation

Maven Central Maven SNAPSHOT Repo

badge badge jacoco java 11 branches java 11

Introduction

Facilitate manipulation such as managing POM dependencies through CLI (command line interface)

How to use it

Tip

In order to make easier the plugin utilization we can register the groupId into the settings.xml like the snipped code below:

<settings >
    <!-- snipped -->
    <pluginGroups>
      <pluginGroup>br.org.soujava</pluginGroup>
    </pluginGroups>
    <!-- snipped -->
</settings>

With that, we will be able to perform the plugin by using its prefix. So, instead of to perform the plugin by the following command:

mvn br.org.soujava:pom-editor-maven-plugin:<GOAL>

We may perform it just providing its prefix like below:

mvn pom-editor:<GOAL>

In the documentation, we’ll assume that you have done this configuration.

Add/Change a dependency

Let’s suppose that you need to add JUnit Jupiter version 5.9.2 into your POM in the test scope, you could perform the following command inside on the target maven project:

mvn pom-editor:add-dep -Dgav='org.junit.jupiter:junit-jupiter:5.9.2' -Dscope=test
Table 1. add-dep supported parameters
Parameter Description Required Default

gav

Dependency coordinates. Supported format: groupId:artifactId:version

Yes

pom

Target POM file.

No

pom.xml

scope

The scope of the dependency - compile, runtime, test, system, and provided

No

type

The type of dependency, that will be mapped to a file extension, an optional classifier and a few other attributes

No

classifier

The classifier of the dependency. It is appended to the filename after the version.

No

Confirm the changes

When you perform the goal add-dep with the command below:

$ mvn pom-editor:add-dep -Dgav='junit:junit:4.13'

The plugin will create a backup POM file based on the target POM if such one doesn’t exist.

$ tree .
.
├── pom.xml
└── pom.xml.backup

You could perform multiple times the add-dep goal as you need.

Then, when you’re done, if there’s no problem with the changed POM, you could confirm the changes by performing the commit goal.

$ mvn pom-editor:commit

Revert the changes

You could also perform the rollback goal:

$ mvn pom-editor:rollback

This goal will revert the changes, replacing the changed POM file to the backup POM file.

Goals

It covers the following goals:

  • Add/Change dependencies at POM.xml

  • Rollback/Commit changes at POM.xml

Code of Conduct

Take a look at here for more information.

The Code of Conduct of this project is adapted from the Contributor Covenant, version 1.4, available at here.

Contributing

We are very happy you are interested in helping us and there are plenty ways you can do so.

  • Open an Issue: Recommend improvements, changes and report bugs

  • Open a Pull Request: If you feel like you can even make changes to our source code and suggest them, just check out our contributing guide to learn about the development process, how to suggest bugfixes and improvements.

Contact

Join the SouJava Discord server and say hello at #pom-editor-maven-plugin channel!