From 3fb1173d3f00c9381101425fe9fc4f431c567c86 Mon Sep 17 00:00:00 2001 From: Colin Lee Date: Fri, 4 Nov 2022 14:10:26 -0500 Subject: [PATCH] Introduce Gradle version catalogs for versioning (#2745) * Introduce Gradle version catalogs for versioning * Correct some versions for version catalogs --- app/build.gradle | 125 ++++++++++---------------------- build.gradle | 6 +- gradle/libs.versions.toml | 148 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 190 insertions(+), 89 deletions(-) create mode 100644 gradle/libs.versions.toml diff --git a/app/build.gradle b/app/build.gradle index 806f25c63..bc60e6533 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -92,110 +92,63 @@ android { } } -ext.coroutinesVersion = "1.6.4" -ext.lifecycleVersion = "2.5.1" -ext.roomVersion = '2.4.3' -ext.retrofitVersion = '2.9.0' -ext.okhttpVersion = '4.10.0' -ext.glideVersion = '4.13.2' -ext.daggerVersion = '2.43.2' -ext.materialdrawerVersion = '8.4.5' -ext.emoji2_version = '1.1.0' -ext.filemojicompat_version = '3.2.3' - -// if libraries are changed here, they should also be changed in LicenseActivity +// library versions are in PROJECT_ROOT/gradle/libs.versions.toml dependencies { - implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutinesVersion" - implementation "org.jetbrains.kotlinx:kotlinx-coroutines-rx3:$coroutinesVersion" + implementation libs.kotlinx.coroutines.android + implementation libs.kotlinx.coroutines.rx3 - implementation "androidx.core:core-ktx:1.9.0" - implementation "androidx.appcompat:appcompat:1.5.1" - implementation "androidx.activity:activity-ktx:1.6.0" - implementation "androidx.fragment:fragment-ktx:1.5.3" - implementation "androidx.browser:browser:1.4.0" - implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0" - implementation "androidx.recyclerview:recyclerview:1.2.1" - implementation "androidx.exifinterface:exifinterface:1.3.4" - implementation "androidx.cardview:cardview:1.0.0" - implementation "androidx.preference:preference-ktx:1.2.0" - implementation "androidx.sharetarget:sharetarget:1.2.0" - implementation "androidx.emoji2:emoji2:$emoji2_version" - implementation "androidx.emoji2:emoji2-views:$emoji2_version" - implementation "androidx.emoji2:emoji2-views-helper:$emoji2_version" - implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycleVersion" - implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycleVersion" - implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycleVersion" - implementation "androidx.lifecycle:lifecycle-reactivestreams-ktx:$lifecycleVersion" - implementation "androidx.constraintlayout:constraintlayout:2.1.4" - implementation "androidx.paging:paging-runtime-ktx:3.1.1" - implementation "androidx.viewpager2:viewpager2:1.0.0" - implementation "androidx.work:work-runtime:2.7.1" - implementation "androidx.room:room-ktx:$roomVersion" - implementation "androidx.room:room-paging:$roomVersion" - kapt "androidx.room:room-compiler:$roomVersion" - implementation 'androidx.core:core-splashscreen:1.0.0' + implementation libs.bundles.androidx + implementation libs.bundles.room + kapt libs.androidx.room.compiler - implementation "com.google.android.material:material:1.6.1" + implementation libs.android.material - implementation "com.google.code.gson:gson:2.9.0" + implementation libs.gson - implementation "com.squareup.retrofit2:retrofit:$retrofitVersion" - implementation "com.squareup.retrofit2:converter-gson:$retrofitVersion" - implementation "com.squareup.retrofit2:adapter-rxjava3:$retrofitVersion" - implementation "at.connyduck:networkresult-calladapter:1.0.0" + implementation libs.bundles.retrofit + implementation libs.networkresult.calladapter - implementation "com.squareup.okhttp3:okhttp:$okhttpVersion" - implementation "com.squareup.okhttp3:logging-interceptor:$okhttpVersion" + implementation libs.bundles.okhttp - implementation "org.conscrypt:conscrypt-android:2.5.2" + implementation libs.conscrypt.android - implementation "com.github.bumptech.glide:glide:$glideVersion" - implementation "com.github.bumptech.glide:okhttp3-integration:$glideVersion" - kapt "com.github.bumptech.glide:compiler:$glideVersion" + implementation libs.bundles.glide + kapt libs.glide.compiler - implementation "com.github.penfeizhou.android.animation:glide-plugin:2.23.0" + implementation libs.bundles.rxjava3 - implementation "io.reactivex.rxjava3:rxjava:3.1.3" - implementation "io.reactivex.rxjava3:rxandroid:3.0.0" - implementation "io.reactivex.rxjava3:rxkotlin:3.0.1" + implementation libs.bundles.autodispose - implementation "com.uber.autodispose2:autodispose-androidx-lifecycle:2.1.1" - implementation "com.uber.autodispose2:autodispose:2.1.1" + implementation libs.bundles.dagger + kapt libs.bundles.dagger.processors - implementation "com.google.dagger:dagger:$daggerVersion" - kapt "com.google.dagger:dagger-compiler:$daggerVersion" - implementation "com.google.dagger:dagger-android:$daggerVersion" - implementation "com.google.dagger:dagger-android-support:$daggerVersion" - kapt "com.google.dagger:dagger-android-processor:$daggerVersion" + implementation libs.sparkbutton - implementation "com.github.connyduck:sparkbutton:4.1.0" + implementation libs.photoview - implementation "com.github.chrisbanes:PhotoView:2.3.0" + implementation libs.bundles.material.drawer + implementation libs.material.typeface, { + artifact { + type = "aar" + } + } - implementation "com.mikepenz:materialdrawer:$materialdrawerVersion" - implementation "com.mikepenz:materialdrawer-iconics:$materialdrawerVersion" - implementation 'com.mikepenz:google-material-typeface:4.0.0.2-kotlin@aar' + implementation libs.image.cropper - implementation "com.github.CanHub:Android-Image-Cropper:4.3.1" + implementation libs.bundles.filemojicompat - implementation "de.c1710:filemojicompat-ui:$filemojicompat_version" - implementation "de.c1710:filemojicompat:$filemojicompat_version" - implementation "de.c1710:filemojicompat-defaults:$filemojicompat_version" + implementation libs.bouncycastle + implementation libs.unified.push - implementation "org.bouncycastle:bcprov-jdk15on:1.70" - implementation "com.github.UnifiedPush:android-connector:2.0.1" + testImplementation libs.androidx.test.junit + testImplementation libs.robolectric + testImplementation libs.bundles.mockito + testImplementation libs.mockwebserver + testImplementation libs.androidx.core.testing + testImplementation libs.kotlinx.coroutines.test - testImplementation "androidx.test.ext:junit:1.1.3" - testImplementation "org.robolectric:robolectric:4.8.1" - testImplementation "org.mockito:mockito-inline:4.7.0" - testImplementation "org.mockito.kotlin:mockito-kotlin:4.0.0" + androidTestImplementation libs.espresso.core + androidTestImplementation libs.androidx.room.testing + androidTestImplementation libs.androidx.test.junit - testImplementation "com.squareup.okhttp3:mockwebserver:$okhttpVersion" - - androidTestImplementation "androidx.test.espresso:espresso-core:3.4.0" - androidTestImplementation "androidx.room:room-testing:$roomVersion" - androidTestImplementation "androidx.test.ext:junit:1.1.3" - testImplementation "androidx.arch.core:core-testing:2.1.0" - - testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutinesVersion" } diff --git a/build.gradle b/build.gradle index 716192653..fe71eb07c 100644 --- a/build.gradle +++ b/build.gradle @@ -5,9 +5,9 @@ buildscript { gradlePluginPortal() } dependencies { - classpath "com.android.tools.build:gradle:7.2.2" - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10" - classpath "org.jlleitschuh.gradle:ktlint-gradle:10.3.0" + classpath libs.android.gradle.plugin + classpath libs.kotlin.gradle.plugin + classpath libs.ktlint.gradle } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 000000000..0b71df70f --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,148 @@ +[versions] +agp = "7.2.2" +androidx-activity = "1.6.0" +androidx-appcompat = "1.5.1" +androidx-browser = "1.4.0" +androidx-cardview = "1.0.0" +androidx-constraintlayout = "2.1.4" +androidx-core = "1.9.0" +androidx-exifinterface = "1.3.4" +androidx-fragment = "1.5.3" +androidx-junit = "1.1.3" +androidx-paging = "3.1.1" +androidx-preference = "1.2.0" +androidx-recyclerview = "1.1.0" +androidx-sharetarget = "1.2.0" +androidx-splashscreen = "1.0.0" +androidx-swiperefresh-layout = "1.1.0" +androidx-testing = "2.1.0" +androidx-viewpager2 = "1.0.0" +androidx-work = "2.7.1" +autodispose = "2.1.1" +bouncycastle = "1.70" +conscrypt = "2.5.2" +coroutines = "1.6.4" +dagger = "2.43.2" +emoji2 = "1.1.0" +espresso = "3.4.0" +filemoji-compat = "3.2.3" +glide = "4.13.2" +glide-animation-plugin = "2.23.0" +gson = "2.9.0" +kotlin = "1.7.10" +ktlint = "10.2.1" +image-cropper = "4.3.1" +lifecycle = "2.5.1" +material = "1.6.1" +material-drawer = "8.4.5" +material-typeface = "4.0.0.2-kotlin" +mockito-inline = "4.7.0" +mockito-kotlin = "4.0.0" +networkresult-calladapter = "1.0.0" +okhttp = "4.10.0" +retrofit = "2.9.0" +robolectric = "4.8.1" +room = "2.4.3" +rxandroid3 = "3.0.0" +rxjava3 = "3.1.3" +rxkotlin3 = "3.0.1" +photoview = "2.3.0" +sparkbutton = "4.1.0" +unified-push = "2.0.1" + +[libraries] +android-gradle-plugin = { module = "com.android.tools.build:gradle", version.ref = "agp" } +android-material = { module = "com.google.android.material:material", version.ref = "material" } +androidx-activity = { module = "androidx.activity:activity-ktx", version.ref = "androidx-activity" } +androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "androidx-appcompat" } +androidx-browser = { module = "androidx.browser:browser", version.ref = "androidx-browser" } +androidx-cardview = { module = "androidx.cardview:cardview", version.ref = "androidx-cardview" } +androidx-constraintlayout = { module = "androidx.constraintlayout:constraintlayout", version.ref = "androidx-constraintlayout" } +androidx-core-ktx = { module = "androidx.core:core-ktx", version.ref = "androidx-core" } +androidx-core-splashscreen = { module = "androidx.core:core-splashscreen", version.ref = "androidx-splashscreen" } +androidx-core-testing = { module = "androidx.arch.core:core-testing", version.ref = "androidx-testing" } +androidx-emoji2-core = { module = "androidx.emoji2:emoji2", version.ref = "emoji2" } +androidx-emoji2-views-core = { module = "androidx.emoji2:emoji2-views", version.ref = "emoji2" } +androidx-emoji2-view-helper = { module = "androidx.emoji2:emoji2-views-helper", version.ref = "emoji2" } +androidx-exifinterface = { module = "androidx.exifinterface:exifinterface", version.ref = "androidx-exifinterface" } +androidx-fragment-ktx = { module = "androidx.fragment:fragment-ktx", version.ref = "androidx-fragment" } +androidx-lifecycle-common-java8 = { module = "androidx.lifecycle:lifecycle-common-java8", version.ref = "lifecycle" } +androidx-lifecycle-livedata-ktx = { module = "androidx.lifecycle:lifecycle-livedata-ktx", version.ref = "lifecycle" } +androidx-lifecycle-reactivestreams-ktx = { module = "androidx.lifecycle:lifecycle-reactivestreams-ktx", version.ref = "lifecycle" } +androidx-lifecycle-viewmodel-ktx = { module = "androidx.lifecycle:lifecycle-viewmodel-ktx", version.ref = "lifecycle" } +androidx-paging-runtime-ktx = { module = "androidx.paging:paging-runtime-ktx", version.ref = "androidx-paging" } +androidx-preference-ktx = { module = "androidx.preference:preference-ktx", version.ref = "androidx-preference" } +androidx-room-compiler = { module = "androidx.room:room-compiler", version.ref = "room" } +androidx-room-paging = { module = "androidx.room:room-paging", version.ref = "room" } +androidx-room-ktx = { module = "androidx.room:room-ktx", version.ref = "room" } +androidx-room-testing = { module = "androidx.room:room-testing", version.ref = "room" } +androidx-recyclerview = { module = "androidx.recyclerview:recyclerview", version.ref = "androidx-recyclerview" } +androidx-sharetarget = { module = "androidx.sharetarget:sharetarget", version.ref = "androidx-sharetarget" } +androidx-swiperefreshlayout = { module = "androidx.swiperefreshlayout:swiperefreshlayout", version.ref = "androidx-swiperefresh-layout" } +androidx-test-junit = { module = "androidx.test.ext:junit", version.ref = "androidx-junit" } +androidx-viewpager2 = { module = "androidx.viewpager2:viewpager2", version.ref = "androidx-viewpager2" } +androidx-work-runtime = { module = "androidx.work:work-runtime", version.ref = "androidx-work" } +autodispose-android-lifecycle = { module = "com.uber.autodispose2:autodispose-androidx-lifecycle", version.ref = "autodispose" } +autodispose-core = { module = "com.uber.autodispose2:autodispose", version.ref = "autodispose" } +bouncycastle = { module = "org.bouncycastle:bcprov-jdk15on", version.ref = "bouncycastle" } +conscrypt-android = { module = "org.conscrypt:conscrypt-android", version.ref = "conscrypt" } +dagger-android-core = { module = "com.google.dagger:dagger-android", version.ref = "dagger" } +dagger-android-processor = { module = "com.google.dagger:dagger-android-processor", version.ref = "dagger" } +dagger-android-support = { module = "com.google.dagger:dagger-android-support", version.ref = "dagger" } +dagger-compiler = { module = "com.google.dagger:dagger-compiler", version.ref = "dagger" } +dagger-core = { module = "com.google.dagger:dagger", version.ref = "dagger" } +espresso-core = { module = "androidx.test.espresso:espresso-core", version.ref = "espresso" } +filemojicompat-core = { module = "de.c1710:filemojicompat", version.ref = "filemoji-compat" } +filemojicompat-defaults = { module = "de.c1710:filemojicompat-defaults", version.ref = "filemoji-compat" } +filemojicompat-ui = { module = "de.c1710:filemojicompat-ui", version.ref = "filemoji-compat" } +glide-animation-plugin = { module = "com.github.penfeizhou.android.animation:glide-plugin", version.ref = "glide-animation-plugin" } +glide-compiler = { module = "com.github.bumptech.glide:compiler", version.ref = "glide" } +glide-core = { module = "com.github.bumptech.glide:glide", version.ref = "glide" } +glide-okhttp3-integration = { module = "com.github.bumptech.glide:okhttp3-integration", version.ref = "glide" } +gson = { module = "com.google.code.gson:gson", version.ref = "gson" } +kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" } +kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "coroutines" } +kotlinx-coroutines-rx3 = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-rx3", version.ref = "coroutines" } +kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines" } +ktlint-gradle = { module = "org.jlleitschuh.gradle:ktlint-gradle", version.ref = "ktlint" } +image-cropper = { module = "com.github.CanHub:Android-Image-Cropper", version.ref = "image-cropper" } +material-drawer-core = { module = "com.mikepenz:materialdrawer", version.ref = "material-drawer" } +material-drawer-iconics = { module = "com.mikepenz:materialdrawer-iconics", version.ref = "material-drawer" } +material-typeface = { module = "com.mikepenz:google-material-typeface", version.ref = "material-typeface" } +mockito-kotlin = { module = "org.mockito.kotlin:mockito-kotlin", version.ref = "mockito-kotlin" } +mockito-inline = { module = "org.mockito:mockito-inline", version.ref = "mockito-inline" } +mockwebserver = { module = "com.squareup.okhttp3:mockwebserver", version.ref = "okhttp" } +networkresult-calladapter = { module = "at.connyduck:networkresult-calladapter", version.ref = "networkresult-calladapter" } +okhttp-core = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" } +okhttp-logging-interceptor = { module = "com.squareup.okhttp3:logging-interceptor", version.ref = "okhttp" } +photoview = { module = "com.github.chrisbanes:PhotoView", version.ref = "photoview" } +retrofit-adapter-rxjava3 = { module = "com.squareup.retrofit2:adapter-rxjava3", version.ref = "retrofit" } +retrofit-converter-gson = { module = "com.squareup.retrofit2:converter-gson", version.ref = "retrofit" } +retrofit-core = { module = "com.squareup.retrofit2:retrofit", version.ref = "retrofit" } +robolectric = { module = "org.robolectric:robolectric", version.ref = "robolectric" } +rxjava3-android = { module = "io.reactivex.rxjava3:rxandroid", version.ref = "rxandroid3" } +rxjava3-core = { module = "io.reactivex.rxjava3:rxjava", version.ref = "rxjava3" } +rxjava3-kotlin = { module = "io.reactivex.rxjava3:rxkotlin", version.ref = "rxkotlin3" } +sparkbutton = { module = "com.github.connyduck:sparkbutton", version.ref = "sparkbutton" } +unified-push = { module = "com.github.UnifiedPush:android-connector", version.ref = "unified-push" } + +[bundles] +androidx = ["androidx-core-ktx", "androidx-appcompat", "androidx-fragment-ktx", "androidx-browser", "androidx-swiperefreshlayout", + "androidx-recyclerview", "androidx-exifinterface", "androidx-cardview", "androidx-preference-ktx", "androidx-sharetarget", + "androidx-emoji2-core", "androidx-emoji2-views-core", "androidx-emoji2-view-helper", "androidx-lifecycle-viewmodel-ktx", + "androidx-lifecycle-livedata-ktx", "androidx-lifecycle-common-java8", "androidx-lifecycle-reactivestreams-ktx", + "androidx-constraintlayout", "androidx-paging-runtime-ktx", "androidx-viewpager2", "androidx-work-runtime", + "androidx-core-splashscreen", "androidx-activity"] +autodispose = ["autodispose-core", "autodispose-android-lifecycle"] +dagger = ["dagger-core", "dagger-android-core", "dagger-android-support"] +dagger-processors = ["dagger-compiler", "dagger-android-processor"] +filemojicompat = ["filemojicompat-core", "filemojicompat-ui", "filemojicompat-defaults"] +glide = ["glide-core", "glide-okhttp3-integration", "glide-animation-plugin"] +material-drawer = ["material-drawer-core", "material-drawer-iconics"] +mockito = ["mockito-kotlin", "mockito-inline"] +okhttp = ["okhttp-core", "okhttp-logging-interceptor"] +retrofit = ["retrofit-core", "retrofit-converter-gson", "retrofit-adapter-rxjava3"] +room = ["androidx-room-ktx", "androidx-room-paging"] +rxjava3 = ["rxjava3-core", "rxjava3-android", "rxjava3-kotlin"] + +[plugins]