So i'm having this weird issue - I'm manually buil...
# android
j
So i'm having this weird issue - I'm manually building a data model for my app layer and then using KotlinPoet to generate a Room compliant version of the same model that I'm using as a Room entity. When I clean and build, Room can't find the generated model. The only path where Room can find the generated model is if I clean -> build -> change the order of my gradle dependencies -> re-sync -> build. In the last build, Room will find the generated models. Anyone have any idea why?
m
Where and how are you generating the Room entities? Perhaps Room is getting in before your code generator does.
j
yeah I think that's the problem, I've created my annotation processor in another module and I'm including that module within my app's gradle, so I have like:
Copy code
// Persistable
    implementation project(":persistable")
    kapt project(":persistable")

    implementation deps.jetpack.room
    implementation deps.jetpack.roomKtx
    implementation deps.jetpack.roomRx
    kapt deps.kapt.room
im just not sure if there's a way to force my processor to run first, and why changing the order of the dependencies and re-syncing always allows room to find the generated models
m
I have not written an annotation processor, so I don't know how the ordering rules work. However, unless this problem is unique to
kapt
, it is unlikely to be a Kotlin issue
j
i was under the impression that the order of which processors run is essentially random, and each time an annotation processor generates a new file, a new round of processing takes place, but perhaps not
☝️ 1
w
That should be the case as far as I know. If you generate some files with Room annotations, Room should process them too. Do you have incremental kapt on by chance? Perhaps it’s an issue with either incremental kapt or Room’s handling of incremental processing
e
If I understand annotation process correctly they will run in couple of pass until annotation processing is still needed
so It should not matter the order of processor since after your first phase room should pickup the generated code for processing
j
@wasyl I don't have incremental kapt on, i'm at the point where the first clean/build will fail but the second will pass, so for some reason even though i'm generating files with room annotation, a new round where Room uses those generated files isn't taking place