From f9e00b0eb21223ddc3aa35a76cd4e65e67bbb99b Mon Sep 17 00:00:00 2001 From: Yahor Berdnikau Date: Thu, 23 Jun 2022 21:00:39 +0200 Subject: [PATCH] Fix all publications contain dependencyManagement Only apply gson constraint for those modules which adds dependency on gson. --- .../main/kotlin/common-configuration.gradle.kts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/buildSrc/src/main/kotlin/common-configuration.gradle.kts b/buildSrc/src/main/kotlin/common-configuration.gradle.kts index 1d4acd86cb3..2f931e000da 100644 --- a/buildSrc/src/main/kotlin/common-configuration.gradle.kts +++ b/buildSrc/src/main/kotlin/common-configuration.gradle.kts @@ -12,11 +12,17 @@ val gsonVersion = rootProject.extra["versions.gson"] as String dependencies { constraints { configurations.all { - this@constraints.add(name, "com.google.code.gson:gson") { - version { - require(gsonVersion) + if (isCanBeResolved) { + allDependencies.configureEach { + if (group == "com.google.code.gson" && name == "gson") { + this@constraints.add(this@all.name, "com.google.code.gson:gson") { + version { + require(gsonVersion) + } + because("Force using same gson version because of https://github.com/google/gson/pull/1991") + } + } } - because("Force using same gson version because of https://github.com/google/gson/pull/1991") } } }