Update parent POM

Use latest parent POM

The Maven project object model ("POM") defines a parent project object model that provides default settings. An update of the parent POM will allow this plugin to compile with recent Java versions. The most recent parent POM files also provide additional static analysis like spotbugs.

Create a branch

In a local copy of your fork of the plugin repository create a git branch for your work with the command:

git checkout -b update-parent-pom master

Compile the plugin

Use Apache Maven to compile the plugin.

mvn -ntp clean verify

When modernizing older plugins, You may need to use Java 8 to compile the plugin initially. Once the parent POM has been updated, you’ll be able to compile and test with recent Java versions.

Update parent POM

Use Apache Maven to update the parent POM:

mvn -ntp versions:update-parent
[INFO] Scanning for projects...
[INFO] ---------------< org.jenkins-ci.plugins:your-plugin >----------------
[INFO] Building Schedule Build Plugin 1.0.0-SNAPSHOT
[INFO] --------------------------------[ hpi ]---------------------------------
[INFO] --- versions-maven-plugin:2.8.1:update-parent (default-cli) @ your-plugin ---
[INFO] Updating parent from 3.50 to 4.47
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  3.013 s
[INFO] Finished at: 2021-09-26T20:03:00-06:00
[INFO] ------------------------------------------------------------------------

Review the change that Apache Maven performed for you with the command:

git diff
diff --git a/pom.xml b/pom.xml
index e6a8356..3a42d47 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
-    <version>3.50</version>
+    <version>4.47</version>


Compile the updated code with the command:

mvn clean verify

Remove java.level property

If there is a <java.level> property defined in the POM, remove it. The minimum version required for a specific pom is now implicit in the POM. The plugin maintainer does not need to specify a <java.level> property.

In many cases, other changes will be needed to the pom.xml file in order to use the most recent parent POM. Some of the other changes may include:

Create a pull request

Commit that change:

git add pom.xml
git commit -m "Use most recent parent pom"

Push the change to GitHub:

git push origin --set-upstream update-parent-pom
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
remote: Create a pull request for '{task-identifier}' on GitHub by visiting:
remote: https://github.com/user/your-plugin/pull/new/{task-identifier}
To github.com:user/your-plugin.git
 * [new branch]      {task-identifier} -> {task-identifier}
Branch '{task-identifier}' tracking remote branch '{task-identifier}'.

Notice that the output of the command includes the URL, which can be used to open a pull request. Copy that URL in your web browser and submit a pull request.