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

Fix build caching for protoc plugin #1895

Merged
merged 2 commits into from
Oct 21, 2021
Merged

Conversation

rnett
Copy link
Contributor

@rnett rnett commented Oct 18, 2021

Fixes the issue brought up in #1853 (comment).

It does this by manually adding the plugin jar as a task input to the protoc tasks, ensuring that if the plugin sources (and thus jar) change the task will have a new cache key.

This ensures that the test proto files will be regenerated if the plugin sources change.
@rnett
Copy link
Contributor Author

rnett commented Oct 19, 2021

Looking through the rest of the codebase, there are multiple places where this occurs (wherever your protoc plugin is used, essentially). I don't know if they all have as severe an effect as this one, but they should all be fixed eventually. I wasn't planning on including it in this PR but I can if it's a big deal.

@chemicL
Copy link
Contributor

chemicL commented Oct 20, 2021

Thank you @rnett for spending the time on it. I verified that indeed the fix works for the tests in the servicetalk-grpc-protoc module, but like you mentioned other modules still use the previously cached version. The servicetalk-examples/grpc are especially affected by it. However it's not such a big deal as the validation of the code generation in the protoc module. Perhaps the improvements directly in the plugin will resolve this at some point. For now, I think this will save us from assuming our changes didn't break anything.

@chemicL chemicL merged commit 6b1a1f2 into apple:main Oct 21, 2021
idelpivnitskiy pushed a commit that referenced this pull request Nov 1, 2021
Motivation:

Recent introduction of Gradle caching mechanism caused the `Generator` class modifications to have no effect if the gRPC proto compiler plugin was already in the local cache. The build stages did not communicate properly that the prerequisites to generate proto classes have been changed and require assembling.

Modifications:

- Include protoc plugin as task input manually. This ensures that the test proto files will be regenerated if the plugin sources change,
- Use classpath normalization for protoc plugin jar file.

Result:

Tests in `servicetalk-grpc-protoc` module use the modified `Generator` class to generate classes.
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.

3 participants