Skip to content

Commit 8ff30c3

Browse files
committed
Shade jackson-annotations and jackson-core to fix classpath conflicts (#11236)
1 parent f2a6fe9 commit 8ff30c3

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

core/build.gradle

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ tasks.japicmp {
5656

5757
configurations.all {
5858
resolutionStrategy {
59+
force 'com.fasterxml.jackson.core:jackson-annotations:2.18.4'
60+
force 'com.fasterxml.jackson.core:jackson-core:2.18.4'
5961
force 'com.fasterxml.jackson.core:jackson-databind:2.18.4'
6062
force 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.18.4'
6163
}
@@ -83,12 +85,17 @@ dependencies {
8385
api platform('com.github.docker-java:docker-java-bom:3.7.0')
8486
shaded platform('com.github.docker-java:docker-java-bom:3.7.0')
8587

86-
api "com.github.docker-java:docker-java-api"
88+
api("com.github.docker-java:docker-java-api") {
89+
exclude group: 'com.fasterxml.jackson.core', module: 'jackson-annotations'
90+
}
8791

8892
shaded('com.github.docker-java:docker-java-core') {
8993
exclude group: 'com.google.guava', module: 'guava'
9094
}
9195

96+
shaded 'com.fasterxml.jackson.core:jackson-annotations:2.18.4'
97+
shaded 'com.fasterxml.jackson.core:jackson-core:2.18.4'
98+
9299
api 'com.github.docker-java:docker-java-transport-zerodep'
93100

94101
shaded 'com.google.guava:guava:33.3.1-jre'

core/src/jarFileTest/java/org/testcontainers/JarFileShadingTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,20 @@ void testMetaInfServices() throws Exception {
3838
.allMatch(it -> it.startsWith("org.testcontainers."));
3939
}
4040

41+
@Test
42+
void testJacksonAnnotationsAreShaded() throws Exception {
43+
Path jacksonAnnotations = root.resolve("org/testcontainers/shaded/com/fasterxml/jackson/annotation");
44+
assertThat(Files.exists(jacksonAnnotations))
45+
.as("Jackson annotations should be shaded to avoid classpath conflicts")
46+
.isTrue();
47+
}
48+
49+
@Test
50+
void testJacksonCoreIsShaded() throws Exception {
51+
Path jacksonCore = root.resolve("org/testcontainers/shaded/com/fasterxml/jackson/core");
52+
assertThat(Files.exists(jacksonCore)).as("Jackson core should be shaded to avoid classpath conflicts").isTrue();
53+
}
54+
4155
private ListAssert<String> assertThatFileList(Path path) throws IOException {
4256
return (ListAssert) assertThat(Files.list(path))
4357
.extracting(Path::getFileName)

0 commit comments

Comments
 (0)