Migrate to Gradle Version Catalogs

This commit is contained in:
Rafael Caetano 2024-06-15 00:05:44 +01:00
parent 0f50afa6d2
commit b0df4ebd9f
11 changed files with 217 additions and 292 deletions

View File

@ -1,18 +1,17 @@
import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties
plugins {
id("com.android.application")
id("kotlin-android")
id("kotlin-parcelize")
id("com.google.devtools.ksp")
id("dagger.hilt.android.plugin")
id("org.jetbrains.kotlin.android")
alias(libs.plugins.android.application)
alias(libs.plugins.hilt.android)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlin.parcelize)
alias(libs.plugins.ksp)
}
android {
signingConfigs {
create("release") {
val props = gradleLocalProperties(rootDir)
val props = gradleLocalProperties(rootDir, providers)
storeFile = file(props["MELONDS_KEYSTORE"] as String)
storePassword = props["MELONDS_KEYSTORE_PASSWORD"] as String
keyAlias = props["MELONDS_KEY_ALIAS"] as String
@ -58,7 +57,7 @@ android {
}
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.7"
kotlinCompilerExtensionVersion = libs.versions.composeCompiler.get()
}
flavorDimensions.add("version")
@ -93,7 +92,6 @@ android {
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
isCoreLibraryDesugaringEnabled = true
kotlin {
jvmToolchain(17)
@ -102,109 +100,69 @@ android {
}
}
}
configurations.all {
resolutionStrategy.eachDependency {
val requested = requested
if (requested.group == "com.android.support") {
if (!requested.name.startsWith("multidex")) {
useVersion("26.+")
}
}
}
}
}
dependencies {
val gitHubImplementation by configurations
with(Dependencies.Tools) {
coreLibraryDesugaring(desugarJdkLibs)
}
implementation(projects.masterswitch)
implementation(projects.rcheevosApi)
implementation(projects.common)
with(Dependencies.Modules) {
implementation(project(masterSwitchPreference))
implementation(project(rcheevosApi))
implementation(project(common))
}
implementation(libs.androidx.activity)
implementation(libs.androidx.activity.compose)
implementation(libs.androidx.appcompat)
implementation(libs.androidx.camera2)
implementation(libs.androidx.camera.lifecycle)
implementation(libs.androidx.cardview)
implementation(libs.androidx.constraintlayout)
implementation(libs.androidx.core)
implementation(libs.androidx.documentfile)
implementation(libs.androidx.fragment)
implementation(libs.androidx.hilt.work)
implementation(libs.androidx.lifecycle.viewmodel)
implementation(libs.androidx.lifecycle.viewmodel.compose)
implementation(libs.androidx.preference)
implementation(libs.androidx.recyclerview)
implementation(libs.androidx.room)
implementation(libs.androidx.room.ktx)
implementation(libs.androidx.room.rxjava)
implementation(libs.androidx.splashscreen)
implementation(libs.androidx.swiperefreshlayout)
implementation(libs.androidx.work)
implementation(libs.android.material)
with(Dependencies.Kotlin) {
implementation(kotlinStdlib)
}
implementation(platform(libs.compose.bom))
implementation(libs.accompanist.pagerindicators)
implementation(libs.accompanist.systemuicontroller)
implementation(libs.compose.foundation)
implementation(libs.compose.material)
implementation(libs.compose.ui)
implementation(libs.compose.ui.tooling.preview)
// AndroidX
with(Dependencies.AndroidX) {
implementation(activity)
implementation(activityCompose)
implementation(appCompat)
implementation(camera2)
implementation(cameraLifecycle)
implementation(cardView)
implementation(constraintLayout)
implementation(core)
implementation(documentFile)
implementation(fragment)
implementation(hiltWork)
implementation(lifecycleViewModel)
implementation(lifecycleViewModelCompose)
implementation(preference)
implementation(recyclerView)
implementation(room)
implementation(roomKtx)
implementation(roomRxJava)
implementation(splashscreen)
implementation(swipeRefreshLayout)
implementation(work)
implementation(material)
}
debugImplementation(libs.compose.ui.tooling)
with(Dependencies.Compose) {
implementation(platform(bom))
implementation(accompanistPagerIndicators)
implementation(accompanistSystemUiController)
implementation(foundation)
implementation(material)
implementation(ui)
implementation(uiToolingPreview)
implementation(libs.coil)
implementation(libs.flexbox)
implementation(libs.gson)
implementation(libs.hilt)
implementation(libs.kotlinx.coroutines.rx)
implementation(libs.picasso)
implementation(libs.markwon)
implementation(libs.markwon.imagepicasso)
implementation(libs.markwon.linkify)
implementation(libs.rxjava)
implementation(libs.rxjava.android)
implementation(libs.commons.compress)
implementation(libs.xz)
debugImplementation(uiTooling)
}
gitHubImplementation(libs.retrofit)
gitHubImplementation(libs.retrofit.adapter.rxjava)
gitHubImplementation(libs.retrofit.converter.gson)
// Third-party
with(Dependencies.ThirdParty) {
implementation(coil)
implementation(flexbox)
implementation(gson)
implementation(hilt)
implementation(kotlinxCoroutinesRx)
implementation(picasso)
implementation(markwon)
implementation(markwonImagePicasso)
implementation(markwonLinkify)
implementation(rxJava)
implementation(rxJavaAndroid)
implementation(commonsCompress)
implementation(xz)
}
ksp(libs.hilt.compiler)
ksp(libs.hilt.compiler.android)
ksp(libs.room.compiler)
// GitHub
with(Dependencies.GitHub) {
gitHubImplementation(retrofit)
gitHubImplementation(retrofitAdapterRxJava)
gitHubImplementation(retrofitConverterGson)
}
with(Dependencies.Ksp) {
ksp(hiltCompiler)
ksp(hiltCompilerAndroid)
ksp(roomCompiler)
}
// Testing
with(Dependencies.Testing) {
testImplementation(junit)
}
}
repositories {
mavenCentral()
}
testImplementation(libs.junit)
}

View File

@ -1,37 +1,13 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
maven("https://jitpack.io")
}
dependencies {
with(Dependencies.GradlePlugins) {
classpath(gradle)
classpath(hiltAndroid)
classpath(kotlin)
}
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
plugins {
with(Dependencies.GradlePlugins) {
id(ksp) version Dependencies.Versions.Ksp apply false
}
}
allprojects {
repositories {
google()
mavenCentral()
maven("https://jitpack.io")
}
alias(libs.plugins.android.application) apply false
alias(libs.plugins.android.library) apply false
alias(libs.plugins.hilt.android) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.kotlin.jvm) apply false
alias(libs.plugins.kotlin.parcelize) apply false
alias(libs.plugins.ksp) apply false
}
tasks.register("clean", Delete::class) {
delete(rootProject.buildDir)
delete(rootProject.layout.buildDirectory)
}

View File

@ -1,132 +0,0 @@
object Dependencies {
object Versions {
const val Accompanist = "0.30.1"
const val Activity = "1.8.2"
const val AppCompat = "1.6.1"
const val CameraX = "1.3.1"
const val CardView = "1.0.0"
const val Coil = "2.2.2"
const val CommonsCompress = "1.21"
const val ComposeBom = "2023.10.01"
const val ConstraintLayout = "2.1.4"
const val Core = "1.12.0"
const val Desugar = "2.0.2"
const val DocumentFile = "1.0.1"
const val Flexbox = "3.0.0"
const val Fragment = "1.6.2"
const val Gradle = "8.2.0"
const val Gson = "2.8.6"
const val HiltX = "1.1.0"
const val Hilt = "2.48"
const val Junit = "4.12"
const val Kotlin = "1.9.21"
const val KotlinxCoroutines = "1.7.3"
const val Ksp = "1.9.0-1.0.12"
const val LifecycleViewModel = "2.6.2"
const val Material = "1.7.0"
const val OkHttp = "4.11.0"
const val Picasso = "2.71828"
const val Preference = "1.2.1"
const val RecyclerView = "1.3.2"
const val Room = "2.6.1"
const val RxAndroid = "2.1.1"
const val RxJava = "2.2.10"
const val Splashscreen = "1.0.0"
const val SwipeRefreshLayout = "1.1.0"
const val Work = "2.9.0"
const val Markwon = "4.6.2"
const val Retrofit = "2.9.0"
const val Xz = "1.9"
}
object GradlePlugins {
const val gradle = "com.android.tools.build:gradle:${Versions.Gradle}"
const val hiltAndroid = "com.google.dagger:hilt-android-gradle-plugin:${Versions.Hilt}"
const val kotlin = "org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.Kotlin}"
const val ksp = "com.google.devtools.ksp"
}
object Tools {
const val desugarJdkLibs = "com.android.tools:desugar_jdk_libs:${Versions.Desugar}"
}
object Kotlin {
const val kotlinStdlib = "org.jetbrains.kotlin:kotlin-stdlib:${Versions.Kotlin}"
const val coroutines = "org.jetbrains.kotlinx:kotlinx-coroutines-core:${Versions.KotlinxCoroutines}"
}
object AndroidX {
const val activity = "androidx.activity:activity-ktx:${Versions.Activity}"
const val activityCompose = "androidx.activity:activity-compose:${Versions.Activity}"
const val appCompat = "androidx.appcompat:appcompat:${Versions.AppCompat}"
const val camera2 = "androidx.camera:camera-camera2:${Versions.CameraX}"
const val cameraLifecycle = "androidx.camera:camera-lifecycle:${Versions.CameraX}"
const val cardView = "androidx.cardview:cardview:${Versions.CardView}"
const val constraintLayout = "androidx.constraintlayout:constraintlayout:${Versions.ConstraintLayout}"
const val core = "androidx.core:core-ktx:${Versions.Core}"
const val documentFile = "androidx.documentfile:documentfile:${Versions.DocumentFile}"
const val fragment = "androidx.fragment:fragment-ktx:${Versions.Fragment}"
const val hiltWork = "androidx.hilt:hilt-work:${Versions.HiltX}"
const val lifecycleViewModel = "androidx.lifecycle:lifecycle-viewmodel-ktx:${Versions.LifecycleViewModel}"
const val lifecycleViewModelCompose = "androidx.lifecycle:lifecycle-viewmodel-compose:${Versions.LifecycleViewModel}"
const val preference = "androidx.preference:preference-ktx:${Versions.Preference}"
const val recyclerView = "androidx.recyclerview:recyclerview:${Versions.RecyclerView}"
const val room = "androidx.room:room-runtime:${Versions.Room}"
const val roomKtx = "androidx.room:room-ktx:${Versions.Room}"
const val roomRxJava = "androidx.room:room-rxjava2:${Versions.Room}"
const val splashscreen = "androidx.core:core-splashscreen:${Versions.Splashscreen}"
const val swipeRefreshLayout = "androidx.swiperefreshlayout:swiperefreshlayout:${Versions.SwipeRefreshLayout}"
const val work = "androidx.work:work-runtime:${Versions.Work}"
const val material = "com.google.android.material:material:${Versions.Material}"
}
object Compose {
const val bom = "androidx.compose:compose-bom:${Versions.ComposeBom}"
const val accompanistPagerIndicators = "com.google.accompanist:accompanist-pager-indicators:${Versions.Accompanist}"
const val accompanistSystemUiController = "com.google.accompanist:accompanist-systemuicontroller:${Versions.Accompanist}"
const val foundation = "androidx.compose.foundation:foundation"
const val material = "androidx.compose.material:material"
const val ui = "androidx.compose.ui:ui"
const val uiTooling = "androidx.compose.ui:ui-tooling"
const val uiToolingPreview = "androidx.compose.ui:ui-tooling-preview"
}
object ThirdParty {
const val coil = "io.coil-kt:coil-compose:${Versions.Coil}"
const val flexbox = "com.google.android.flexbox:flexbox:${Versions.Flexbox}"
const val gson = "com.google.code.gson:gson:${Versions.Gson}"
const val hilt = "com.google.dagger:hilt-android:${Versions.Hilt}"
const val kotlinxCoroutinesRx = "org.jetbrains.kotlinx:kotlinx-coroutines-rx2:${Versions.KotlinxCoroutines}"
const val picasso = "com.squareup.picasso:picasso:${Versions.Picasso}"
const val markwon = "io.noties.markwon:core:${Versions.Markwon}"
const val markwonImagePicasso = "io.noties.markwon:image-picasso:${Versions.Markwon}"
const val markwonLinkify = "io.noties.markwon:linkify:${Versions.Markwon}"
const val okHttp = "com.squareup.okhttp3:okhttp:${Versions.OkHttp}"
const val rxJava = "io.reactivex.rxjava2:rxjava:${Versions.RxJava}"
const val rxJavaAndroid = "io.reactivex.rxjava2:rxandroid:${Versions.RxAndroid}"
const val commonsCompress = "org.apache.commons:commons-compress:${Versions.CommonsCompress}"
const val xz = "org.tukaani:xz:${Versions.Xz}"
}
object GitHub {
const val retrofit = "com.squareup.retrofit2:adapter-rxjava2:${Versions.Retrofit}"
const val retrofitAdapterRxJava = "com.squareup.retrofit2:adapter-rxjava2:${Versions.Retrofit}"
const val retrofitConverterGson = "com.squareup.retrofit2:converter-gson:${Versions.Retrofit}"
}
object Ksp {
const val hiltCompiler = "androidx.hilt:hilt-compiler:${Versions.HiltX}"
const val hiltCompilerAndroid = "com.google.dagger:hilt-android-compiler:${Versions.Hilt}"
const val roomCompiler = "androidx.room:room-compiler:${Versions.Room}"
}
object Modules {
const val masterSwitchPreference = ":masterswitch"
const val rcheevosApi = ":rcheevos-api"
const val common = ":common"
}
object Testing {
const val junit = "junit:junit:${Versions.Junit}"
}
}

View File

@ -1,5 +1,5 @@
plugins {
id("org.jetbrains.kotlin.jvm")
alias(libs.plugins.kotlin.jvm)
}
kotlin {
@ -7,7 +7,5 @@ kotlin {
}
dependencies {
with(Dependencies.Kotlin) {
implementation(coroutines)
}
implementation(libs.kotlin.coroutines)
}

View File

@ -13,6 +13,5 @@ org.gradle.jvmargs=-Xmx1536m
# org.gradle.parallel=true
android.useAndroidX=true
android.enableJetifier=true
android.nonTransitiveRClass=false
android.enableR8.fullMode=false

114
gradle/libs.versions.toml Normal file
View File

@ -0,0 +1,114 @@
[versions]
accompanist = "0.30.1"
activity = "1.8.2"
appCompat = "1.6.1"
cameraX = "1.3.1"
cardView = "1.0.0"
coil = "2.2.2"
commonsCompress = "1.21"
composeBom = "2023.10.01"
composeCompiler = "1.5.7"
constraintLayout = "2.1.4"
core = "1.12.0"
documentFile = "1.0.1"
flexbox = "3.0.0"
fragment = "1.6.2"
gradle = "8.5.0"
gson = "2.8.6"
hiltX = "1.1.0"
hilt = "2.48"
junit = "4.12"
kotlin = "1.9.21"
kotlinxCoroutines = "1.7.3"
ksp = "1.9.0-1.0.12"
lifecycleViewModel = "2.6.2"
material = "1.7.0"
okHttp = "4.11.0"
picasso = "2.71828"
preference = "1.2.1"
recyclerView = "1.3.2"
room = "2.6.1"
rxAndroid = "2.1.1"
rxJava = "2.2.10"
splashscreen = "1.0.0"
swipeRefreshLayout = "1.1.0"
work = "2.9.0"
markwon = "4.6.2"
retrofit = "2.9.0"
xz = "1.9"
[libraries]
# Kotlin
kotlin-coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinxCoroutines" }
# AndroidX
androidx-activity = { module = "androidx.activity:activity-ktx", version.ref = "activity" }
androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "activity" }
androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "appCompat" }
androidx-camera2 = { module = "androidx.camera:camera-camera2", version.ref = "cameraX" }
androidx-camera-lifecycle = { module = "androidx.camera:camera-lifecycle", version.ref = "cameraX" }
androidx-cardview = { module = "androidx.cardview:cardview", version.ref = "cardView" }
androidx-constraintlayout = { module = "androidx.constraintlayout:constraintlayout", version.ref = "constraintLayout" }
androidx-core = { module = "androidx.core:core-ktx", version.ref = "core" }
androidx-documentfile = { module = "androidx.documentfile:documentfile", version.ref = "documentFile" }
androidx-fragment = { module = "androidx.fragment:fragment-ktx", version.ref = "fragment" }
androidx-hilt-work = { module = "androidx.hilt:hilt-work", version.ref = "hiltX" }
androidx-lifecycle-viewmodel = { module = "androidx.lifecycle:lifecycle-viewmodel-ktx", version.ref = "lifecycleViewModel" }
androidx-lifecycle-viewmodel-compose = { module = "androidx.lifecycle:lifecycle-viewmodel-compose", version.ref = "lifecycleViewModel" }
androidx-preference = { module = "androidx.preference:preference-ktx", version.ref = "preference" }
androidx-recyclerview = { module = "androidx.recyclerview:recyclerview", version.ref = "recyclerView" }
androidx-room = { module = "androidx.room:room-runtime", version.ref = "room" }
androidx-room-ktx = { module = "androidx.room:room-ktx", version.ref = "room" }
androidx-room-rxjava = { module = "androidx.room:room-rxjava2", version.ref = "room" }
androidx-splashscreen = { module = "androidx.core:core-splashscreen", version.ref = "splashscreen" }
androidx-swiperefreshlayout = { module = "androidx.swiperefreshlayout:swiperefreshlayout", version.ref = "swipeRefreshLayout" }
androidx-work = { module = "androidx.work:work-runtime", version.ref = "work" }
android-material = { module = "com.google.android.material:material", version.ref = "material" }
# Compose
compose-bom = { module = "androidx.compose:compose-bom", version.ref = "composeBom" }
accompanist-pagerindicators = { module = "com.google.accompanist:accompanist-pager-indicators", version.ref = "accompanist" }
accompanist-systemuicontroller = { module = "com.google.accompanist:accompanist-systemuicontroller", version.ref = "accompanist" }
compose-foundation = { module = "androidx.compose.foundation:foundation" }
compose-material = { module = "androidx.compose.material:material" }
compose-ui = { module = "androidx.compose.ui:ui" }
compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling" }
compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview" }
# Third-party
coil = { module = "io.coil-kt:coil-compose", version.ref = "coil" }
flexbox = { module = "com.google.android.flexbox:flexbox", version.ref = "flexbox" }
gson = { module = "com.google.code.gson:gson", version.ref = "gson" }
hilt = { module = "com.google.dagger:hilt-android", version.ref = "hilt" }
kotlinx-coroutines-rx = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-rx2", version.ref = "kotlinxCoroutines" }
picasso = { module = "com.squareup.picasso:picasso", version.ref = "picasso" }
markwon = { module = "io.noties.markwon:core", version.ref = "markwon" }
markwon-imagepicasso = { module = "io.noties.markwon:image-picasso", version.ref = "markwon" }
markwon-linkify = { module = "io.noties.markwon:linkify", version.ref = "markwon" }
okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okHttp" }
rxjava = { module = "io.reactivex.rxjava2:rxjava", version.ref = "rxJava" }
rxjava-android = { module = "io.reactivex.rxjava2:rxandroid", version.ref = "rxAndroid" }
commons-compress = { module = "org.apache.commons:commons-compress", version.ref = "commonsCompress" }
xz = { module = "org.tukaani:xz", version.ref = "xz" }
# GitHub
retrofit = { module = "com.squareup.retrofit2:retrofit", version.ref = "retrofit" }
retrofit-adapter-rxjava = { module = "com.squareup.retrofit2:adapter-rxjava2", version.ref = "retrofit" }
retrofit-converter-gson = { module = "com.squareup.retrofit2:converter-gson", version.ref = "retrofit" }
# Ksp
hilt-compiler = { module = "androidx.hilt:hilt-compiler", version.ref = "hiltX" }
hilt-compiler-android = { module = "com.google.dagger:hilt-android-compiler", version.ref = "hilt" }
room-compiler = { module = "androidx.room:room-compiler", version.ref = "room" }
# Testing
junit = { module = "junit:junit", version.ref = "junit" }
[plugins]
android-application = { id = "com.android.application", version.ref = "gradle" }
android-library = { id = "com.android.library", version.ref = "gradle" }
hilt-android = { id = "com.google.dagger.hilt.android", version.ref = "hilt" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
kotlin-parcelize = { id = "org.jetbrains.kotlin.plugin.parcelize", version.ref = "kotlin" }
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }

View File

@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip

View File

@ -1,5 +1,5 @@
plugins {
id("com.android.library")
alias(libs.plugins.android.library)
id("kotlin-android")
}
@ -28,13 +28,7 @@ android {
}
dependencies {
with(Dependencies.Kotlin) {
implementation(kotlinStdlib)
}
with(Dependencies.AndroidX) {
implementation(appCompat)
implementation(core)
implementation(preference)
}
implementation(libs.androidx.appcompat)
implementation(libs.androidx.core)
implementation(libs.androidx.preference)
}

View File

@ -1,5 +1,5 @@
plugins {
id("org.jetbrains.kotlin.jvm")
alias(libs.plugins.kotlin.jvm)
}
kotlin {
@ -7,12 +7,8 @@ kotlin {
}
dependencies {
with(Dependencies.Modules) {
implementation(project(common))
}
implementation(projects.common)
with(Dependencies.ThirdParty) {
implementation(gson)
implementation(okHttp)
}
implementation(libs.gson)
implementation(libs.okhttp)
}

View File

@ -1 +0,0 @@
include ':app', ':masterswitch', ':rcheevos-api', ':common'

23
settings.gradle.kts Normal file
View File

@ -0,0 +1,23 @@
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
rootProject.name = "melonDS"
include(":app")
include(":common")
include(":masterswitch")
include(":rcheevos-api")