Skip to content

Commit

Permalink
Dagger KSP.
Browse files Browse the repository at this point in the history
  • Loading branch information
ychescale9 committed Aug 31, 2023
1 parent e082e74 commit 67ebd99
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 52 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import java.time.Instant
plugins {
id("kstreamlined.android.application")
id("kstreamlined.android.application.compose")
id("kstreamlined.kapt")
id("kstreamlined.ksp")
id("com.google.dagger.hilt.android")
id("com.google.gms.google-services") apply false
id("com.google.firebase.firebase-perf")
Expand Down Expand Up @@ -243,7 +243,7 @@ dependencies {

// Hilt
implementation(libs.hilt.android)
kapt(libs.hilt.compiler)
ksp(libs.hilt.compiler)

// LeakCanary
debugImplementation(libs.leakcanary.android)
Expand Down
6 changes: 3 additions & 3 deletions build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ gradlePlugin {
id = "kstreamlined.kmm.test"
implementationClass = "io.github.reactivecircus.kstreamlined.buildlogic.convention.KMMTestConventionPlugin"
}
register("kapt") {
id = "kstreamlined.kapt"
implementationClass = "io.github.reactivecircus.kstreamlined.buildlogic.convention.KaptConventionPlugin"
register("ksp") {
id = "kstreamlined.ksp"
implementationClass = "io.github.reactivecircus.kstreamlined.buildlogic.convention.KspConventionPlugin"
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package io.github.reactivecircus.kstreamlined.buildlogic.convention

import com.google.devtools.ksp.gradle.KspExtension
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.configure

internal class KspConventionPlugin : Plugin<Project> {
override fun apply(target: Project) = with(target) {
with(pluginManager) {
apply("com.google.devtools.ksp")
}

extensions.configure<KspExtension> {
if (hasHiltCompilerDependency) {
arg("dagger.fastInit", "enabled")
arg("dagger.strictMultibindingValidation", "enabled")
arg("dagger.experimentalDaggerErrorMessages", "enabled")
}
}

// disable ksp tasks for unit tests
tasks.matching {
it.name.startsWith("ksp") && it.name.endsWith("UnitTestKotlin")
}.configureEach {
enabled = false
}
}
}

private val Project.hasHiltCompilerDependency: Boolean
get() = configurations.any {
it.dependencies.any { dependency ->
dependency.name == "hilt-compiler"
}
}
3 changes: 0 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ kotlin.compiler.keepIncrementalCompilationCachesInMemory=true
# try K2 compiler
kotlin.experimental.tryK2=true

# Enable kapt compile avoidance
kapt.include.compile.classpath=false

# Enable AndroidX
android.useAndroidX=true

Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fladle = "0.17.4"
nativeCoroutines = "1.0.0-ALPHA-18"
desugarJdkLibs = "2.0.3"
leakcanary = "2.12"
hilt = "2.47"
hilt = "2.48"
kotlinx-coroutines = "1.7.3"
kotlinx-datetime = "0.4.0"
firebase-analytics = "21.3.0"
Expand Down

0 comments on commit 67ebd99

Please sign in to comment.