-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Anvil causes Gradle tasks to be non-cacheable #1039
Comments
Thanks for the report. That warning message means that some other task is declaring that directory, that file, or some other parent directory as its own output. The warning will only happen when both of the tasks are actually configured and in the task graph, which might explain why it only sometimes happens with library modules. The Anvil plugin creates cache directories that are unique to each build variant (e.g., To find the other task, you can add an assertion against the output files of other tasks. For example, to find out the culprit for val overlapped = generateSequence(
file("build/anvil/devDebug/caches/generated-file-cache.bin"),
) { it.parentFile }
.takeWhile { it != rootDir }
.toList()
tasks.named { it != "compileDevDebugKotlin" }.configureEach {
doLast {
val overlaps = overlapped.filter { outputs.files.contains(it) }
check(overlaps.isEmpty()) {
"Overlapping output files:\n${overlaps.joinToString("\n")}"
}
}
} After that, if you just run the same task(s) that prompted the warning before, it should tell you where the overlap is coming from. |
Thanks @RBusarow for getting back to me so quickly. I tried this but none of the tasks seem to have an overlap while I still get the overlapping output message in the Gradle build scan. I had to convert the script to Groovy because we haven't converted all of our build files to Kotlin yet but I think this should work:
I put in print statements to verify that there's indeed no overlap (there isn't). I am working through past releases of our app to see when this starts happening. I don't see the issue with Anvil 2.4.9 but will keep testing. |
I can say with a high level of certainty that the issue was introduced with a 2.5.0-beta0X version. I don't see it with 2.4.9 and it shows the moment we updated to 2.5.0-beta03 which we did because of #693. I just tested with 2.5.0-beta10 and still the same issue. |
Duplicate of #821 mentioned in #693 (comment)? |
After running more tests, I found that three of our Gradle projects show that error when we run all tasks (--rerun-tasks): What they have in common is that kapt is running the Dagger compiler. I removed it from the two library modules using My assumption is that there is some interaction between kapt and the Anvil plugin. |
I was able to reproduce the issue in a sample app that I pushed to Github: https://github.com/1gravity/anvil-tests. When I make a change in the app module and run I would very much appreciate if someone could try this and give me some guidance on what needs to change |
Thanks for the repro. It seems to be an issue with KAPT. If you run this, the problem goes away: ./gradlew :app:compileDebugKotlin -x :app:kaptDebugKotlin It's not immediately apparent to me why that's happening. I should have time to dig into it more this evening. |
Just +1'ing this. We're seeing the same. |
This is an issue only when |
I am seeing the same issue. +1 |
When analyzing our Gradle builds, we see that the Kotlin compile task cannot be cached by Gradle. The error message always shows for the app module and sometimes also for library modules:
Kind TASK
Path :mobile:compileDevDebugKotlin
Type org.jetbrains.kotlin.gradle.tasks.KotlinCompile
Dagger 2.51.1
Anvil 2.5.0-beta09
Kotlin 1.9.23
com.squareup.anvil.trackSourceFiles=true
This is an issue for us since non-cacheable tasks increase the local builds times considerably
The text was updated successfully, but these errors were encountered: