From d743dc70ac6cbada0465ca1d10cd09e3eba41979 Mon Sep 17 00:00:00 2001 From: Yahor Berdnikau Date: Tue, 18 Jul 2023 09:58:09 +0200 Subject: [PATCH] [repo] Add version catalog for gradle-build-conventions included build --- gradle/libs.versions.toml | 20 +++++++++++ gradle/versions.properties | 3 ++ .../buildsrc-compat/build.gradle.kts | 34 +++++++------------ .../settings.gradle.kts | 20 ++--------- 4 files changed, 39 insertions(+), 38 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index a6cc0d7aaf6..db51810f329 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,12 +1,32 @@ [versions] +dexMemberList = "4.1.1" +dokka = "1.8.20" gradle-custom-user-data = "1.9" gradle-enterprise = "3.12.4" +gradle-plugin-publish = "1.0.0" # Version for foojay should be also synced with version in repo/gradle-settings-conventions/settings.gradle.kts gradle-toolchains-foojay-resolver = "0.4.0" kotlinx-serialization = "1.5.0" +shadow = "7.1.2" # should be in sync with versions.properties +spdx = "0.1.0-dev-10" +proguard = "6.2.2" +ktor = "2.0.2" # should be in sync with versions.properties +kotlinx-metadataJvm = "0.6.2" +# Forcing gson version because of https://github.com/google/gson/pull/1991 +gson = { strictly = "2.8.9" } # should be in sync with version.properties [libraries] +dexMemberList = { module = "com.jakewharton.dex:dex-member-list", version.ref = "dexMemberList" } +dokka-gradlePlugin = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref = "dokka" } gradle-customUserData-gradlePlugin = { module = "com.gradle:common-custom-user-data-gradle-plugin", version.ref = "gradle-custom-user-data" } gradle-enterprise-gradlePlugin = { module = "com.gradle:gradle-enterprise-gradle-plugin", version.ref = "gradle-enterprise" } +gradle-pluginPublish-gradlePlugin = { module = "com.gradle.publish:plugin-publish-plugin", version.ref = "gradle-plugin-publish" } gradle-toolchainsFoojayResolver-gradlePlugin = { module = "org.gradle.toolchains:foojay-resolver", version.ref = "gradle-toolchains-foojay-resolver" } kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinx-serialization" } +kotlinx-metadataJvm = { module = "org.jetbrains.kotlinx:kotlinx-metadata-jvm", version.ref = "kotlinx-metadataJvm" } +shadow-gradlePlugin = { module = "gradle.plugin.com.github.johnrengelman:shadow", version.ref = "shadow" } +spdx-gradlePlugin = { module = "org.spdx:spdx-gradle-plugin", version.ref = "spdx" } +proguard-gradlePlugin = { module = "net.sf.proguard:proguard-gradle", version.ref = "proguard" } +ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" } +ktor-client-cio = { module = "io.ktor:ktor-client-cio", version.ref = "ktor" } +gson = { module = "com.google.code.gson:gson", version.ref = "gson" } diff --git a/gradle/versions.properties b/gradle/versions.properties index 33a115bbb7b..dee1a81e913 100644 --- a/gradle/versions.properties +++ b/gradle/versions.properties @@ -9,6 +9,7 @@ versions.aalto-xml=1.3.0 versions.gradle-api=4.5.1 versions.groovy-xml=2.5.11 versions.groovy=2.5.11 +# should be in sync with libs.versions.toml versions.gson=2.8.9 versions.guava=29.0-jre versions.intellij-deps-fastutil=8.5.4-9 @@ -21,6 +22,7 @@ versions.lz4-java=1.7.1 versions.org.junit.platform=1.7.0 versions.oro=2.0.8 versions.serviceMessages=2019.1.4 +# Should be in sync with libs.versions.toml versions.shadow=7.1.2 versions.stax2-api=4.2.1 versions.streamex=0.7.2 @@ -48,6 +50,7 @@ versions.kotlinx-coroutines-core=1.5.0 versions.kotlinx-metadata-jvm=0.6.2 versions.kotlinx-metadata-klib=0.0.1-dev-10 versions.kotlinx-serialization-json=1.3.3 +# Ktor's versions should be in sync with libs.versions.toml versions.ktor-network=2.0.2 versions.ktor-utils=2.0.2 versions.ktor-server-test-host=2.0.2 diff --git a/repo/gradle-build-conventions/buildsrc-compat/build.gradle.kts b/repo/gradle-build-conventions/buildsrc-compat/build.gradle.kts index dd4e714aa4f..b3b54e70ce4 100644 --- a/repo/gradle-build-conventions/buildsrc-compat/build.gradle.kts +++ b/repo/gradle-build-conventions/buildsrc-compat/build.gradle.kts @@ -4,15 +4,11 @@ buildscript { // workaround for KGP build metrics reports: https://github.com/gradle/gradle/issues/20001 project.extensions.extraProperties["kotlin.build.report.output"] = null - val versionPropertiesFile = project.rootProject.projectDir.parentFile.resolve("../gradle/versions.properties") - val versionProperties = java.util.Properties() - versionPropertiesFile.inputStream().use { propInput -> - versionProperties.load(propInput) - } + val gsonVersion = libs.versions.gson.get() configurations.all { resolutionStrategy.eachDependency { if (requested.group == "com.google.code.gson" && requested.name == "gson") { - useVersion(versionProperties["versions.gson"] as String) + useVersion(gsonVersion) because("Force using same gson version because of https://github.com/google/gson/pull/1991") } } @@ -97,36 +93,32 @@ java { dependencies { implementation(kotlin("stdlib", embeddedKotlinVersion)) implementation("org.jetbrains.kotlin:kotlin-build-gradle-plugin:${kotlinBuildProperties.buildGradlePluginVersion}") - implementation("com.gradle.publish:plugin-publish-plugin:1.0.0") - implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.8.20") + implementation(libs.gradle.pluginPublish.gradlePlugin) + implementation(libs.dokka.gradlePlugin) + implementation(libs.spdx.gradlePlugin) + implementation(libs.dexMemberList) - implementation("org.spdx:spdx-gradle-plugin:0.1.0-dev-10") - - implementation("com.jakewharton.dex:dex-member-list:4.1.1") - - implementation("gradle.plugin.com.github.johnrengelman:shadow:${project.extra["versions.shadow"]}") { + implementation(libs.shadow.gradlePlugin) { // https://github.com/johnrengelman/shadow/issues/807 exclude("org.ow2.asm") } - implementation("net.sf.proguard:proguard-gradle:6.2.2") + implementation(libs.proguard.gradlePlugin) // Version should be in sync with /build.gradle.kts implementation("gradle.plugin.org.jetbrains.gradle.plugin.idea-ext:gradle-idea-ext:1.0.1") - implementation("io.ktor:ktor-client-core:${project.extra["versions.ktor-client-core"]}") - implementation("io.ktor:ktor-client-cio:${project.extra["versions.ktor-client-cio"]}") + implementation(libs.ktor.client.core) + implementation(libs.ktor.client.cio) - compileOnly("com.gradle:gradle-enterprise-gradle-plugin:3.12.4") + compileOnly(libs.gradle.enterprise.gradlePlugin) compileOnly(gradleApi()) - // See https://github.com/gradle/gradle/issues/22510 - implementation("org.gradle.kotlin:gradle-kotlin-dsl-plugins:2.4.1") implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:${project.bootstrapKotlinVersion}") implementation("org.jetbrains.kotlin:kotlin-stdlib:${project.bootstrapKotlinVersion}") implementation("org.jetbrains.kotlin:kotlin-reflect:${project.bootstrapKotlinVersion}") - implementation("com.google.code.gson:gson:2.8.9") // Workaround for Gradle dependency resolution error - implementation("org.jetbrains.kotlinx:kotlinx-metadata-jvm:0.6.2") + implementation(libs.gson) + implementation(libs.kotlinx.metadataJvm) } samWithReceiver { diff --git a/repo/gradle-build-conventions/settings.gradle.kts b/repo/gradle-build-conventions/settings.gradle.kts index 70dd38e8e07..a56b079aa97 100644 --- a/repo/gradle-build-conventions/settings.gradle.kts +++ b/repo/gradle-build-conventions/settings.gradle.kts @@ -21,24 +21,10 @@ plugins { id("kotlin-daemon-config") } -val versionPropertiesFile = File(rootProject.projectDir.parentFile, "../gradle/versions.properties") -val versionProperties = Properties() -versionPropertiesFile.bufferedReader().use { - versionProperties.load(it) -} dependencyResolutionManagement { - components { - withModule("com.google.code.gson:gson") { - allVariants { - withDependencies { - add("com.google.code.gson:gson") { - version { - require(versionProperties["versions.gson"] as String) - } - because("Force using same gson version because of https://github.com/google/gson/pull/1991") - } - } - } + versionCatalogs { + create("libs") { + from(files("../../gradle/libs.versions.toml")) } } }