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

[#575] [#586] Migrate to build version catalog #591

Merged
merged 6 commits into from
Jan 10, 2025
Merged
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
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)
ryan-conway marked this conversation as resolved.
Show resolved Hide resolved
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)
ryan-conway marked this conversation as resolved.
Show resolved Hide resolved
}
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)
ryan-conway marked this conversation as resolved.
Show resolved Hide resolved
}
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)
luongvo marked this conversation as resolved.
Show resolved Hide resolved
testImplementation(TURBINE)
}
testImplementation(libs.bundles.unitTest)
testImplementation(libs.test.core.ktx)
Copy link
Member

Choose a reason for hiding this comment

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

I know this is not needed for domain tests. However, I feel like we can add this dependency to the unitTest bundle. What do you think?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Unfortunately not, having this dependency on the :domain module breaks the tests 🙈

./gradlew koverHtmlReport output:
~/Projects/Nimble/android-templates/template-compose git:[645f7811]
kover

> Task :koverHtmlReport UP-TO-DATE
Kover: HTML report for ':' file:///Users/ryan/Projects/Nimble/android-templates/template-compose/build/reports/kover/html/index.html

> Task :domain:compileTestKotlin FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':domain:compileTestKotlin'.
> Could not resolve all files for configuration ':domain:testCompileClasspath'.
   > Could not resolve androidx.tracing:tracing:1.1.0.
     Required by:
         project :domain > androidx.test:core-ktx:1.6.1 > androidx.test:core:1.6.1
         project :domain > androidx.test:core-ktx:1.6.1 > androidx.test:core:1.6.1 > androidx.test:monitor:1.7.1
      > No matching variant of androidx.tracing:tracing:1.1.0 was found. The consumer was configured to find a library for use during compile-time, compatible with Java 17, preferably in the form of class files, preferably optimized for standard JVMs, and its dependencies declared externally, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' but:
          - Variant 'releaseVariantReleaseApiPublication' capability androidx.tracing:tracing:1.1.0 declares a library for use during compile-time, and its dependencies declared externally:
              - Incompatible because this component declares a component, with the library elements 'aar' and the consumer needed a component, preferably in the form of class files
              - Other compatible attributes:
                  - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
                  - Doesn't say anything about its target Java version (required compatibility with Java 17)
                  - Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'jvm')
          - Variant 'releaseVariantReleaseRuntimePublication' capability androidx.tracing:tracing:1.1.0 declares a library for use during runtime, and its dependencies declared externally:
              - Incompatible because this component declares a component, with the library elements 'aar' and the consumer needed a component, preferably in the form of class files
              - Other compatible attributes:
                  - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
                  - Doesn't say anything about its target Java version (required compatibility with Java 17)
                  - Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'jvm')
          - Variant 'sourcesElements' capability androidx.tracing:tracing:1.1.0 declares a component for use during runtime, and its dependencies declared externally:
              - Incompatible because this component declares documentation and the consumer needed a library
              - Other compatible attributes:
                  - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
                  - Doesn't say anything about its target Java version (required compatibility with Java 17)
                  - Doesn't say anything about its elements (required them preferably in the form of class files)
                  - Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'jvm')

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
47 actionable tasks: 6 executed, 41 up-to-date

Copy link
Member

Choose a reason for hiding this comment

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

Oh my bad, androidx.test:core only applies for Android modules: app & library, not pure Java module.

testImplementation(libs.test.turbine)
testImplementation(libs.test.robolectric)
}
Loading
Loading