diff --git a/build.gradle.kts b/build.gradle.kts
index d0588dd9cedeb..fa79c4ccf0738 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -34,6 +34,20 @@ buildscript {
classpath(kotlin("serialization", bootstrapKotlinVersion))
classpath("org.jetbrains.dokka:dokka-gradle-plugin:0.9.17")
}
+
+ val versionPropertiesFile = project.rootProject.projectDir.resolve("gradle/versions.properties")
+ val versionProperties = java.util.Properties()
+ versionPropertiesFile.inputStream().use { propInput ->
+ versionProperties.load(propInput)
+ }
+ configurations.all {
+ resolutionStrategy.eachDependency {
+ if (requested.group == "com.google.code.gson" && requested.name == "gson") {
+ useVersion(versionProperties["versions.gson"] as String)
+ because("Force using same gson version because of https://github.com/google/gson/pull/1991")
+ }
+ }
+ }
}
plugins {
diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts
index f93eb55e22733..e7b7e9cbdc8a3 100644
--- a/buildSrc/build.gradle.kts
+++ b/buildSrc/build.gradle.kts
@@ -26,6 +26,20 @@ buildscript {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${project.bootstrapKotlinVersion}")
classpath("org.jetbrains.kotlin:kotlin-sam-with-receiver:${project.bootstrapKotlinVersion}")
}
+
+ val versionPropertiesFile = project.rootProject.projectDir.parentFile.resolve("gradle/versions.properties")
+ val versionProperties = java.util.Properties()
+ versionPropertiesFile.inputStream().use { propInput ->
+ versionProperties.load(propInput)
+ }
+ configurations.all {
+ resolutionStrategy.eachDependency {
+ if (requested.group == "com.google.code.gson" && requested.name == "gson") {
+ useVersion(versionProperties["versions.gson"] as String)
+ because("Force using same gson version because of https://github.com/google/gson/pull/1991")
+ }
+ }
+ }
}
logger.info("buildSrcKotlinVersion: " + extra["bootstrapKotlinVersion"])
diff --git a/buildSrc/settings.gradle b/buildSrc/settings.gradle
index 691dfbb11f8ae..c01fe03c4573c 100644
--- a/buildSrc/settings.gradle
+++ b/buildSrc/settings.gradle
@@ -11,6 +11,28 @@ pluginManagement {
}
}
+File versionPropertiesFile = new File(rootProject.projectDir.parentFile, "gradle/versions.properties")
+def versionProperties = new Properties()
+versionPropertiesFile.withInputStream {
+ versionProperties.load(it)
+}
+dependencyResolutionManagement {
+ components {
+ withModule("com.google.code.gson:gson") {
+ allVariants {
+ withDependencies {
+ add("com.google.code.gson:gson") {
+ version {
+ it.require(versionProperties['versions.gson'])
+ }
+ because("Force using same gson version because of https://github.com/google/gson/pull/1991")
+ }
+ }
+ }
+ }
+ }
+}
+
buildscript {
repositories {
if (cacheRedirectorEnabled == 'true') {
diff --git a/buildSrc/src/main/kotlin/dependencies.kt b/buildSrc/src/main/kotlin/dependencies.kt
index a9a769f54c8d9..4dd430d047de4 100644
--- a/buildSrc/src/main/kotlin/dependencies.kt
+++ b/buildSrc/src/main/kotlin/dependencies.kt
@@ -55,12 +55,12 @@ fun Project.commonDependency(group: String, artifact: String, vararg suffixesAnd
return "$group:$artifact${artifactSuffixes.joinToString("")}:${commonDependencyVersion(group, artifact)}${classifiers.joinToString("")}"
}
-fun Project.commonDependencyVersion(group: String, artifact: String) =
+fun Project.commonDependencyVersion(group: String, artifact: String): String =
when {
rootProject.extra.has("versions.$artifact") -> rootProject.extra["versions.$artifact"]
rootProject.extra.has("versions.$group") -> rootProject.extra["versions.$group"]
else -> throw GradleException("Neither versions.$artifact nor versions.$group is defined in the root project's extra")
- }
+ } as String
fun Project.preloadedDeps(
vararg artifactBaseNames: String,
diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml
index 1f28256941334..7b3b52f50b38d 100644
--- a/gradle/verification-metadata.xml
+++ b/gradle/verification-metadata.xml
@@ -1435,52 +1435,10 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
diff --git a/gradle/versions.properties b/gradle/versions.properties
index 8a5481a0d7eae..5b228b44a045a 100644
--- a/gradle/versions.properties
+++ b/gradle/versions.properties
@@ -12,7 +12,7 @@ versions.commons-lang=2.4
versions.gradle-api=4.5.1
versions.groovy-xml=2.5.11
versions.groovy=2.5.11
-versions.gson=2.8.6
+versions.gson=2.8.9
versions.guava=29.0-jre
versions.intellij-deps-fastutil=8.4.1-4
versions.jdom=2.0.6
diff --git a/kotlin-native/gradle/kotlinGradlePlugin.gradle b/kotlin-native/gradle/kotlinGradlePlugin.gradle
index 6fb05bd923e71..fba4bf9b2b37e 100644
--- a/kotlin-native/gradle/kotlinGradlePlugin.gradle
+++ b/kotlin-native/gradle/kotlinGradlePlugin.gradle
@@ -10,6 +10,21 @@ project.buildscript.repositories {
mavenCentral()
}
+File versionPropertiesFile = new File(rootProject.projectDir, "gradle/versions.properties")
+def versionProperties = new Properties()
+versionPropertiesFile.withInputStream {
+ versionProperties.load(it)
+}
+
+project.buildscript.configurations.all {
+ resolutionStrategy.eachDependency {
+ if (requested.group == "com.google.code.gson" && requested.name == "gson") {
+ useVersion(versionProperties['versions.gson'])
+ because("Force using same gson version because of https://github.com/google/gson/pull/1991")
+ }
+ }
+}
+
project.buildscript.dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${project.bootstrapKotlinVersion}"
}
diff --git a/settings.gradle b/settings.gradle
index 2ff702a8f4bd1..16266af65ccbf 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -38,6 +38,28 @@ plugins {
id "com.gradle.common-custom-user-data-gradle-plugin" version "1.4" apply false
}
+File versionPropertiesFile = new File(rootProject.projectDir, "gradle/versions.properties")
+def versionProperties = new Properties()
+versionPropertiesFile.withInputStream {
+ versionProperties.load(it)
+}
+dependencyResolutionManagement {
+ components {
+ withModule("com.google.code.gson:gson") {
+ allVariants {
+ withDependencies {
+ add("com.google.code.gson:gson") {
+ version {
+ it.require(versionProperties['versions.gson'])
+ }
+ because("Force using same gson version because of https://github.com/google/gson/pull/1991")
+ }
+ }
+ }
+ }
+ }
+}
+
def buildProperties = BuildPropertiesKt.getKotlinBuildPropertiesForSettings(settings)
if (buildProperties.buildScanServer != null) {