diff --git a/core/build.gradle b/core/build.gradle index da9ec1f2a44..9f845707ace 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -56,6 +56,8 @@ tasks.japicmp { configurations.all { resolutionStrategy { + force 'com.fasterxml.jackson.core:jackson-annotations:2.18.4' + force 'com.fasterxml.jackson.core:jackson-core:2.18.4' force 'com.fasterxml.jackson.core:jackson-databind:2.18.4' force 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.18.4' } @@ -83,12 +85,17 @@ dependencies { api platform('com.github.docker-java:docker-java-bom:3.7.0') shaded platform('com.github.docker-java:docker-java-bom:3.7.0') - api "com.github.docker-java:docker-java-api" + api("com.github.docker-java:docker-java-api") { + exclude group: 'com.fasterxml.jackson.core', module: 'jackson-annotations' + } shaded('com.github.docker-java:docker-java-core') { exclude group: 'com.google.guava', module: 'guava' } + shaded 'com.fasterxml.jackson.core:jackson-annotations:2.18.4' + shaded 'com.fasterxml.jackson.core:jackson-core:2.18.4' + api 'com.github.docker-java:docker-java-transport-zerodep' shaded 'com.google.guava:guava:33.3.1-jre' diff --git a/core/src/jarFileTest/java/org/testcontainers/JarFileShadingTest.java b/core/src/jarFileTest/java/org/testcontainers/JarFileShadingTest.java index 8b6f380f6eb..c68865892f0 100644 --- a/core/src/jarFileTest/java/org/testcontainers/JarFileShadingTest.java +++ b/core/src/jarFileTest/java/org/testcontainers/JarFileShadingTest.java @@ -38,6 +38,20 @@ void testMetaInfServices() throws Exception { .allMatch(it -> it.startsWith("org.testcontainers.")); } + @Test + void testJacksonAnnotationsAreShaded() throws Exception { + Path jacksonAnnotations = root.resolve("org/testcontainers/shaded/com/fasterxml/jackson/annotation"); + assertThat(Files.exists(jacksonAnnotations)) + .as("Jackson annotations should be shaded to avoid classpath conflicts") + .isTrue(); + } + + @Test + void testJacksonCoreIsShaded() throws Exception { + Path jacksonCore = root.resolve("org/testcontainers/shaded/com/fasterxml/jackson/core"); + assertThat(Files.exists(jacksonCore)).as("Jackson core should be shaded to avoid classpath conflicts").isTrue(); + } + private ListAssert assertThatFileList(Path path) throws IOException { return (ListAssert) assertThat(Files.list(path)) .extracting(Path::getFileName)