gradle: Migrate to recommended method of build version catalogs

This fixes broken AGP Upgrade Assistant in Android Studio as well as detects
the version catalog files in Android view.

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
Aayush Gupta 2024-05-30 11:37:16 +05:30
parent 18c85a76c7
commit 6953f154b3
8 changed files with 47 additions and 58 deletions

View file

@ -7,8 +7,8 @@ import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import java.io.ByteArrayOutputStream import java.io.ByteArrayOutputStream
plugins { plugins {
id("com.android.application") alias(libs.plugins.android.application)
kotlin("android") alias(libs.plugins.jetbrains.kotlin.android)
} }
val gitDescribe = { val gitDescribe = {

View file

@ -12,13 +12,13 @@ buildscript {
} }
plugins { plugins {
id("com.android.application") version plugins.versions.androidGradle apply false alias(libs.plugins.android.application) apply false
id("com.android.library") version plugins.versions.androidGradle apply false alias(libs.plugins.android.library) apply false
id("com.google.protobuf") version plugins.versions.protobuf apply false alias(libs.plugins.google.protobuf) apply false
id("org.jetbrains.kotlin.android") version plugins.versions.kotlin apply false alias(libs.plugins.jetbrains.kotlin.android) apply false
id("org.jetbrains.kotlin.kapt") version plugins.versions.kotlin apply false alias(libs.plugins.jetbrains.kotlin.kapt) apply false
id("org.jetbrains.dokka") version plugins.versions.kotlin apply false alias(libs.plugins.jetbrains.dokka) apply false
id("org.jlleitschuh.gradle.ktlint") version plugins.versions.ktlint apply false alias(libs.plugins.jlleitschuh.ktlint) apply false
} }
tasks.register("clean", Delete::class) { tasks.register("clean", Delete::class) {

View file

@ -1,20 +0,0 @@
#
# SPDX-FileCopyrightText: 2023 The Calyx Institute
# SPDX-License-Identifier: Apache-2.0
#
[versions]
# We need to enforce that the versions we use are the same as AOSP to ensure compatibility.
# 1.3.61 Android 11
# 1.4.30 Android 12
# 1.6.10 Android 13
# 1.7.20 Android 13 (QPR2)
# 1.8.10 Android 14
# 1.9.0 Android 14 (QPR2)
# Check:
# https://android.googlesource.com/platform/external/kotlinc/+/refs/tags/android-14.0.0_r29/build.txt
kotlin = "1.9.0"
androidGradle = "8.4.1"
protobuf = "0.9.4"
ktlint = "11.5.0"

View file

@ -6,8 +6,8 @@ import java.io.FileInputStream
import java.util.Properties import java.util.Properties
plugins { plugins {
id("com.android.application") alias(libs.plugins.android.application)
id("org.jetbrains.kotlin.android") alias(libs.plugins.jetbrains.kotlin.android)
} }
android { android {

View file

@ -1,11 +1,14 @@
# #
# SPDX-FileCopyrightText: 2023 The Calyx Institute # SPDX-FileCopyrightText: 2024 The Calyx Institute
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
# #
[metadata]
[versions] [versions]
# Gradle plugin versions
androidGradlePlugin = "8.4.1"
protobufPlugin = "0.9.4"
ktlint = "11.5.0"
# Android SDK versions # Android SDK versions
compileSdk = "34" compileSdk = "34"
minSdk = "33" minSdk = "33"
@ -21,9 +24,14 @@ espresso = "3.4.0"
# We use "strictly" to enforce the version cannot be overriden by transitive dependencies. # We use "strictly" to enforce the version cannot be overriden by transitive dependencies.
# We need to enforce that the versions we use are the same as AOSP to ensure compatibility. # We need to enforce that the versions we use are the same as AOSP to ensure compatibility.
# Kotlin versions # 1.3.61 Android 11
# https://android.googlesource.com/platform/external/kotlinc/+/refs/tags/android-14.0.0_r29/build.txt # 1.4.30 Android 12
aosp-kotlin = { strictly = "1.9.0" } # 1.6.10 Android 13
# 1.7.20 Android 13 (QPR2)
# 1.8.10 Android 14
# 1.9.0 Android 14 (QPR2)
# Check: https://android.googlesource.com/platform/external/kotlinc/+/refs/tags/android-14.0.0_r29/build.txt
kotlin = { strictly = "1.9.0" }
# Lint versions # Lint versions
lint-rules = { strictly = "0.1.0" } lint-rules = { strictly = "0.1.0" }
@ -64,9 +72,9 @@ androidx-work-runtime = { strictly = "2.10.0-alpha01" }
[libraries] [libraries]
# Kotlin standard dependencies # Kotlin standard dependencies
kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "aosp-kotlin" } kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" }
kotlin-stdlib-jdk8 = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "aosp-kotlin" } kotlin-stdlib-jdk8 = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "kotlin" }
kotlin-stdlib-common = { module = "org.jetbrains.kotlin:kotlin-stdlib-common", version.ref = "aosp-kotlin" } kotlin-stdlib-common = { module = "org.jetbrains.kotlin:kotlin-stdlib-common", version.ref = "kotlin" }
# Lint dependencies # Lint dependencies
thirdegg-lint-rules = { module = "com.github.thirdegg:lint-rules", version.ref = "lint-rules" } thirdegg-lint-rules = { module = "com.github.thirdegg:lint-rules", version.ref = "lint-rules" }
@ -96,3 +104,12 @@ androidx-room-runtime = { module = "androidx.room:room-runtime", version.ref = "
[bundles] [bundles]
kotlin = ["kotlin-stdlib", "kotlin-stdlib-jdk8", "kotlin-stdlib-common"] kotlin = ["kotlin-stdlib", "kotlin-stdlib-jdk8", "kotlin-stdlib-common"]
coroutines = ["kotlinx-coroutines-core-jvm", "kotlinx-coroutines-android"] coroutines = ["kotlinx-coroutines-core-jvm", "kotlinx-coroutines-android"]
[plugins]
android-application = { id = "com.android.application", version.ref = "androidGradlePlugin" }
android-library = { id = "com.android.library", version.ref = "androidGradlePlugin" }
google-protobuf = { id = "com.google.protobuf", version.ref = "protobufPlugin" }
jetbrains-dokka = { id = "org.jetbrains.dokka", version.ref = "kotlin" }
jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
jetbrains-kotlin-kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kotlin" }
jlleitschuh-ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlint" }

View file

@ -32,14 +32,6 @@ dependencyResolutionManagement {
mavenCentral() mavenCentral()
maven("https://jitpack.io") maven("https://jitpack.io")
} }
versionCatalogs {
create("libs") {
from(files("build.libs.toml"))
}
create("plugins") {
from(files("build.plugins.toml"))
}
}
} }
rootProject.name = "Seedvault" rootProject.name = "Seedvault"

View file

@ -4,10 +4,10 @@
*/ */
plugins { plugins {
id("com.android.application") alias(libs.plugins.android.application)
id("com.google.protobuf") alias(libs.plugins.google.protobuf)
id("org.jetbrains.kotlin.android") alias(libs.plugins.jetbrains.kotlin.android)
id("org.jetbrains.kotlin.kapt") alias(libs.plugins.jetbrains.kotlin.kapt)
} }
android { android {

View file

@ -5,11 +5,11 @@ import com.google.protobuf.gradle.id
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
plugins { plugins {
id("com.google.protobuf") alias(libs.plugins.android.library)
id("org.jetbrains.kotlin.kapt") alias(libs.plugins.google.protobuf)
id("org.jetbrains.dokka") alias(libs.plugins.jetbrains.kotlin.android)
id("com.android.library") alias(libs.plugins.jetbrains.kotlin.kapt)
kotlin("android") alias(libs.plugins.jetbrains.dokka)
} }
android { android {
@ -98,7 +98,7 @@ dependencies {
lintChecks(libs.thirdegg.lint.rules) lintChecks(libs.thirdegg.lint.rules)
testImplementation("junit:junit:${libs.versions.junit4.get()}") testImplementation("junit:junit:${libs.versions.junit4.get()}")
testImplementation("io.mockk:mockk:${libs.versions.mockk.get()}") testImplementation("io.mockk:mockk:${libs.versions.mockk.get()}")
testImplementation("org.jetbrains.kotlin:kotlin-test-junit:${libs.versions.aosp.kotlin.get()}") testImplementation("org.jetbrains.kotlin:kotlin-test-junit:${libs.versions.kotlin.get()}")
androidTestImplementation("androidx.test.ext:junit:1.1.5") androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation( androidTestImplementation(
"androidx.test.espresso:espresso-core:${libs.versions.espresso.get()}" "androidx.test.espresso:espresso-core:${libs.versions.espresso.get()}"