Force using 2.8.9+ gson version as a dependency

Mitigate https://github.com/google/gson/pull/1991

^KT-51837 Fixed
This commit is contained in:
Nikolay Krasko
2022-04-12 00:30:57 +03:00
committed by Yahor Berdnikau
parent 315ff0beeb
commit f7a53a1b24
8 changed files with 94 additions and 55 deletions
+14
View File
@@ -28,6 +28,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"])
+22
View File
@@ -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') {
+2 -2
View File
@@ -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,