Skip to content

Commit

Permalink
Merge pull request #591 from nimblehq/feature/586-migrate-to-build-ve…
Browse files Browse the repository at this point in the history
…rsion-catalog

[#575] [#586] Migrate to build version catalog
  • Loading branch information
ryan-conway authored Jan 10, 2025
2 parents cc18919 + 8cca290 commit 692a83c
Show file tree
Hide file tree
Showing 10 changed files with 209 additions and 257 deletions.
93 changes: 35 additions & 58 deletions template-compose/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
import org.jetbrains.kotlin.konan.properties.loadProperties

plugins {
id(Plugins.ANDROID_APPLICATION)
id(Plugins.KOTLIN_ANDROID)
id(Plugins.KOTLIN_KAPT)
id(Plugins.KOTLIN_PARCELIZE)
id(Plugins.HILT_ANDROID)
id(Plugins.KOVER)
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlin.kapt)
alias(libs.plugins.kotlin.parcelize)
alias(libs.plugins.hilt)
alias(libs.plugins.kover)
}

val signingProperties = loadProperties("$rootDir/signing.properties")
val getVersionCode: () -> Int = {
if (project.hasProperty("versionCode")) {
(project.property("versionCode") as String).toInt()
} else {
Versions.ANDROID_VERSION_CODE
libs.versions.androidVersionCode.get().toInt()
}
}

android {
namespace = "co.nimblehq.template.compose"
compileSdk = Versions.ANDROID_COMPILE_SDK
compileSdk = libs.versions.androidCompileSdk.get().toInt()

defaultConfig {
applicationId = "co.nimblehq.template.compose"
minSdk = Versions.ANDROID_MIN_SDK
targetSdk = Versions.ANDROID_TARGET_SDK
minSdk = libs.versions.androidMinSdk.get().toInt()
targetSdk = libs.versions.androidTargetSdk.get().toInt()
versionCode = getVersionCode()
versionName = Versions.ANDROID_VERSION_NAME
versionName = libs.versions.androidVersionName.get()

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down Expand Up @@ -97,8 +97,9 @@ android {
buildConfig = true
}

// TODO Remove this block in https://github.com/nimblehq/android-templates/issues/587
composeOptions {
kotlinCompilerExtensionVersion = Versions.COMPOSE_COMPILER
kotlinCompilerExtensionVersion = "1.5.3"
}

packaging {
Expand Down Expand Up @@ -128,67 +129,43 @@ kapt {
}

dependencies {
implementation(project(Modules.DATA))
implementation(project(Modules.DOMAIN))
implementation(projects.data)
implementation(projects.domain)

implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))

with(Dependencies.AndroidX) {
implementation(CORE_KTX)
implementation(LIFECYCLE_RUNTIME_KTX)
implementation(LIFECYCLE_RUNTIME_COMPOSE)
implementation(DATASTORE_PREFERENCES)
}
implementation(libs.bundles.androidx)
implementation(libs.androidx.datastore.preferences)

with(Dependencies.Compose) {
implementation(platform(BOM))
implementation(UI)
debugImplementation(UI_TOOLING)
implementation(UI_TOOLING_PREVIEW)
implementation(MATERIAL)
implementation(NAVIGATION)
implementation(platform(libs.compose.bom))
implementation(libs.bundles.compose)
implementation(libs.accompanist.permissions)
debugImplementation(libs.compose.ui.tooling)

implementation(ACCOMPANIST_PERMISSIONS)
}
implementation(libs.bundles.hilt)
kapt(libs.hilt.compiler)

with(Dependencies.Hilt) {
implementation(ANDROID)
implementation(NAVIGATION_COMPOSE)
kapt(COMPILER)
}
implementation(libs.timber)
debugImplementation(libs.chucker)
releaseImplementation(libs.chucker.noOp)

with(Dependencies.Log) {
implementation(TIMBER)
implementation(libs.nimble.common)

debugImplementation(CHUCKER)
releaseImplementation(CHUCKER_NO_OP)
}
// Unit test
testImplementation(libs.bundles.unitTest)
testImplementation(libs.test.turbine)

with(Dependencies.Util) {
implementation(COMMON_KTX)
}

with(Dependencies.Test) {
// Unit test
testImplementation(COROUTINES)
testImplementation(JUNIT)
testImplementation(KOTEST)
testImplementation(MOCKK)
testImplementation(TURBINE)

// UI test with Robolectric
testImplementation(platform(Dependencies.Compose.BOM))
testImplementation(COMPOSE_UI_TEST_JUNIT)
testImplementation(ROBOLECTRIC)
}
// UI test with Robolectric
testImplementation(platform(libs.compose.bom))
testImplementation(libs.bundles.uiTest)
}

/*
* Kover configs
*/
dependencies {
kover(project(Modules.DATA))
kover(project(Modules.DOMAIN))
kover(projects.data)
kover(projects.domain)
}

koverReport {
Expand Down
18 changes: 10 additions & 8 deletions template-compose/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id(Plugins.ANDROID_APPLICATION) version Versions.GRADLE apply false
id(Plugins.ANDROID_LIBRARY) version Versions.GRADLE apply false
id(Plugins.KOTLIN_JVM) version Versions.KOTLIN apply false
id(Plugins.KOTLIN_ANDROID) version Versions.KOTLIN apply false
id(Plugins.HILT_ANDROID) version Versions.HILT apply false
id(Plugins.DETEKT) version Versions.DETEKT
id(Plugins.KOVER) version Versions.KOVER
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) apply false
alias(libs.plugins.kotlin.parcelize) apply false
alias(libs.plugins.hilt) apply false
alias(libs.plugins.detekt)
alias(libs.plugins.kover)
}

tasks.register("clean", Delete::class) {
delete(rootProject.buildDir)
}

detekt {
toolVersion = Versions.DETEKT
toolVersion = libs.versions.detekt.get()

source = files(
"app/src/main/java",
Expand Down
71 changes: 0 additions & 71 deletions template-compose/buildSrc/src/main/java/Dependencies.kt

This file was deleted.

4 changes: 0 additions & 4 deletions template-compose/buildSrc/src/main/java/Modules.kt

This file was deleted.

16 changes: 0 additions & 16 deletions template-compose/buildSrc/src/main/java/Plugins.kt

This file was deleted.

49 changes: 0 additions & 49 deletions template-compose/buildSrc/src/main/java/Versions.kt

This file was deleted.

52 changes: 18 additions & 34 deletions template-compose/data/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
plugins {
id(Plugins.ANDROID_LIBRARY)
id(Plugins.KOTLIN_ANDROID)
id(Plugins.KOVER)
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kover)
}

android {
namespace = "co.nimblehq.template.compose.data"
compileSdk = Versions.ANDROID_COMPILE_SDK
compileSdk = libs.versions.androidCompileSdk.get().toInt()

defaultConfig {
minSdk = Versions.ANDROID_MIN_SDK
minSdk = libs.versions.androidMinSdk.get().toInt()

consumerProguardFiles("consumer-rules.pro")
}
Expand Down Expand Up @@ -44,37 +44,21 @@ android {
}

dependencies {
implementation(project(Modules.DOMAIN))
implementation(projects.domain)

with(Dependencies.AndroidX) {
implementation(CORE_KTX)
implementation(DATASTORE_PREFERENCES)
implementation(SECURITY_CRYPTO)
}

with(Dependencies.Hilt) {
implementation(JAVAX_INJECT)
}
implementation(libs.androidx.core)
implementation(libs.androidx.datastore.preferences)
implementation(libs.androidx.security.crypto)

with(Dependencies.Network) {
api(RETROFIT)
api(RETROFIT_CONVERTER_MOSHI)
implementation(libs.javax.inject)

api(OKHTTP)
api(OKHTTP_LOGGING_INTERCEPTOR)
api(libs.bundles.retrofit)
api(libs.bundles.okhttp)
api(libs.moshi)
implementation(libs.bundles.moshi)

api(MOSHI)
implementation(MOSHI_ADAPTERS)
implementation(MOSHI_KOTLIN)
}

with(Dependencies.Test) {
testImplementation(COROUTINES)
testImplementation(JUNIT)
testImplementation(KOTEST)
testImplementation(MOCKK)
testImplementation(ROBOLECTRIC)
testImplementation(TEST_CORE)
testImplementation(TURBINE)
}
testImplementation(libs.bundles.unitTest)
testImplementation(libs.test.core.ktx)
testImplementation(libs.test.turbine)
testImplementation(libs.test.robolectric)
}
Loading

0 comments on commit 692a83c

Please sign in to comment.