https://kotlinlang.org logo
#dagger
Title
# dagger
p

Paul Woitaschek

11/05/2019, 8:46 AM
How would I use dagger-reflect with a pure kotlin module? For the android modules I have set a
Dev
build type where I use dagger reflect and the
Debug
and
Release
build types use the regular dagger.
w

wasyl

11/05/2019, 8:55 AM
You could check a Gradle property and set proper dependency, something like
Copy code
if (hasProperty("daggerReflect") {
  implementation daggerReflect
} else {
  implementation daggerRegular
}
and pass property during build
./gradlew app:assemble -PdaggerReflect
. You can also set this property from the AS configuration settings as default one, or set dagger-reflect as the default and not use it in the CI etc.
p

Paul Woitaschek

11/05/2019, 2:56 PM
Thanks that worked 🙂
Hm but is there a way to check if the project that requests this is actually a release build? Because on release builds I don't want to use dagger reflect
w

wasyl

11/05/2019, 4:51 PM
If you want to guard against that I think the best you can use something like
project.gradle.taskGraph.whenReady
and check if you have any release tasks there
p

Paul Woitaschek

11/05/2019, 9:32 PM
Hm it seems that in general kotlin-android and pure kotlin don't go well together because of the missing buildvariant concept
4 Views