Skip to content

Commit

Permalink
Upgrade Jackson to 2.12.2 (#10288)
Browse files Browse the repository at this point in the history
* Adds a jackson.version property to simplify managing the version
* Make sure the specified version is used as add-on dependency by excluding Jackson from transitive dependencies
* Use openhab.tp-jackson feature with dynamodb
* Remove jackson-dataformat-cbor dependency from features which is now also provided by the openhab.tp-jackson feature

Signed-off-by: Wouter Born <github@maindrain.net>
  • Loading branch information
wborn authored Mar 7, 2021
1 parent f2eea9e commit 051c764
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 8 deletions.
7 changes: 6 additions & 1 deletion bundles/org.openhab.binding.chromecast/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

<properties>
<dep.noembedding>jackson-core,jackson-annotations,jackson-databind</dep.noembedding>
<jackson.version>2.9.10</jackson.version>
</properties>

<dependencies>
Expand All @@ -25,6 +24,12 @@
<artifactId>api-v2</artifactId>
<version>0.11.3</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.protobuf</groupId>
Expand Down
7 changes: 6 additions & 1 deletion bundles/org.openhab.binding.icalendar/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
<name>openHAB Add-ons :: Bundles :: iCalendar Binding</name>
<properties>
<dep.noembedding>jackson-core,jackson-annotations,jackson-databind</dep.noembedding>
<jackson.version>2.10.3</jackson.version>
</properties>
<dependencies>
<!-- own dependencies -->
Expand All @@ -20,6 +19,12 @@
<artifactId>biweekly</artifactId>
<version>0.6.4</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- dependencies of biweekly -->
<dependency>
Expand Down
25 changes: 21 additions & 4 deletions bundles/org.openhab.persistence.dynamodb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<name>openHAB Add-ons :: Bundles :: Persistence Service :: DynamoDB</name>

<properties>
<dep.noembedding>jackson-core,jackson-annotations,jackson-databind,jackson-dataformat-cbor</dep.noembedding>
<bnd.importpackage>!com.amazonaws.*,!org.joda.convert.*,!com.sun.org.apache.xpath.*,!kotlin,!org.apache.log.*,!org.bouncycastle.*,!org.apache.avalon.*</bnd.importpackage>
</properties>

Expand All @@ -24,6 +25,16 @@
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-core</artifactId>
<version>1.11.213</version>
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
Expand All @@ -47,6 +58,12 @@
<groupId>com.amazonaws</groupId>
<artifactId>jmespath-java</artifactId>
<version>1.11.213</version>
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
<dependency>
Expand Down Expand Up @@ -91,25 +108,25 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.6.0</version>
<version>${jackson.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.6.7</version>
<version>${jackson.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.6.7.1</version>
<version>${jackson.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.dataformat/jackson-dataformat-cbor -->
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-cbor</artifactId>
<version>2.6.7</version>
<version>${jackson.version}</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

<feature name="openhab-persistence-dynamodb" description="DynamoDB Persistence" version="${project.version}">
<feature>openhab-runtime-base</feature>
<feature dependency="true">openhab.tp-jackson</feature>
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.persistence.dynamodb/${project.version}</bundle>
<configfile finalname="${openhab.conf}/services/dynamodb.cfg" override="false">mvn:${project.groupId}/org.openhab.addons.features.karaf.openhab-addons-external/${project.version}/cfg/dynamodb</configfile>
</feature>
Expand Down
2 changes: 1 addition & 1 deletion bundles/org.openhab.transform.jinja/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.10</version>
<version>${jackson.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<feature name="openhab-voice-pollytts" description="Polly Text-to-Speech" version="${project.version}">
<feature>openhab-runtime-base</feature>
<feature dependency="true">openhab.tp-jackson</feature>
<bundle dependency="true">mvn:com.fasterxml.jackson.dataformat/jackson-dataformat-cbor/2.9.9</bundle>
<bundle dependency="true">mvn:org.apache.httpcomponents/httpcore-osgi/4.4.9</bundle>
<bundle dependency="true">mvn:org.apache.httpcomponents/httpclient-osgi/4.5.5</bundle>
<bundle dependency="true">mvn:org.openhab.osgiify/com.amazonaws.aws-java-sdk-core/1.11.490</bundle>
Expand Down
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
<bnd.version>5.3.0</bnd.version>
<commons.net.version>3.7.2</commons.net.version>
<eea.version>2.2.1</eea.version>
<jackson.version>2.12.2</jackson.version>
<karaf.version>4.2.7</karaf.version>
<sat.version>0.10.0</sat.version>
<slf4j.version>1.7.21</slf4j.version>
Expand Down

4 comments on commit 051c764

@ssalonen
Copy link
Contributor

@ssalonen ssalonen commented on 051c764 Mar 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wborn I am not fully understanding this bit.

  • Make sure the specified version is used as add-on dependency by excluding Jackson from transitive dependencies

Specifically commenting on dynamodb pom.xml <exclusions>. Is this not unnecessary since jackson dependencies are also specified as direct dependencies? Maven should therefore pick the correct version as described in https://stackoverflow.com/a/47104330

Would you agree?

I need to work on the dependencies again in #9937 since the whole sdk is updated.

@wborn
Copy link
Member Author

@wborn wborn commented on 051c764 Mar 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No the version is resolved based on the order of how dependencies are declared in the POM.
So I excluded it so the order no longer matters and it will always use our version, i.e. the version provided by the Karaf feature.
That way you are guaranteed that you always use the same Jackson version when writing tests, debugging in Eclipse or running the binding with Karaf.

@ssalonen
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wborn this is not how it is documented in https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html

According to the docs, the order matters only in tie-situations:

That is, it uses the version of the closest dependency to your project in the tree of dependencies. You can always guarantee a version by declaring it explicitly in your project's POM. Note that if two dependency versions are at the same depth in the dependency tree, the first declaration wins.

I can do some experiments as well and report here.

@wborn
Copy link
Member Author

@wborn wborn commented on 051c764 Mar 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC I just looked at how the dependencies were resolved in Eclipse which may have its own opinion about this. 😉

Please sign in to comment.