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 Java 11 and with Java 17. 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 Java 11.

Update parent POM

Use Apache Maven to update the parent POM:

$ mvn -ntp versions:update-parent
[INFO] Scanning for projects...
[INFO]
[INFO] ---------------< org.jenkins-ci.plugins:your-plugin >----------------
[INFO] Building Schedule Build Plugin 1.0.0-SNAPSHOT
[INFO] --------------------------------[ hpi ]---------------------------------
[INFO]
[INFO] --- versions-maven-plugin:2.8.1:update-parent (default-cli) @ your-plugin ---
[INFO] Updating parent from 3.50 to 4.47
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[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 @@
   <parent>
     <groupId>org.jenkins-ci.plugins</groupId>
     <artifactId>plugin</artifactId>
-    <version>3.50</version>
+    <version>4.47</version>
   </parent>

   <artifactId>your-plugin</artifactId>

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:
remote: Create a pull request for 'update-parent-pom' on GitHub by visiting:
remote: https://github.com/user/your-plugin/pull/new/update-parent-pom
remote:
To github.com:user/your-plugin.git
 * [new branch]      update-parent-pom -> update-parent-pom
Branch 'update-parent-pom' tracking remote branch 'update-parent-pom'.

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.