Skip to content

Commit

Permalink
Improvements for Gradle pre-compiled script plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitriy-chernysh committed Feb 17, 2024
1 parent e29f04b commit 084445a
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 6 deletions.
3 changes: 3 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ android {
dependencies {

implementation(libs.androidx.core.ktx)
coreLibraryDesugaring(libs.desugaring)
implementation(libs.bundles.lifecycle)

implementation(projects.core.navigation)

testApi(libs.bundles.test.common)
Expand Down
3 changes: 0 additions & 3 deletions build-logic/src/main/kotlin/core-compose-module.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,4 @@ dependencies {
api(platform(libs.library("compose.bom")))
api(libs.bundle("compose"))
debugApi(libs.bundle("compose.debug"))

androidTestApi(platform(libs.library("compose.bom")))
androidTestApi(libs.bundle("test.android"))
}
22 changes: 22 additions & 0 deletions build-logic/src/main/kotlin/core-module.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ android {
}

compileOptions {
android.compileOptions.isCoreLibraryDesugaringEnabled = true

targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_17
}
Expand All @@ -40,4 +42,24 @@ android {
println("# Compile SDK version: ${libs.versionStr("sdk.compile")}")
println("# Min SDK version: ${libs.versionStr("sdk.min")}")
println("# Compose Compiler version: ${libs.versionStr("compose.compiler")}")
}

android.sourceSets {
getByName("main") {
kotlin.srcDir("src/main/kotlin")
res.srcDir("src/main/res")
}

getByName("production") {
kotlin.srcDir("src/production/kotlin")
res.srcDir("src/production/res")
}
getByName("dev") {
kotlin.srcDir("src/dev/kotlin")
res.srcDir("src/dev/res")
}
}

dependencies {
coreLibraryDesugaring(libs.library("desugaring"))
}
4 changes: 4 additions & 0 deletions build-logic/src/main/kotlin/feature-module.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@ dependencies {
implementation(project(":core:di"))
implementation(project(":core:domain"))
implementation(project(":core:coroutines"))

implementation(libs.bundle("lifecycle"))
implementation(libs.library("coil"))
implementation(libs.library("activity.ktx"))
}
20 changes: 20 additions & 0 deletions build-logic/src/main/kotlin/testing-module.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
plugins {
id("core-module")
}

android.defaultConfig.testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

// It solve the issue with testing Coroutines Flow / ViewModel state
// and getting the error "app.cash.turbine.TurbineAssertionError: No value produced in 3s"
android.testOptions {
unitTests.isReturnDefaultValues = true
}

dependencies {
androidTestImplementation(platform(libs.library("compose.bom")))
androidTestImplementation(libs.bundle("test.android"))
androidTestImplementation(libs.bundle("test.koin"))

testImplementation(libs.bundle("test"))
testImplementation(libs.bundle("test.koin"))
}
2 changes: 1 addition & 1 deletion core/ui/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ plugins {
id("core-compose-module")
}
dependencies {
api(libs.bundles.lyfecycle)
api(libs.bundles.lifecycle)
api(libs.coil)
api(libs.lottie)
}
43 changes: 41 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# App
app-version-code = "1"
app-version-name = "0.1.0-alpha"
sdk-min = "24"
sdk-min = "29"
sdk-target = "34"
sdk-compile = "34"

Expand All @@ -11,6 +11,9 @@ android-gradle = "8.1.4"
kotlin = "1.9.22"
kotlin-coroutines = "1.7.3"
kotlin-serialization = "1.4.1"
google-services = "4.4.1"
plugin-crashlytics = "2.9.9"
plugin-performance = "1.4.2"

# Libs
android-core-ktx = "1.12.0"
Expand All @@ -24,8 +27,14 @@ compose-compiler = "1.5.8"
coil = "2.5.0"
material3 = "1.2.0"
koin = "3.5.3"
data-store = "1.0.0"
koin-compose = "3.5.3"
coroutines-android = "1.7.3"
workmanager = "2.9.0"
inapp-update = "2.1.0"

# Firebase
firebase-bom = "32.7.2"

# test libraries
test-junit = "4.13.2"
Expand All @@ -39,6 +48,9 @@ espresso-core = "3.5.1"

# 3rd party libs
lottie = "6.1.0"
desugaring = "2.0.4"
appcompat = "1.6.1"
material = "1.11.0"

[plugins]

Expand All @@ -47,11 +59,15 @@ android-library = { id = "com.android.library", version.ref = "android-gradle" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
kotlin-kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kotlin" }
kotlin-parcelize = { id = "org.jetbrains.kotlin.plugin.parcelize", version.ref = "kotlin" }
google-services = { id = "com.google.gms.google-services", version.ref = "google-services" }
crashlytics = { id = "com.google.firebase.crashlytics", version.ref = "plugin-crashlytics" }
performance-monitor = { id = "com.google.firebase.firebase-perf", version.ref = "plugin-performance" }

[libraries]

androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "android-core-ktx" }
activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activity" }
activity-ktx = { group = "androidx.activity", name = "activity-ktx", version.ref = "activity" }
lyfecycle-compose = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-compose", version.ref = "lifecycle" }
lyfecycle-runtime = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycle" }
lyfecycle-runtime-compose = { group = "androidx.lifecycle", name = "lifecycle-runtime-compose", version.ref = "lifecycle" }
Expand All @@ -61,7 +77,12 @@ kotlin-coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android
kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
gradle = { module = "com.android.tools.build:gradle", version.ref = "android-gradle" }
gradle-api = { module = "com.android.tools.build:gradle-api", version.ref = "android-gradle" }
data-store = { module = "androidx.datastore:datastore-preferences", version.ref = "data-store" }
coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "coroutines-android" }
workmanager = { module = "androidx.work:work-runtime-ktx", version.ref = "workmanager" }
desugaring = { module = "com.android.tools:desugar_jdk_libs", version.ref = "desugaring" }
inapp-update = { module = "com.google.android.play:app-update", version.ref = "inapp-update" }
inapp-update-ext = { module = "com.google.android.play:app-update-ktx", version.ref = "inapp-update" }

# Compose
compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "compose-bom" }
Expand Down Expand Up @@ -95,6 +116,19 @@ koin-core = { module = "io.insert-koin:koin-core", version.ref = "koin" }
koin-android = { module = "io.insert-koin:koin-android", version.ref = "koin" }
koin-compose = { module = "io.insert-koin:koin-androidx-compose", version.ref = "koin-compose" }
koin-compose-navigation = { module = "io.insert-koin:koin-androidx-compose-navigation", version.ref = "koin-compose" }
koin-workmanager = { module = "io.insert-koin:koin-androidx-workmanager", version.ref = "koin" }
koin-test = { module = "io.insert-koin:koin-test", version.ref = "koin" }
koin-test-junit = { module = "io.insert-koin:koin-test-junit4", version.ref = "koin" }

# Firebase
firebase-bom = { module = "com.google.firebase:firebase-bom", version.ref = "firebase-bom" }
firebase-crashlytics = { module = "com.google.firebase:firebase-crashlytics" }
firebase-analytics = { module = "com.google.firebase:firebase-analytics" }
firebase-performance = { module = "com.google.firebase:firebase-perf" }
firebase-messaging = { module = "com.google.firebase:firebase-messaging" }
androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
material = { group = "com.google.android.material", name = "material", version.ref = "material" }


[bundles]
compose = [
Expand All @@ -111,7 +145,7 @@ compose-debug = [
"compose-ui-manifest"
]

lyfecycle = [
lifecycle = [
"lyfecycle-compose",
"lyfecycle-runtime",
"lyfecycle-runtime-compose"
Expand All @@ -135,4 +169,9 @@ koin = [
"koin-android",
"koin-compose",
"koin-compose-navigation"
]

test-koin = [
"koin-test",
"koin-test-junit"
]

0 comments on commit 084445a

Please sign in to comment.