Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#586] Migrate to build version catalog (2/2) #596

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .cicdtemplate/.github/workflows/bump_version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:

- name: Bump version name
run: |
perl -i -pe 's/ANDROID_VERSION_NAME =(.*)$/ANDROID_VERSION_NAME = "${{ github.event.inputs.newVersion }}"/g' buildSrc/src/main/java/Versions.kt
perl -i -pe 's/androidVersionName =(.*)$/androidVersionName = "${{ github.event.inputs.newVersion }}"/g' gradle/libs.versions.toml
ryan-conway marked this conversation as resolved.
Show resolved Hide resolved

- name: Create pull request
uses: peter-evans/create-pull-request@v4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

- name: Read the current version
id: version
run: echo "version=$(perl -nle 'print $1 if /ANDROID_VERSION_NAME = \"(.*)\"$/' buildSrc/src/main/java/Versions.kt)" >> $GITHUB_OUTPUT
run: echo "version=$(perl -nle 'print $1 if /androidVersionName = \"(.*)\"$/' gradle/libs.versions.toml)" >> $GITHUB_OUTPUT

- uses: nimblehq/github-actions-workflows/[email protected]
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/bump_version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:

- name: Bump version Compose
run: |
perl -i -pe 's/ANDROID_VERSION_NAME =(.*)$/ANDROID_VERSION_NAME = "${{ github.event.inputs.newVersion }}"/g' sample-compose/buildSrc/src/main/java/Versions.kt
perl -i -pe 's/androidVersionName =(.*)$/androidVersionName = "${{ github.event.inputs.newVersion }}"/g' sample-compose/gradle/libs.versions.toml

- name: Create pull request
uses: peter-evans/create-pull-request@v4
Expand Down
104 changes: 47 additions & 57 deletions sample-compose/app/build.gradle.kts
ryan-conway marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
plugins {
id("com.android.application")

id("kotlin-android")
id("kotlin-kapt")
id("kotlin-parcelize")

id("dagger.hilt.android.plugin")

id("org.jetbrains.kotlinx.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 keystoreProperties = rootDir.loadGradleProperties("signing.properties")
Expand All @@ -30,13 +27,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
ryan-conway marked this conversation as resolved.
Show resolved Hide resolved
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 +70,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 @@ -116,68 +116,58 @@ kapt {
}

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

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

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(platform("androidx.compose:compose-bom:${Versions.COMPOSE_BOM_VERSION}"))
implementation("androidx.compose.ui:ui")
implementation("androidx.compose.ui:ui-tooling")
ryan-conway marked this conversation as resolved.
Show resolved Hide resolved
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)
debugImplementation(libs.compose.ui.tooling)

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should create new issue to deprecate this lib. Now this officially support in androidx.activity 💁‍♂️ https://google.github.io/accompanist/systemuicontroller/

image


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)
}

/*
ryan-conway marked this conversation as resolved.
Show resolved Hide resolved
* Kover configs
*/
dependencies {
kover(project(":data"))
kover(project(":domain"))
kover(projects.data)
kover(projects.domain)
}

koverReport {
Expand Down
36 changes: 11 additions & 25 deletions sample-compose/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,28 +1,14 @@
// 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.application) apply false
alias(libs.plugins.android.library) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.kotlin.jvm) 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) {
Expand All @@ -31,7 +17,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 +29,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
5 changes: 0 additions & 5 deletions sample-compose/buildSrc/src/main/java/Configurations.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,3 @@ object BuildType {
const val DEBUG = "debug"
const val RELEASE = "release"
}

object Module {
const val DATA = ":data"
const val DOMAIN = ":domain"
}
52 changes: 0 additions & 52 deletions sample-compose/buildSrc/src/main/java/Versions.kt

This file was deleted.

59 changes: 25 additions & 34 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 @@ -44,33 +43,25 @@ 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}")
implementation(projects.domain)

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)
}
Loading
Loading