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.
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
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.
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
java.level
propertyIf 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:
Resolve spotbugs warnings
Resolve upper bounds dependency warnings
Prevent cross-site scripting by escaping expressions in Jelly pages
Resolve ambiguous property encodings by converting translations with native2ascii
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 '{task-identifier}' on GitHub by visiting: remote: https://github.com/user/your-plugin/pull/new/{task-identifier} remote: 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.