Skip to content

Commit

Permalink
Merge pull request #3267 from CruGlobal/circuitCodegen
Browse files Browse the repository at this point in the history
Centralize Circuit configuration and enable hilt codegen
  • Loading branch information
frett authored Dec 12, 2023
2 parents 14d8cf3 + 88f4ac9 commit 5b0408d
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 44 deletions.
5 changes: 1 addition & 4 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
plugins {
id("godtools.application-conventions")
id("kotlin-parcelize")
alias(libs.plugins.firebase.appdistribution)
alias(libs.plugins.firebase.crashlytics)
alias(libs.plugins.firebase.perf)
Expand All @@ -13,7 +12,7 @@ plugins {
android {
namespace = "org.cru.godtools"

configureCompose(project)
configureCompose(project, enableCircuit = true)
configureGodToolsCustomUri()

defaultConfig {
Expand Down Expand Up @@ -201,8 +200,6 @@ dependencies {
implementation(libs.godtoolsShared.common)

api(libs.eventbus)
implementation(libs.circuit.codegen.annotations)
implementation(libs.circuit.foundation)
implementation(libs.coil.compose)
implementation(libs.compose.reorderable)
implementation(libs.hilt)
Expand Down

This file was deleted.

1 change: 1 addition & 0 deletions build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ dependencies {
implementation(libs.json)
implementation(libs.kotlin.gradlePlugin)
implementation(libs.kotlin.kover.gradlePlugin)
implementation(libs.ksp.gradlePlugin)
implementation(libs.onesky.gradlePlugin)
}

Expand Down
12 changes: 11 additions & 1 deletion build-logic/src/main/kotlin/AndroidConfiguration.kt
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ fun BaseExtension.configureFlavorDimensions(project: Project) {
// TODO: provide Project using the new multiple context receivers functionality.
// this is prototyped in 1.6.20 and will reach beta after Kotlin 2.0
// context(Project)
fun CommonExtension<*, *, *, *, *>.configureCompose(project: Project) {
fun CommonExtension<*, *, *, *, *>.configureCompose(project: Project, enableCircuit: Boolean = false) {
buildFeatures.compose = true
composeOptions.kotlinCompilerExtensionVersion =
project.libs.findVersion("androidx-compose-compiler").get().requiredVersion
Expand All @@ -120,6 +120,16 @@ fun CommonExtension<*, *, *, *, *>.configureCompose(project: Project) {
addProvider("debugImplementation", project.libs.findBundle("androidx-compose-debug").get())
addProvider("testDebugImplementation", project.libs.findBundle("androidx-compose-testing").get())
}

if (enableCircuit) {
project.pluginManager.apply("com.google.devtools.ksp")
project.pluginManager.apply("kotlin-parcelize")

project.dependencies.addProvider("implementation", project.libs.findBundle("circuit").get())
project.dependencies.addProvider("ksp", project.libs.findLibrary("circuit-codegen").get())

project.ksp.arg("circuit.codegen.mode", "hilt")
}
}

// TODO: provide Project using the new multiple context receivers functionality.
Expand Down
2 changes: 2 additions & 0 deletions build-logic/src/main/kotlin/Project.kt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import com.android.build.api.variant.AndroidComponentsExtension
import com.google.devtools.ksp.gradle.KspExtension
import org.gradle.api.Action
import org.gradle.api.Project
import org.gradle.api.artifacts.VersionCatalogsExtension
Expand All @@ -13,3 +14,4 @@ internal fun Project.kapt(configure: KaptExtension.() -> Unit) = extensions.conf
internal val Project.libs get() = project.extensions.getByType<VersionCatalogsExtension>().named("libs")
internal val Project.androidComponents
get() = project.extensions.getByName("androidComponents") as AndroidComponentsExtension<*, *, *>
internal val Project.ksp get() = project.extensions.getByType<KspExtension>()
6 changes: 5 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ gtoSupport = "4.2.0-SNAPSHOT"
kotlin = "1.9.21"
kotlinCoroutines = "1.7.3"
kotlinKover = "0.7.5"
ksp = "1.9.21-1.0.15"
ktlint = "1.0.1"
ktlintGradle = "12.0.3"
lottie = "6.2.0"
Expand Down Expand Up @@ -78,6 +79,7 @@ androidx-viewpager2 = { module = "androidx.viewpager2:viewpager2", version.ref =
androidx-work = { module = "androidx.work:work-runtime", version.ref = "androidx-work" }
androidx-work-ktx = { module = "androidx.work:work-runtime-ktx", version.ref = "androidx-work" }
appsflyer = "com.appsflyer:af-android-sdk:6.12.4"
circuit-codegen = { module = "com.slack.circuit:circuit-codegen", version.ref = "circuit" }
circuit-codegen-annotations = { module = "com.slack.circuit:circuit-codegen-annotations", version.ref = "circuit" }
circuit-foundation = { module = "com.slack.circuit:circuit-foundation", version.ref = "circuit" }
circuit-test = { module = "com.slack.circuit:circuit-test", version.ref = "circuit" }
Expand Down Expand Up @@ -173,6 +175,7 @@ kotlin-gradlePlugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", ve
kotlin-kover-gradlePlugin = { module = "org.jetbrains.kotlinx:kover-gradle-plugin", version.ref = "kotlinKover" }
kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" }
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }
ksp-gradlePlugin = { module = "com.google.devtools.ksp:symbol-processing-gradle-plugin", version.ref = "ksp" }
ktlint-gradle = { module = "org.jlleitschuh.gradle:ktlint-gradle", version.ref = "ktlintGradle" }
leakcanary = "com.squareup.leakcanary:leakcanary-android:2.12"
lottie = { module = "com.airbnb.android:lottie", version.ref = "lottie" }
Expand Down Expand Up @@ -217,6 +220,7 @@ ktlint = { module = "com.pinterest.ktlint:ktlint-cli", version.ref = "ktlint" }
androidx-compose = ["androidx-compose-runtime", "androidx-compose-ui", "androidx-compose-ui-tooling-preview"]
androidx-compose-debug = ["androidx-compose-ui-test-manifest", "androidx-compose-ui-tooling"]
androidx-compose-testing = ["androidx-compose-ui-test", "circuit-test"]
circuit = ["circuit-foundation", "circuit-codegen-annotations"]
common = ["kotlin-stdlib", "timber"]
test-framework = ["junit", "kotlin-test", "androidx-test-junit", "mockk", "robolectric"]

Expand All @@ -227,5 +231,5 @@ firebase-perf = { id = "com.google.firebase.firebase-perf", version = "1.4.2" }
google-services = { id = "com.google.gms.google-services", version = "4.4.0" }
grgit = { id = "org.ajoberstar.grgit", version = "5.2.1" }
hilt = { id = "com.google.dagger.hilt.android", version.ref = "dagger" }
ksp = { id = "com.google.devtools.ksp", version = "1.9.21-1.0.15" }
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlintGradle" }

0 comments on commit 5b0408d

Please sign in to comment.