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

Improve caching of protoc in GenerateProtoTask #1

Closed
wants to merge 1 commit into from

Conversation

clayburn
Copy link
Owner

@clayburn clayburn commented Apr 27, 2022

This change will remove the OS from the input properties of the
GenerateProtoTask. The expectation is that same versions of protoc
will produce same outputs regardless of the OS on which it was run.

If a protoc artifact is defined with GAV parameters, the classifier
and extension will not be considered part of the input. An exception is
made for snapshots, which will always be considered out of date and be
re-run.

If a protoc path is defined, then the path will be exposed as a File
Provider with absolute path normalization since there is no good way to
tell the version of protoc without running protoc --version.

See google#457.

@clayburn clayburn force-pushed the 457-generateProtoTask-protoc-caching branch 2 times, most recently from 35df827 to aa107a8 Compare April 27, 2022 21:09
@clayburn clayburn force-pushed the 457-generateProtoTask-protoc-caching branch 3 times, most recently from c1e0b45 to 07361fd Compare April 27, 2022 21:53
}

outputs.upToDateWhen {
!provider.getOrElse("").endsWith("-SNAPSHOT")
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't decide if it was worth trying to cache on snapshots. A typical plugin consumer isn't going to utilize them.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this eagerly resolves the provider when this function is called in order to add an output upToDate condition. i don't think this is a good practice.

@clayburn clayburn force-pushed the 457-generateProtoTask-protoc-caching branch from 07361fd to 4bdd52b Compare April 27, 2022 22:01
This change will remove the OS from the input properties of the
`GenerateProtoTask`. The expectation is that same versions of `protoc`
will produce same outputs regardless of the OS on which it was run.

If a protoc `artifact` is defined with GAV parameters, the classifier
and extension will not be considered part of the input. An exception is
made for snapshots, which will always be considered out of date and be
re-run.

If a protoc `path` is defined, then the path will be exposed as a File
Provider with absolute path normalization since there is no good way to
tell the version of `protoc` without running `protoc --version`.

See google#457.
@clayburn clayburn force-pushed the 457-generateProtoTask-protoc-caching branch from 4bdd52b to 8a7e414 Compare April 27, 2022 22:04
Copy link

@runningcode runningcode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you ask Gary or the build tool team if there is a better way of excluding the classifier here?

@InputFile
@PathSensitive(PathSensitivity.ABSOLUTE)
@Optional
Provider<File> getProtocPath() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the case where this absolute path is relevant to the output? the previous input had PathSensitivity.NONE

}

outputs.upToDateWhen {
!provider.getOrElse("").endsWith("-SNAPSHOT")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this eagerly resolves the provider when this function is called in order to add an output upToDate condition. i don't think this is a good practice.

@PathSensitive(PathSensitivity.NONE)
@Input
@Optional
Provider<String> getProtocArtifact() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this returns a single string as an input but the previous alternativePaths property could return a collection of files. do you know what the case is with multiple alternativePaths?

@clayburn clayburn closed this Apr 28, 2022
@clayburn clayburn deleted the 457-generateProtoTask-protoc-caching branch May 3, 2022 18:12
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.

2 participants