Skip to content

Commit

Permalink
[#586] Migrate sample-compose to use gradle version catalog
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan-conway committed Jan 10, 2025
1 parent 8cca290 commit bb327d0
Show file tree
Hide file tree
Showing 8 changed files with 238 additions and 168 deletions.
83 changes: 39 additions & 44 deletions sample-compose/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ android {
}
}

compileSdk = Versions.ANDROID_COMPILE_SDK_VERSION
namespace = "co.nimblehq.sample.compose"
compileSdk = libs.versions.androidCompileSdk.get().toInt()
defaultConfig {
applicationId = "co.nimblehq.sample.compose"
minSdk = Versions.ANDROID_MIN_SDK_VERSION
targetSdk = Versions.ANDROID_TARGET_SDK_VERSION
versionCode = Versions.ANDROID_VERSION_CODE
versionName = Versions.ANDROID_VERSION_NAME
minSdk = libs.versions.androidMinSdk.get().toInt()
targetSdk = libs.versions.androidTargetSdk.get().toInt()
versionCode = libs.versions.androidVersionCode.get().toInt()
versionName = libs.versions.androidVersionName.get()
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

Expand Down Expand Up @@ -72,20 +73,22 @@ android {
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

kotlinOptions {
jvmTarget = JavaVersion.VERSION_11.toString()
jvmTarget = JavaVersion.VERSION_17.toString()
}

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

buildFeatures {
compose = true
buildConfig = true
}

packagingOptions {
Expand Down Expand Up @@ -119,57 +122,49 @@ dependencies {
implementation(project(Module.DATA))
implementation(project(Module.DOMAIN))

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

implementation("androidx.core:core-ktx:${Versions.ANDROIDX_CORE_KTX_VERSION}")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:${Versions.ANDROIDX_LIFECYCLE_VERSION}")
implementation("androidx.lifecycle:lifecycle-runtime-compose:${Versions.ANDROIDX_LIFECYCLE_VERSION}")
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))

implementation(platform("androidx.compose:compose-bom:${Versions.COMPOSE_BOM_VERSION}"))
implementation("androidx.compose.ui:ui")
implementation("androidx.compose.ui:ui-tooling")
implementation("androidx.compose.foundation:foundation")
implementation("androidx.compose.material:material")
implementation(libs.bundles.androidx)

implementation("androidx.navigation:navigation-compose:${Versions.COMPOSE_NAVIGATION_VERSION}")
implementation("com.google.accompanist:accompanist-permissions:${Versions.ACCOMPANIST_VERSION}")
implementation("com.google.accompanist:accompanist-systemuicontroller:${Versions.ACCOMPANIST_VERSION}")
implementation(platform(libs.compose.bom))
implementation(libs.bundles.compose)

implementation("androidx.datastore:datastore-preferences:${Versions.ANDROIDX_DATASTORE_PREFERENCES_VERSION}")
implementation(libs.accompanist.permissions)
implementation(libs.accompanist.systemUiController)

implementation("com.google.dagger:hilt-android:${Versions.HILT_VERSION}")
implementation("androidx.hilt:hilt-navigation-compose:${Versions.HILT_NAVIGATION_COMPOSE_VERSION}")
implementation(libs.androidx.datastore.preferences)

implementation("com.jakewharton.timber:timber:${Versions.TIMBER_LOG_VERSION}")
implementation(libs.bundles.hilt)
kapt(libs.hilt.compiler)

implementation("com.github.nimblehq:android-common-ktx:${Versions.ANDROID_COMMON_KTX_VERSION}")
implementation(libs.timber)

implementation("org.jetbrains.kotlin:kotlin-stdlib:${Versions.KOTLIN_VERSION}")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:${Versions.KOTLINX_COROUTINES_VERSION}")
implementation(libs.nimble.common)

kapt("com.google.dagger:hilt-compiler:${Versions.HILT_VERSION}")
implementation(libs.kotlin.stdlib)
implementation(libs.kotlinx.coroutines.core)

debugImplementation("com.github.chuckerteam.chucker:library:${Versions.CHUCKER_VERSION}")
releaseImplementation("com.github.chuckerteam.chucker:library-no-op:${Versions.CHUCKER_VERSION}")
debugImplementation(libs.chucker)
releaseImplementation(libs.chucker.noOp)

// Unit test
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:${Versions.KOTLINX_COROUTINES_VERSION}")
testImplementation("io.kotest:kotest-assertions-core:${Versions.TEST_KOTEST_VERSION}")
testImplementation("junit:junit:${Versions.TEST_JUNIT_VERSION}")
testImplementation("io.mockk:mockk:${Versions.TEST_MOCKK_VERSION}")
testImplementation("app.cash.turbine:turbine:${Versions.TEST_TURBINE_VERSION}")
testImplementation(libs.bundles.unitTest)
testImplementation(libs.test.turbine)

// UI test with Robolectric
testImplementation(platform("androidx.compose:compose-bom:${Versions.COMPOSE_BOM_VERSION}"))
testImplementation("androidx.compose.ui:ui-test-junit4")
testImplementation("androidx.test:rules:${Versions.TEST_RULES_VERSION}")
testImplementation("org.robolectric:robolectric:${Versions.TEST_ROBOLECTRIC_VERSION}")
testImplementation(platform(libs.compose.bom))
testImplementation(libs.test.compose.ui)
testImplementation(libs.test.rules)
testImplementation(libs.test.robolectric)

// UI test
androidTestImplementation(platform("androidx.compose:compose-bom:${Versions.COMPOSE_BOM_VERSION}"))
androidTestImplementation("androidx.compose.ui:ui-test-junit4")
androidTestImplementation("androidx.test:rules:${Versions.TEST_RULES_VERSION}")
androidTestImplementation("io.mockk:mockk-android:${Versions.TEST_MOCKK_VERSION}")
androidTestImplementation(platform(libs.compose.bom))
androidTestImplementation(libs.test.compose.ui)
androidTestImplementation(libs.test.rules)
androidTestImplementation(libs.test.mockk)
}

/*
Expand Down
33 changes: 8 additions & 25 deletions sample-compose/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,28 +1,11 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
}

dependencies {
classpath("com.android.tools.build:gradle:${Versions.BUILD_GRADLE_VERSION}")
classpath("com.google.dagger:hilt-android-gradle-plugin:${Versions.HILT_VERSION}")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.KOTLIN_VERSION}")
}
}

plugins {
id("io.gitlab.arturbosch.detekt").version(Versions.DETEKT_VERSION)
id("org.jetbrains.kotlinx.kover").version(Versions.KOVER_VERSION)
}

allprojects {
repositories {
google()
mavenCentral()
maven { url = uri("https://www.jitpack.io") }
}
alias(libs.plugins.android.library) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.kotlin.jvm) apply false
alias(libs.plugins.hilt) apply false
alias(libs.plugins.detekt)
alias(libs.plugins.kover)
}

tasks.register("clean", Delete::class) {
Expand All @@ -31,7 +14,7 @@ tasks.register("clean", Delete::class) {

tasks.withType<io.gitlab.arturbosch.detekt.Detekt>().configureEach {
// Target version of the generated JVM bytecode. It is used for type resolution.
jvmTarget = JavaVersion.VERSION_11.toString()
jvmTarget = JavaVersion.VERSION_17.toString()
reports {
xml {
outputLocation.set(file("build/reports/detekt/detekt.xml"))
Expand All @@ -43,7 +26,7 @@ tasks.withType<io.gitlab.arturbosch.detekt.Detekt>().configureEach {
}

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

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

This file was deleted.

57 changes: 24 additions & 33 deletions sample-compose/data/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
plugins {
id("com.android.library")
id("kotlin-android")

id("org.jetbrains.kotlinx.kover")
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kover)
}

android {
compileSdk = Versions.ANDROID_COMPILE_SDK_VERSION
namespace = "co.nimblehq.sample.compose.data"
compileSdk = libs.versions.androidCompileSdk.get().toInt()
defaultConfig {
minSdk = Versions.ANDROID_MIN_SDK_VERSION
targetSdk = Versions.ANDROID_TARGET_SDK_VERSION
minSdk = libs.versions.androidMinSdk.get().toInt()

consumerProguardFiles("consumer-rules.pro")
}
Expand All @@ -28,12 +27,12 @@ android {
}

compileOptions {
targetCompatibility = JavaVersion.VERSION_11
sourceCompatibility = JavaVersion.VERSION_11
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

kotlinOptions {
jvmTarget = JavaVersion.VERSION_11.toString()
jvmTarget = JavaVersion.VERSION_17.toString()
}

lintOptions {
Expand All @@ -46,31 +45,23 @@ android {
dependencies {
implementation(project(Module.DOMAIN))

implementation("androidx.core:core-ktx:${Versions.ANDROIDX_CORE_KTX_VERSION}")
implementation("androidx.datastore:datastore-preferences:${Versions.ANDROIDX_DATASTORE_PREFERENCES_VERSION}")
implementation("androidx.security:security-crypto:${Versions.ANDROID_CRYPTO_VERSION}")
implementation("com.google.dagger:hilt-android:${Versions.HILT_VERSION}")
implementation("com.squareup.moshi:moshi:${Versions.MOSHI_VERSION}")
implementation("org.jetbrains.kotlin:kotlin-stdlib:${Versions.KOTLIN_VERSION}")
implementation("javax.inject:javax.inject:${Versions.JAVAX_INJECT_VERSION}")

implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:${Versions.KOTLINX_COROUTINES_VERSION}")

api("com.squareup.retrofit2:converter-moshi:${Versions.RETROFIT_VERSION}")
api("com.squareup.retrofit2:retrofit:${Versions.RETROFIT_VERSION}")
implementation(libs.androidx.core)
implementation(libs.androidx.datastore.preferences)
implementation(libs.androidx.security.crypto)
implementation(libs.hilt.android)
implementation(libs.kotlin.stdlib)
implementation(libs.javax.inject)

api("com.squareup.moshi:moshi-adapters:${Versions.MOSHI_VERSION}")
api("com.squareup.moshi:moshi-kotlin:${Versions.MOSHI_VERSION}")
implementation(libs.kotlinx.coroutines.core)

api("com.squareup.okhttp3:okhttp:${Versions.OKHTTP_VERSION}")
api("com.squareup.okhttp3:logging-interceptor:${Versions.OKHTTP_VERSION}")
api(libs.bundles.retrofit)
api(libs.bundles.okhttp)
api(libs.bundles.moshi)
implementation(libs.moshi)

// Testing
testImplementation("junit:junit:${Versions.TEST_JUNIT_VERSION}")
testImplementation("io.mockk:mockk:${Versions.TEST_MOCKK_VERSION}")
testImplementation("io.kotest:kotest-assertions-core:${Versions.TEST_KOTEST_VERSION}")
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:${Versions.KOTLINX_COROUTINES_VERSION}")
testImplementation("androidx.test:core:${Versions.TEST_ANDROIDX_CORE_VERSION}")
testImplementation("org.robolectric:robolectric:${Versions.TEST_ROBOLECTRIC_VERSION}")
testImplementation("app.cash.turbine:turbine:${Versions.TEST_TURBINE_VERSION}")
testImplementation(libs.bundles.unitTest)
testImplementation(libs.test.core.ktx)
testImplementation(libs.test.robolectric)
testImplementation(libs.test.turbine)
}
21 changes: 8 additions & 13 deletions sample-compose/domain/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
plugins {
id("java-library")
id("kotlin")

id("org.jetbrains.kotlinx.kover")
id(libs.plugins.javaLibrary.get().pluginId)
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.kover)
}

java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

dependencies {
implementation("javax.inject:javax.inject:${Versions.JAVAX_INJECT_VERSION}")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:${Versions.KOTLINX_COROUTINES_VERSION}")
implementation(libs.kotlinx.coroutines.core)
implementation(libs.javax.inject)

// Testing
testImplementation("junit:junit:${Versions.TEST_JUNIT_VERSION}")
testImplementation("io.mockk:mockk:${Versions.TEST_MOCKK_VERSION}")
testImplementation("io.kotest:kotest-assertions-core:${Versions.TEST_KOTEST_VERSION}")
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:${Versions.KOTLINX_COROUTINES_VERSION}")
testImplementation(libs.bundles.unitTest)
}
Loading

0 comments on commit bb327d0

Please sign in to comment.