Skip to content

Commit

Permalink
Update bom instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
timja committed Apr 20, 2020
1 parent 4116d47 commit fdfec96
Showing 1 changed file with 2 additions and 40 deletions.
Expand Up @@ -12,7 +12,7 @@ This section details some ways to simplify the management of dependency versions

== Jenkins Core BOM

Since version 2.195, Jenkins Core provides a link:https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Importing_Dependencies[Maven Bill Of Materials (BOM)] that centrally defines versions of various libraries used by Jenkins.
Since version 2.195 (and LTS version 2.164.x) Jenkins Core provides a link:https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Importing_Dependencies[Maven Bill Of Materials (BOM)] that centrally defines versions of various libraries used by Jenkins.
If you are using Maven to build your plugin, then you can simplify dependency management by importing this BOM, at `jenkins.version`.
Then, dependency versions will automatically be synchronised with whatever version of Jenkins you are building against.
This can help to avoid build errors like:
Expand Down Expand Up @@ -43,45 +43,7 @@ What this error is saying is that there is a conflict between the versions of `c
Without using the BOM, you would need to go and update the dependencies in your plugin to match those required by Jenkins, and then keep changing these as your `jenkins.version` changes.
With the BOM all you have to do is import the link:https://github.com/jenkinsci/jenkins/blob/master/bom/pom.xml[jenkins-bom] for the version of Jenkins you are building against, and the versions of these and other common dependencies will be matched to that version of Jenkins.

To use the Jenkins Core BOM in your plugin, just import the BOM in your plugin's POM and set `slf4jVersion` appropriately.
For example:

[source, xml]
----
<properties>
<slf4jVersion>1.7.26</slf4jVersion>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jenkins-ci.main</groupId>
<artifactId>jenkins-bom</artifactId>
<version>${jenkins.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
----

Or, if you are using the plugin-pom (3.52 or later) as the parent, then things are even easier as there is a profile that will manage this for you.
The default behaviour of `plugin-pom` is to _not_ use the BOM, but you can switch on BOM support by setting the Maven property `use-jenkins-bom`.
For example:

[source]
----
mvn -Djenkins.version=2.195 -Duse-jenkins-bom package
----

This will use the Core BOM for Jenkins 2.195.

If you want this to become the default for building your plugin, you can avoid having to specify the `use-jenkins-bom` property on the command line every time by putting it into a link:https://maven.apache.org/configure.html[.mvn/maven.config] file in the root of your plugin project:

[source]
----
-Duse-jenkins-bom
----

To use the Jenkins Core BOM in your plugin, just use plugin-pom (4.0 or later).

== Jenkins Plugin BOM

Expand Down

0 comments on commit fdfec96

Please sign in to comment.