Skip to content
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

Project dependencies don't invalidate properly in the configuration cache #2815

Open
swankjesse opened this issue Jan 31, 2024 · 5 comments
Open

Comments

@swankjesse
Copy link
Collaborator

I’m using the Wire Gradle plugin and the Gradle configuration cache.

My Wire build includes this syntax:

  sourcePath {
    srcProject(":upstream-protos")
    include("file_a.proto")
    include("file_b.proto")
  }

Unfortunately when I make changes to upstream-protos my Wire project doesn’t rebuild enough, and produces an incorrect compilation result.

In the interim I’m using this to workaround:

    tasks.withType<WireTask> {
      notCompatibleWithConfigurationCache("Project dependencies don't invalidate properly")
    }

I can also use --no-configuration-cache as a workaround, but that’s more severe.

@oldergod
Copy link
Member

oldergod commented Feb 7, 2024

@martinbonnin tried to repro and wasn't able to.
If any of the .proto in upstream changes, he's getting

Calculating task graph as configuration cache cannot be reused because an input to unknown location has changed.

Would it be because another file than file_a and file_b is updated?

@martinbonnin
Copy link
Collaborator

What I did is there: https://github.com/martinbonnin/test-wire

git checkout https://github.com/martinbonnin/test-wire
cd test-wire
./gradlew :module2:generateProtos --configuration-cache
sed -i.old 's/picture_urls2/picture_urls/g' module1/src/main/protos/dino.proto
./gradlew :module2:generateProtos --configuration-cache
# Calculating task graph as configuration cache cannot be reused because an input to unknown location has changed.

And the output is technically correct but it theorically should be able to reuse the CC I think? So there might be different problems there?

@martinbonnin
Copy link
Collaborator

martinbonnin commented Feb 7, 2024

Did a bit more digging, my hunch is that the problem lies somewhere around here:

    return project.provider {
      configuration.dependencies.flatMap { dep ->
        val sortedFiles = configuration.files(dep).sortedWith(compareBy { it.name })
        sortedFiles.flatMap { file -> file.toLocations(project, dep) }
      }
    }

This provider here breaks the task dependency between upstream modules and the WireTask. So when the module changes, nothing tells WireTask to recompute. Maybe it worked before CC because of some other dependency, I'm not sure. Ideally, WireTask.sourceInput should be moved from sourceInput: ListProperty<InputLocation> to sourceInput: ConfigurableFileCollection.

I'll try to give it a shot well, that didn't turn out really well, it's more complicated than what I anticipated since the base path of the files is required. I think gradle/gradle#27836 would be quite useful here.

@swankjesse
Copy link
Collaborator Author

@swankjesse
Copy link
Collaborator Author

This too: #2848

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants