Skip to content

Commit

Permalink
Issue #56: Migrate to Gradle version catalog
Browse files Browse the repository at this point in the history
  • Loading branch information
AmrDeveloper committed May 14, 2024
1 parent c902e9d commit 1cb6be7
Show file tree
Hide file tree
Showing 5 changed files with 149 additions and 124 deletions.
121 changes: 51 additions & 70 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,31 +1,24 @@
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-parcelize'
id 'androidx.navigation.safeargs.kotlin'
id "dagger.hilt.android.plugin"
id 'kotlin-kapt'
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlin.parcelize)
alias(libs.plugins.navigation.safeargs)
alias(libs.plugins.hilt)
alias(libs.plugins.ksp)
}

android {
compileSdkVersion rootProject.compileSdkVersion

defaultConfig {
applicationId "com.amrdeveloper.linkhub"
minSdkVersion 17
targetSdkVersion rootProject.targetSdkVersion
minSdkVersion 19
compileSdk 34
targetSdkVersion 34
versionCode 23
versionName "1.6.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

javaCompileOptions {
annotationProcessorOptions {
arguments += [
"room.schemaLocation" : "$projectDir/schemas".toString(),
"room.incremental" : "true",
"room.expandProjection": "true"
]
}
ksp {
arg("room.schemaLocation", "$projectDir/schemas")
}

multiDexEnabled true
Expand All @@ -38,69 +31,57 @@ android {
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = '1.8'
}

buildFeatures {
viewBinding true
}
}

dependencies {
// Core
implementation "androidx.core:core-ktx:$rootProject.coreKtxVersion"
implementation "androidx.appcompat:appcompat:$rootProject.appcompatVersion"
implementation "com.google.android.material:material:$rootProject.materialVersion"

// Room Database
implementation "androidx.room:room-runtime:$rootProject.roomVersion"
implementation "androidx.room:room-ktx:$rootProject.roomVersion"
kapt "androidx.room:room-compiler:$rootProject.roomVersion"

// Coroutines
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$rootProject.coroutinesVersion"

// LiveData, ViewModel, Fragment Extension
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$rootProject.lifecycleVersion"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$rootProject.lifecycleVersion"
implementation "androidx.fragment:fragment-ktx:$rootProject.fragmentVersion"

implementation "com.google.code.gson:gson:$rootProject.gsonVersion"

// Navigation Component
implementation "androidx.navigation:navigation-fragment-ktx:$rootProject.navigationVersion"
implementation "androidx.navigation:navigation-ui-ktx:$rootProject.navigationVersion"
implementation 'androidx.legacy:legacy-support-v4:1.0.0'

// Airbnb Lottie
implementation "com.airbnb.android:lottie:$rootProject.lottieVersion"

// Dagger Hilt
implementation "com.google.dagger:hilt-android:$rootProject.hiltVersion"
kapt "com.google.dagger:hilt-android-compiler:$rootProject.hiltVersion"

// Debugging
implementation "com.jakewharton.timber:timber:$rootProject.timberVersion"
debugImplementation "com.squareup.leakcanary:leakcanary-android:$rootProject.leackcanaryVersion"

// Local Testing
testImplementation "junit:junit:$rootProject.junitVersion"
testImplementation "com.google.truth:truth:$rootProject.truthVersion"

implementation "androidx.multidex:multidex:$rootProject.multidexVersion"

// Android Testing
androidTestImplementation "junit:junit:$rootProject.junitVersion"
androidTestImplementation "com.google.truth:truth:$rootProject.truthVersion"
androidTestImplementation "androidx.test.ext:junit:$rootProject.junitExtVersion"
androidTestImplementation "androidx.arch.core:core-testing:$rootProject.archCoreTestVersion"
androidTestImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$rootProject.coroutinesTestVersion"
androidTestImplementation "androidx.test.espresso:espresso-core:$rootProject.espressoVersion"

// Html parsing lib
implementation "org.jsoup:jsoup:$rootProject.jsoupVersion"
implementation(libs.androidx.ktx)
implementation(libs.androidx.appcompat)
implementation(libs.material)
implementation(libs.legacy.support)

implementation(libs.androidx.lifecycle.viewmodel.ktx)
implementation(libs.androidx.lifecycle.livedata.ktx)
implementation(libs.androidx.fragment.ktx)

implementation(libs.androidx.navigation.fragment.ktx)
implementation(libs.androidx.navigation.ui.ktx)

implementation(libs.kotlinx.coroutines)

implementation(libs.bundles.room)
ksp(libs.room.compiler)

implementation(libs.hilt.android)
ksp(libs.hilt.compiler)

implementation(libs.gson)
implementation(libs.jsoup)
implementation(libs.lottie)

implementation(libs.timber)
debugImplementation(libs.leakcanary.android)

testImplementation(libs.junit)
testImplementation(libs.truth)
implementation(libs.androidx.multidex)

androidTestImplementation(libs.junit)
androidTestImplementation(libs.truth)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.core.testing)
androidTestImplementation(libs.kotlinx.coroutines.testing)
androidTestImplementation(libs.androidx.espresso.core)
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ const val DATABASE_VERSION = 5
AutoMigration(from = 2, to = 3),
AutoMigration(from = 3, to = 4),
AutoMigration(from = 4, to = 5)
]
],
exportSchema = true,
)
@TypeConverters(FolderColorConverter::class)
abstract class LinkRoomDatabase : RoomDatabase() {
Expand Down
60 changes: 7 additions & 53 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,56 +1,10 @@
buildscript {

ext.kotlinVersion = " 1.9.0"
ext.navigationVersion = '2.7.4'
ext.hiltVersion = '2.46.1'

repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.2.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$navigationVersion"
classpath "com.google.dagger:hilt-android-gradle-plugin:$hiltVersion"
}
}

allprojects {
repositories {
google()
mavenCentral()
}
}

ext {
compileSdkVersion = 34
targetSdkVersion = 34
coreKtxVersion = '1.12.0'
appcompatVersion = '1.6.1'
fragmentVersion = '1.6.1'
lifecycleVersion = '2.6.2'
materialVersion = '1.10.0'

roomVersion = '2.6.0'
coroutinesVersion = '1.7.3'

gsonVersion = "2.10.1"

lottieVersion = '6.1.0'

timberVersion = '4.7.1'
leackcanaryVersion = '2.7'

multidexVersion = '2.0.1'

junitVersion = '4.13.2'
junitExtVersion = '1.1.5'
truthVersion = '1.0.1'
archCoreTestVersion = '2.1.0'
coroutinesTestVersion = '1.2.1'
espressoVersion = '3.5.1'
jsoupVersion = '1.13.1'
plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.navigation.safeargs) apply false
alias(libs.plugins.kotlin.parcelize) apply false
alias(libs.plugins.hilt) apply false
alias(libs.plugins.ksp) apply false
}

tasks.register('clean', Delete) {
Expand Down
70 changes: 70 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
[versions]
kotlin = "1.9.10"
androidGradlePlugin = "7.4.2"
androidx-junit = "1.1.5"
appcompat = "1.6.1"
core-testing = "2.1.0"
espresso-core = "3.5.1"
fragment-ktx = "1.6.1"
gson = "2.10.1"
jsoup = "1.13.1"
junit = "4.13.2"
kotlinx-coroutines = "1.7.3"
kotlinx-coroutines-testing = '1.2.1'
ktx = "1.13.1"
leakcanary-android = "2.7"
lifecycle-livedata-ktx = "2.6.2"
lottie = "6.1.0"
material = "1.10.0"
multidex = "2.0.1"
navigation-fragment-ktx = "2.7.4"
navigation-safeargs = "2.7.4"
room = "2.6.0"
hilt = "2.48"
legacy_support = "1.0.0"
timber = "4.7.1"
truth = "1.0.1"
ksp = "1.9.20-1.0.14"

[libraries]
androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "appcompat" }
androidx-core-testing = { module = "androidx.arch.core:core-testing", version.ref = "core-testing" }
androidx-espresso-core = { module = "androidx.test.espresso:espresso-core", version.ref = "espresso-core" }
androidx-fragment-ktx = { module = "androidx.fragment:fragment-ktx", version.ref = "fragment-ktx" }
androidx-junit = { module = "androidx.test.ext:junit", version.ref = "androidx-junit" }
androidx-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "ktx" }
androidx-lifecycle-livedata-ktx = { module = "androidx.lifecycle:lifecycle-livedata-ktx", version.ref = "lifecycle-livedata-ktx" }
androidx-lifecycle-viewmodel-ktx = { module = "androidx.lifecycle:lifecycle-viewmodel-ktx", version.ref = "lifecycle-livedata-ktx" }
androidx-multidex = { module = "androidx.multidex:multidex", version.ref = "multidex" }
androidx-navigation-fragment-ktx = { module = "androidx.navigation:navigation-fragment-ktx", version.ref = "navigation-fragment-ktx" }
androidx-navigation-ui-ktx = { module = "androidx.navigation:navigation-ui-ktx", version.ref = "navigation-fragment-ktx" }
gson = { module = "com.google.code.gson:gson", version.ref = "gson" }
jsoup = { module = "org.jsoup:jsoup", version.ref = "jsoup" }
junit = { module = "junit:junit", version.ref = "junit" }
kotlinx-coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "kotlinx-coroutines" }
kotlinx-coroutines-testing = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlinx-coroutines-testing" }
leakcanary-android = { module = "com.squareup.leakcanary:leakcanary-android", version.ref = "leakcanary-android" }
lottie = { module = "com.airbnb.android:lottie", version.ref = "lottie" }
material = { module = "com.google.android.material:material", version.ref = "material" }

room-runtime = { module = "androidx.room:room-runtime", version.ref = "room" }
room-compiler = { module = "androidx.room:room-compiler", version.ref = "room" }
room-ktx = { module = "androidx.room:room-ktx", version.ref = "room" }

hilt-android = { module = "com.google.dagger:hilt-android", version.ref = "hilt" }
hilt-compiler = { module = "com.google.dagger:hilt-compiler", version.ref = "hilt" }

legacy_support = { module = "androidx.legacy:legacy-support-v4", version.ref = "legacy_support" }
timber = { module = "com.jakewharton.timber:timber", version.ref = "timber" }
truth = { module = "com.google.truth:truth", version.ref = "truth" }

[bundles]
room = ["room-runtime", "room-ktx"]

[plugins]
android-application = { id = "com.android.application", version.ref = "androidGradlePlugin" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
kotlin-parcelize = { id = "org.jetbrains.kotlin.plugin.parcelize", version.ref = "kotlin" }
navigation-safeargs = { id = "androidx.navigation.safeargs", version.ref = "navigation-safeargs" }
hilt = { id = "com.google.dagger.hilt.android", version.ref = "hilt" }
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
19 changes: 19 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,2 +1,21 @@
pluginManagement {
repositories {
maven {
url = uri("https://plugins.gradle.org/m2/")
}
gradlePluginPortal()
google()
mavenCentral()

}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}

rootProject.name = "LinkHub"
include ':app'

0 comments on commit 1cb6be7

Please sign in to comment.