Skip to content

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

Merged
YifeiZhuang merged 1 commit into
google:v0.9.xfrom
YifeiZhuang:backport3
Jul 13, 2023
Merged

Avoid eagerly resolving input files in ProtobufExtract (#713) (v0.9.x backport)#719
YifeiZhuang merged 1 commit into
google:v0.9.xfrom
YifeiZhuang:backport3

Conversation

@YifeiZhuang

Copy link
Copy Markdown
Contributor

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

TinyTrebuchet commented Jan 20, 2025

Copy link
Copy Markdown

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