any Anvil user noticing builds breaking after any ...
# dagger
u
any Anvil user noticing builds breaking after any change to dagger code? (say adding a parameter in @Provides functions), fails with
...:compileWithJavac
Cannot find symbol FooModule_XYZFactory
cant pinpoint if its dagger or anvil causing this ..
w
Definitely anvil, incremental compilation changes aren't picked up
There's an open issue about multibindings changes not being picked up, too. Rerunning kotlin compilation task for that module with the failing class fixes the issue
u
clean build fixes it yea but its costing me so much time
w
I'm saying it's Anvil because it started happening for us after we switched to anvil to generate dagger modules. And it's changes to anvil-only module that don't properly regenerate classes
u
how recent is that? because im anvil user since1.0 (or whenever they added the ability to generate dagger factories) and this for sure wasnt happening
w
We migrated some time this year? Couple of months back at most. It might correlate with Kotlin 1.9
u
so you just clean build all the time?
w
Rerun the tasks when it happens, yes 😢 although it's not happening constantly. It is annoying though, yeah. I wanted to open a new issue for both anvil and JB but haven't gotten around to writing a proper repro
u
I presume this doesnt happen on hello world projects..
w
Haven't tried 😅 for me it's definitely related to switching branches and pulling new changes from vcs
r
No need to file a new ticket, it’s covered in https://github.com/square/anvil/issues/693 This issue started to happen with Kotlin’s new incremental compiler and Kotlin 1.8.22 and later.
☝️ 2
u
is there a more lightweight solution to workaround it other than a clean build? that is killing me, since it's happening to me on any dagger change, not just switching branches etc
w
You can rerun a single compilation task,
./gradlew failingModule:compileKotlin --rerun
. If you have more modules it's not that heavy
Ralf is there an issue I can track on YouTrack for this?
u
when ksp dagger comes online, will it alleviate the issue? i.e. when ksp dagger, then one can remove the
Copy code
anvil {
    generateDaggerFactories.set(true)
}
?
generateDaggerFactories
is basically just a optimization to not run
kapt
everywhere, right?
w
Since it uses the same ksp infrastructure as anvil (?), I feel it might have the same problem
u
idk but I feel like anvil generatedaggerblabla doesnt generate kotlin source as ksp does, but is one level deeper
r
No, Dagger KSP doesn’t have this issue, because they use a separate Kotlin compilation task.
It’s the opposite, Anvil generates Kotlin but Dagger KSP generates Java
u
btw how will that play together in the future? will
generateDaggerFactories
become deprecated and anvil will send people to use ksp dagger? (and anvil just do anvil multimodule-meta-dagger stuff it's advertising?)
r
Not sure yet. Keep in mind that
generateDaggerFactories
is totally optional and only a build performance optimization
u
yea hence me asking if its obsolete once kapt is ritually murdered 😄
😂 1
j
It's possible -- we'll likely do some benchmarks to see if there are still any performance gains with
generateDaggerFactories
before making any decisions.