Skip to content

Commit ad05650

Browse files
brharringtonrpalcolea
authored andcommitted
Update jackson alignment rule for 2.20
There was a change in 2.20.x for the `jackson-annotations` library. It no longer includes the patch version ([#294]). Add it to the exclude list to avoid trying to align with the patch versions of other jackson projects. If the other projects are aligned, `jackson-annotations` should be handled correctly with the normal dependency resolution. [#294]: FasterXML/jackson-annotations#294
1 parent b660bbb commit ad05650

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
package nebula.plugin.resolutionrules
2+
3+
import org.gradle.testkit.runner.BuildResult
4+
5+
class AlignJacksonSpec extends RulesBaseSpecification {
6+
7+
def setup() {
8+
def resolutionRulesFile = getClass().getClassLoader().getResource('align-jackson.json')
9+
buildFile << """
10+
dependencies {
11+
resolutionRules files('$resolutionRulesFile')
12+
}
13+
""".stripIndent()
14+
}
15+
16+
def 'can align jackson 2.x libraries'() {
17+
given:
18+
buildFile << """\
19+
dependencies {
20+
implementation 'com.fasterxml.jackson.core:jackson-core:2.19.1'
21+
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.17.0'
22+
implementation 'com.fasterxml.jackson.core:jackson-databind:2.18.0'
23+
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.19.0'
24+
}
25+
""".stripIndent()
26+
27+
when:
28+
BuildResult result = runWithArgumentsSuccessfully('dI', '--dependency', 'com.fasterxml.jackson')
29+
30+
then:
31+
result.output.contains('By constraint: belongs to platform aligned-platform:align-jackson-0-for-com.fasterxml.jackson.core-or-dataformat-or-datatype-or-jaxrs-or-jr-or-module:2.19.1')
32+
def alignedVersion = "2.19.1"
33+
// aligned
34+
result.output.contains("com.fasterxml.jackson.core:jackson-core:$alignedVersion\n")
35+
result.output.contains("com.fasterxml.jackson.core:jackson-annotations:$alignedVersion\n")
36+
result.output.contains("com.fasterxml.jackson.core:jackson-databind:$alignedVersion\n")
37+
result.output.contains("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:$alignedVersion\n")
38+
!result.output.contains('FAILED')
39+
}
40+
41+
def 'can align jackson 2.20.x libraries with annotations change'() {
42+
// 2.20.x dropped the patch version for the annotations library:
43+
// https://github.com/FasterXML/jackson-annotations/issues/294
44+
45+
given:
46+
buildFile << """\
47+
dependencies {
48+
implementation enforcedPlatform('com.fasterxml.jackson:jackson-bom:2.20.0')
49+
implementation 'com.fasterxml.jackson.core:jackson-core:2.20.0'
50+
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.17.0'
51+
implementation 'com.fasterxml.jackson.core:jackson-databind:2.18.0'
52+
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.19.0'
53+
}
54+
""".stripIndent()
55+
56+
when:
57+
BuildResult result = runWithArgumentsSuccessfully('dI', '--dependency', 'com.fasterxml.jackson')
58+
59+
then:
60+
result.output.contains('By constraint: belongs to platform aligned-platform:align-jackson-0-for-com.fasterxml.jackson.core-or-dataformat-or-datatype-or-jaxrs-or-jr-or-module:2.20.0')
61+
def alignedVersion = "2.20.0"
62+
def alignedVersionAnno = "2.20"
63+
// aligned
64+
result.output.contains("com.fasterxml.jackson.core:jackson-core:$alignedVersion\n")
65+
result.output.contains("com.fasterxml.jackson.core:jackson-annotations:$alignedVersionAnno\n")
66+
result.output.contains("com.fasterxml.jackson.core:jackson-databind:$alignedVersion\n")
67+
result.output.contains("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:$alignedVersion\n")
68+
!result.output.contains('FAILED')
69+
}
70+
}

src/main/resources/align-jackson.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
{
44
"group": "com\\.fasterxml\\.jackson\\.(core|dataformat|datatype|jaxrs|jr|module)",
55
"excludes": [
6+
"jackson-annotations",
67
"jackson-datatype-jdk7",
78
"jackson-module-scala_2.12.0-RC1",
89
"jackson-module-scala_2.12.0-M5",

0 commit comments

Comments
 (0)