|
| 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 | +} |
0 commit comments