Migrate dependencies to gradle version catalog

This commit is contained in:
William Brawner 2021-06-03 18:54:02 -06:00
parent e345afb2b7
commit bdacaaae34
5 changed files with 73 additions and 41 deletions

View file

@ -21,13 +21,13 @@ try {
} }
android { android {
compileSdk = 29 compileSdk = libs.versions.maxSdk.get().toInt()
defaultConfig { defaultConfig {
applicationId = "com.wbrawner.pihelper" applicationId = "com.wbrawner.pihelper"
minSdk = 23 minSdk = libs.versions.minSdk.get().toInt()
targetSdk = 29 targetSdk = libs.versions.maxSdk.get().toInt()
versionCode = 2 versionCode = libs.versions.versionCode.get().toInt()
versionName = "1.0.0" versionName = libs.versions.versionName.get()
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
signingConfig = signingConfigs["debug"] signingConfig = signingConfigs["debug"]
} }
@ -63,24 +63,19 @@ android {
dependencies { dependencies {
implementation(project(":piholeclient")) implementation(project(":piholeclient"))
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:${rootProject.ext["kotlinVersion"]}") implementation(libs.bundles.coroutines)
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:${rootProject.ext["coroutinesVersion"]}") implementation("io.insert-koin:koin-androidx-viewmodel:${libs.versions.koin.get()}")
implementation("org.koin:koin-androidx-viewmodel:${rootProject.ext["koinVersion"]}") implementation(libs.androidx.core)
implementation("androidx.appcompat:appcompat:1.2.0") implementation(libs.androidx.appcompat)
implementation("androidx.core:core-ktx:1.3.2") implementation(libs.material)
implementation("androidx.constraintlayout:constraintlayout:2.0.4") implementation("androidx.constraintlayout:constraintlayout:2.0.4")
implementation("com.google.android.material:material:1.3.0-alpha04")
implementation("androidx.legacy:legacy-support-v4:1.0.0") implementation("androidx.legacy:legacy-support-v4:1.0.0")
implementation("androidx.security:security-crypto:1.0.0-rc01") implementation("androidx.security:security-crypto:1.0.0-rc01")
implementation("androidx.preference:preference-ktx:1.1.1") implementation(libs.preference)
testImplementation("junit:junit:4.13.1") testImplementation(libs.junit)
androidTestImplementation("androidx.test.ext:junit:1.1.2") androidTestImplementation(libs.test.ext)
androidTestImplementation("androidx.test.espresso:espresso-core:3.3.0") androidTestImplementation(libs.espresso)
val navigation_version = "2.3.2" implementation(libs.bundles.navigation)
implementation("androidx.navigation:navigation-fragment-ktx:$navigation_version") implementation(libs.bundles.lifecycle)
implementation("androidx.navigation:navigation-ui-ktx:$navigation_version")
val lifecycle_version = "2.2.0"
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version")
implementation("androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version")
} }

View file

@ -3,11 +3,7 @@ buildscript {
google() google()
mavenCentral() mavenCentral()
} }
val coroutinesVersion by extra("1.3.2")
val hiltVersion by extra("2.36")
val koinVersion by extra("2.0.1")
val kotlinVersion by extra("1.4.32") val kotlinVersion by extra("1.4.32")
val okHttpVersion by extra("4.2.2")
dependencies { dependencies {
classpath("com.android.tools.build:gradle:7.0.0-beta03") classpath("com.android.tools.build:gradle:7.0.0-beta03")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}") classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}")

43
gradle/libs.versions.toml Normal file
View file

@ -0,0 +1,43 @@
[versions]
androidx-core = "1.3.2"
androidx-appcompat = "1.2.0"
coroutines = "1.4.3"
espresso = "3.3.0"
koin = "2.2.3"
kotlin = "1.4.32"
lifecycle = "2.2.0"
material = "1.3.0"
maxSdk = "30"
moshi = "1.9.2"
minSdk = "21"
navigation = "2.3.2"
okhttp = "4.2.2"
versionCode = "1"
versionName = "1.0"
[libraries]
androidx-core = { module = "androidx.core:core-ktx", version.ref = "androidx-core" }
androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "androidx-appcompat" }
material = { module = "com.google.android.material:material", version.ref = "material" }
moshi-core = { module = "com.squareup.moshi:moshi", version.ref = "moshi" }
moshi-codegen = { module = "com.squareup.moshi:moshi-kotlin-codegen", version.ref = "moshi" }
navigation-fragment = { module = "androidx.navigation:navigation-fragment-ktx", version.ref = "navigation" }
navigation-ui = { module = "androidx.navigation:navigation-ui-ktx", version.ref = "navigation" }
coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" }
coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "coroutines" }
preference = { module = "androidx.preference:preference-ktx", version = "1.1.1" }
lifecycle-livedata = { module = "androidx.lifecycle:lifecycle-livedata-ktx", version.ref = "lifecycle" }
lifecycle-viewmodel = { module = "androidx.lifecycle:lifecycle-viewmodel-ktx", version.ref = "lifecycle" }
junit = { module = "junit:junit", version = "4.12" }
kotlin-gradle = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" }
kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kotlin" }
test-ext = { module = "androidx.test.ext:junit", version = "1.1.2" }
espresso = { module = "androidx.test.espresso:espresso-core", version.ref = "espresso" }
[bundles]
coroutines = ["coroutines-core", "coroutines-android"]
lifecycle = ["lifecycle-livedata", "lifecycle-viewmodel"]
navigation = ["navigation-fragment", "navigation-ui"]

View file

@ -5,10 +5,10 @@ plugins {
} }
android { android {
compileSdk = 29 compileSdk = libs.versions.maxSdk.get().toInt()
defaultConfig { defaultConfig {
minSdk = 23 minSdk = libs.versions.minSdk.get().toInt()
targetSdk = 29 targetSdk = libs.versions.maxSdk.get().toInt()
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro") consumerProguardFiles("consumer-rules.pro")
@ -30,17 +30,14 @@ android {
} }
dependencies { dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:${rootProject.ext["kotlinVersion"]}") implementation("io.insert-koin:koin-core:${libs.versions.koin.get()}")
implementation("org.jetbrains.kotlin:kotlin-reflect:${rootProject.ext["kotlinVersion"]}") implementation("com.squareup.okhttp3:okhttp:${libs.versions.okhttp.get()}")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:${rootProject.ext["coroutinesVersion"]}") implementation("com.squareup.okhttp3:logging-interceptor:${libs.versions.okhttp.get()}")
implementation("org.koin:koin-core:${rootProject.ext["koinVersion"]}") implementation(libs.androidx.core)
implementation("com.squareup.okhttp3:okhttp:${rootProject.ext["okHttpVersion"]}") implementation(libs.androidx.appcompat)
implementation("com.squareup.okhttp3:logging-interceptor:${rootProject.ext["okHttpVersion"]}") implementation(libs.bundles.coroutines)
implementation("androidx.appcompat:appcompat:1.1.0") implementation(libs.kotlin.reflect)
implementation("androidx.core:core-ktx:1.1.0") implementation(libs.moshi.core)
implementation("com.squareup.moshi:moshi:1.9.2") kapt(libs.moshi.codegen)
kapt("com.squareup.moshi:moshi-kotlin-codegen:1.9.2") testImplementation(libs.junit)
testImplementation("junit:junit:4.12")
androidTestImplementation("androidx.test.ext:junit:1.1.1")
androidTestImplementation("androidx.test.espresso:espresso-core:3.2.0")
} }

View file

@ -1,3 +1,4 @@
enableFeaturePreview("VERSION_CATALOGS")
dependencyResolutionManagement { dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories { repositories {