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

Avoid eagerly resolving input files in ProtobufExtract (#713) (v0.9.x backport) #719

Merged
merged 1 commit into from
Jul 13, 2023

Conversation

YifeiZhuang
Copy link
Collaborator

Rely on FileCollection.getElements() (available in Gradle 5.6+) to ensure no files are accessed eagerly during configuration. This also ensures configuration cache key does not depend on them.

Fixes issue #711.

Test: Added "testProjectDependent proto extraction with configuration cache" with Gradle 8.1

backport of #713

Rely on FileCollection.getElements() (available in Gradle 5.6+) to
ensure no files are accessed eagerly during configuration. This also
ensures configuration cache key does not depend on them.

Fixes issue google#711.

Test: Added "testProjectDependent proto extraction with configuration cache" with Gradle 8.1
@YifeiZhuang YifeiZhuang requested a review from ejona86 July 13, 2023 17:21
@YifeiZhuang YifeiZhuang merged commit 4502c7e into google:v0.9.x Jul 13, 2023
@YifeiZhuang YifeiZhuang deleted the backport3 branch July 13, 2023 18:57
@TinyTrebuchet
Copy link

TinyTrebuchet commented Jan 20, 2025

Hi @YifeiZhuang , I was facing a similar issue, and was checking out your fix, but had trouble understanding it.

If I am not wrong, aren't these two things effectively the same?

Create a provider, so that inputFiles.files is accessed lazily during execution, when the tasks queries the fileCollection and the sources added need to be resolved.

return objectFactory.fileCollection()
        .from(providerFactory.provider { unused ->
          Set<File> files = inputFiles.files
          // use files

Use FileCollection.getElements() which is also just provides Provider for accessing inputFile.files

return objectFactory.fileCollection()
        .from(inputFiles.getElements().map { files ->
          // use files

How does the former change access inputFiles.files eagerly?

Vampire added a commit to Vampire/protobuf-gradle-plugin that referenced this pull request Jan 20, 2025
Vampire added a commit to Vampire/protobuf-gradle-plugin that referenced this pull request Jan 22, 2025
Vampire added a commit to Vampire/protobuf-gradle-plugin that referenced this pull request Jan 22, 2025
Vampire added a commit to Vampire/protobuf-gradle-plugin that referenced this pull request Jan 22, 2025
Vampire added a commit to Vampire/protobuf-gradle-plugin that referenced this pull request Jan 22, 2025
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

Successfully merging this pull request may close these issues.

4 participants