From 342051e11dae4937f45ff6ae651fbfb89ee79d20 Mon Sep 17 00:00:00 2001 From: Lai Jiang Date: Tue, 25 Jul 2023 11:09:38 -0400 Subject: [PATCH] Fix the build due to jackson-core incompatibility (#2085) --- java_common.gradle | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/java_common.gradle b/java_common.gradle index 3dfbbcb4a..4b21c74b0 100644 --- a/java_common.gradle +++ b/java_common.gradle @@ -70,6 +70,27 @@ configurations { } } +// Custom resolution strategy to get around tricky dependency issues. +configurations.all { + // jackson-core is a transitive dependency that we cannot explicity specify + // versions for, without triggering linter alerts. Even though the lockfiles + // lock it to a lower version, Gradle will first try to resolve the + // dependency tree based on what is available in the Maven repo before + // applying any dependency locks. The newer version (v2.15) of jackson-core + // results in a build failure for pre-7.6 Gradle versions during that stage. + // This custom resolution strategy will modify the dependency tree as it was + // being built and prevent Gradle from even trying v2.15. + // See: https://github.com/FasterXML/jackson-core/issues/955 + // TODO: Remove the custom stragegy after we upgrade to Gradle 7.6+. + resolutionStrategy.eachDependency { DependencyResolveDetails details -> + if (details.requested.group == 'com.fasterxml.jackson.core' + && details.requested.name == 'jackson-core' + && details.requested.version.startsWith('2.15')) { + details.useVersion '2.14.2' + } + } +} + dependencies { // compatibility with Java 8 errorprone("com.google.errorprone:error_prone_core:2.3.4")