Skip to content

Commit

Permalink
Using version catalog to declare shared dependencies (#49)
Browse files Browse the repository at this point in the history
## Context
Using version catalog to declare shared dependencies
https://docs.gradle.org/current/userguide/platforms.html

## Code
- Following the guide
  • Loading branch information
cmorigaki authored Feb 14, 2023
1 parent 84c5217 commit 627f278
Show file tree
Hide file tree
Showing 23 changed files with 288 additions and 285 deletions.
8 changes: 0 additions & 8 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 21 additions & 20 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
apply plugin: "com.android.application"
apply plugin: 'kotlin-android'
apply plugin: 'com.starter.easylauncher'
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.easylauncher)
}

apply from: "$rootDir/project-config/api-properties/api-properties.gradle"

android {
compileSdkVersion AndroidConfig.compileSdk
buildToolsVersion AndroidConfig.buildTools
compileSdk libs.versions.compileSdk.get() as int
namespace 'br.com.recipebook'

defaultConfig {
applicationId AndroidConfig.applicationId
applicationId "br.com.recipebook"

minSdkVersion AndroidConfig.minSdk
targetSdkVersion AndroidConfig.targetSdk
versionCode AndroidConfig.versionCode
versionName AndroidConfig.versionName
minSdk libs.versions.minSdk.get() as int
targetSdk libs.versions.compileSdk.get() as int
versionCode 10000001 // x.xxx.xx-xx
versionName "1.0.0"
}

buildTypes {
Expand Down Expand Up @@ -42,15 +44,14 @@ android {
kotlinOptions {
jvmTarget = jvmTargetVersion
}
namespace 'br.com.recipebook'
}

dependencies {
implementation EnvironmentConfig.kotlinStdLib
implementation AndroidLibConfig.coroutinesCore
implementation libs.kotlin.stdlib
implementation libs.coroutines.core

implementation AndroidLibConfig.koinCore
implementation AndroidLibConfig.koinAndroidExt
implementation libs.koin.core
implementation libs.koin.android

implementation project(ProjectConfig.coreAndroid)
implementation project(ProjectConfig.utilityAndroid)
Expand All @@ -64,18 +65,18 @@ dependencies {
implementation project(ProjectConfig.monitoring)
implementation project(ProjectConfig.device)

implementation AndroidLibConfig.sentry
implementation AndroidLibConfig.timber
implementation libs.sentry
implementation libs.timber

implementation project(Features.recipeCollection)
implementation project(Features.recipeDetail)
implementation project(Features.settings)
implementation project(Features.settingsTheme)
implementation project(Features.inAppUpdate)

testImplementation TestConfig.jUnit
testImplementation TestConfig.mockk
testImplementation libs.junit
testImplementation libs.mockk

// debugImplementation because LeakCanary should only run in debug builds.
debugImplementation AndroidLibConfig.leakCanary
debugImplementation libs.leak.canary
}
38 changes: 12 additions & 26 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,43 +1,29 @@
plugins {
// Need to declare all plugins here
alias(libs.plugins.android.application) apply false
alias(libs.plugins.android.library) apply false
alias(libs.plugins.kotlin.jvm) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.kotlin.kapt)
alias(libs.plugins.easylauncher) apply false
alias(libs.plugins.gradle.deps.update)
}

// Dependency version definitions
apply from: "project-config/dependencies.gradle"

// Dependency version checker
// Usage: ./gradlew dependencyUpdates -Drevision=release
apply plugin: "com.github.ben-manes.versions"
apply from: "project-config/dependencies-checker/dependencies-checker.gradle"

// Test coverage
// Usage ./gradlew jacocoTestReport
apply from: "$rootDir/quality/test-coverage-setup.gradle"

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
google()
gradlePluginPortal() // ben-manes
}
ext {
composeVersion = '1.3.2'
kotlinVersion = "1.7.20"
gradleVersion = '7.3.1'
}

dependencies {
classpath "com.android.tools.build:gradle:$gradleVersion"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
classpath "com.github.ben-manes:gradle-versions-plugin:0.43.0"
classpath "com.project.starter:easylauncher:5.1.2" // variant ribbon

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

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

Expand Down
27 changes: 14 additions & 13 deletions core-android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
apply plugin: "com.android.library"
apply plugin: 'kotlin-android'
plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin.android)
}

android {
compileSdkVersion AndroidConfig.compileSdk
buildToolsVersion AndroidConfig.buildTools
compileSdk libs.versions.compileSdk.get() as int

defaultConfig {
minSdkVersion AndroidConfig.minSdk
targetSdkVersion AndroidConfig.targetSdk
minSdk libs.versions.minSdk.get() as int
targetSdk libs.versions.compileSdk.get() as int
}

buildFeatures {
Expand All @@ -25,17 +26,17 @@ android {
}

dependencies {
implementation EnvironmentConfig.kotlinStdLib
implementation libs.kotlin.stdlib

implementation AndroidLibConfig.koinCore
implementation libs.koin.core

implementation AndroidLibConfig.retrofit
implementation AndroidLibConfig.moshiConverter
implementation AndroidLibConfig.moshi
implementation libs.retrofit
implementation libs.moshi.converter
implementation libs.moshi

implementation project(ProjectConfig.utilityAndroid)
implementation project(ProjectConfig.utilityKotlin)

testImplementation TestConfig.jUnit
testImplementation TestConfig.mockk
testImplementation libs.junit
testImplementation libs.mockk
}
6 changes: 3 additions & 3 deletions features/in-app-update/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ android {
}

dependencies {
implementation AndroidLibConfig.playCore
implementation AndroidLibConfig.playCoreExtensions
implementation AndroidLibConfig.fragment
implementation libs.play.core
implementation libs.play.core.extensions
implementation libs.fragment

implementation project(ProjectConfig.configuration)
implementation project(ProjectConfig.monitoring)
Expand Down
2 changes: 1 addition & 1 deletion features/recipe-collection/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ android {
}

dependencies {
implementation AndroidLibConfig.composeSwipeRefresh
implementation libs.compose.swipeRefresh

implementation project(ProjectConfig.analytics)
implementation project(ProjectConfig.device)
Expand Down
2 changes: 1 addition & 1 deletion features/recipe-detail/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ android {
}

dependencies {
implementation AndroidLibConfig.composeCollapsingToolbar
implementation libs.compose.collapsingToolbar

implementation project(ProjectConfig.analytics)
implementation project(ProjectConfig.device)
Expand Down
4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ org.gradle.parallel=true
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
kotlin.code.style=official
# Temporary solution for easylauncher plugin
android.disableResourceValidation=true
78 changes: 78 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
[versions]
gradleplugin = "7.3.1"
kotlin = "1.7.20"
minSdk = "23"
compileSdk = "33"
compose = "1.3.2"

[libraries]
# Kotlin
kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" }
kotlin-jdk = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "kotlin" }
coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version = "1.6.4" }
kotlin-result = { module = "com.michael-bull.kotlin-result:kotlin-result", version = "1.1.16" }

# Debug
leak-canary = { module = "com.squareup.leakcanary:leakcanary-android", version = "2.9.1" }

# Compose
compose-bom = { module = "androidx.compose:compose-bom", version = "2022.10.00" }
compose-ui = { module = "androidx.compose.ui:ui" }
compose-foundation = { module = "androidx.compose.foundation:foundation" }
compose-material = { module = "androidx.compose.material:material" }
compose-materialIcons = { module = "androidx.compose.material:material-icons-core" }
compose-materialIconsExt = { module = "androidx.compose.material:material-icons-extended" }
compose-tooling = { module = "androidx.compose.ui:ui-tooling" }
compose-activity = { module = "androidx.activity:activity-compose", version = "1.6.1" }
compose-swipeRefresh = { module = "com.google.accompanist:accompanist-swiperefresh", version = "0.27.0" }
compose-collapsingToolbar = { module = "me.onebone:toolbar-compose", version = "2.3.5" }

# Network related libraries
retrofit = { module = "com.squareup.retrofit2:retrofit", version = "2.9.0" }
okhttp = { module = "com.squareup.okhttp3:okhttp", version = "4.10.0" }
moshi-converter = { module = "com.squareup.retrofit2:converter-moshi", version = "2.9.0" }
moshi-codegen = { module = "com.squareup.moshi:moshi-kotlin-codegen", version = "1.14.0" }
moshi = { module = "com.squareup.moshi:moshi", version = "1.14.0" }

# Android components
appCompat = { module = "androidx.appcompat:appcompat", version = "1.5.1" }
viewmodel = { module = "androidx.lifecycle:lifecycle-viewmodel-ktx", version = "2.4.1" }
fragment = { module = "androidx.fragment:fragment-ktx", version = "1.5.4" }
material = { module = "com.google.android.material:material", version = "1.7.0" }

# Android utilities
play-core = { module = "com.google.android.play:core", version = "1.10.3" } # For in-App update
play-core-extensions = { module = "com.google.android.play:core-ktx", version = "1.8.1" }

# DI
koin-core = { module = "io.insert-koin:koin-core", version = "3.2.2" }
koin-android = { module = "io.insert-koin:koin-android", version = "3.3.0" }

# Image download library
coil = { module = "io.coil-kt:coil", version = "2.2.2" }
coil-compose = { module = "io.coil-kt:coil-compose", version = "2.2.2" }

# Crash reporting library
sentry = { module = "io.sentry:sentry-android", version = "6.7.0" }

# Analytics
amplitude = { module = "com.amplitude:android-sdk", version = "3.35.1" }

# Logging
timber = { module = "com.jakewharton.timber:timber", version = "5.0.1" }

# Testing
junit = { module = "junit:junit", version = "4.13.2"}
mockk = { module = "io.mockk:mockk", version = "1.13.2"}
coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version = "1.5.2"}

[bundles]

[plugins]
android-application = { id = "com.android.application", version.ref = "gradleplugin" }
android-library = { id = "com.android.library", version.ref = "gradleplugin" }
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
kotlin-kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kotlin" }
easylauncher = { id = "com.starter.easylauncher", version = "6.0.0" }
gradle-deps-update = { id = "com.github.ben-manes.versions", version = "0.43.0" }
23 changes: 12 additions & 11 deletions infrastructure/analytics-amplitude/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
apply plugin: "com.android.library"
apply plugin: 'kotlin-android'
plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin.android)
}

android {
compileSdkVersion AndroidConfig.compileSdk
buildToolsVersion AndroidConfig.buildTools
compileSdk libs.versions.compileSdk.get() as int

defaultConfig {
minSdkVersion AndroidConfig.minSdk
targetSdkVersion AndroidConfig.targetSdk
minSdk libs.versions.minSdk.get() as int
targetSdk libs.versions.compileSdk.get() as int
}

compileOptions {
Expand All @@ -21,13 +22,13 @@ android {
}

dependencies {
implementation EnvironmentConfig.kotlinStdLib
implementation libs.kotlin.stdlib

implementation AndroidLibConfig.koinCore
implementation AndroidLibConfig.koinAndroidExt
implementation libs.koin.core
implementation libs.koin.android

implementation AndroidLibConfig.amplitude
implementation AndroidLibConfig.timber
implementation libs.amplitude
implementation libs.timber

implementation project(ProjectConfig.utilityAndroid)
implementation project(ProjectConfig.utilityKotlin)
Expand Down
6 changes: 4 additions & 2 deletions infrastructure/analytics/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
apply plugin: 'kotlin'
plugins {
alias(libs.plugins.kotlin.jvm)
}

dependencies {
implementation EnvironmentConfig.kotlinJdk
implementation libs.kotlin.jdk
}
Loading

0 comments on commit 627f278

Please sign in to comment.