Improve task relocatability in Detekt and Protobuf plugins#49840
Improve task relocatability in Detekt and Protobuf plugins#49840erichaagdev wants to merge 2 commits intospring-projects:mainfrom
Conversation
Configures the `basePath` on Detekt tasks to use a relative path from the root project. This prevents absolute paths from being used during analysis, avoiding cross-machine build cache misses and ensuring the task is fully relocatable. See: detekt/detekt#7170 Signed-off-by: Eric Haag <ehaag@gradle.com>
Clears the `javaExecutablePath` on the Protobuf extension. This prevents absolute Java installation paths from being tracked as task inputs, avoiding cross-machine build cache misses and ensuring the task is fully relocatable. This is safe because `protoc` and `grpc` are configured to use native binaries rather than executable JARs. See: google/protobuf-gradle-plugin#785 Signed-off-by: Eric Haag <ehaag@gradle.com>
|
Thanks for the PR, Eric. I like the Kotlin change as that only affects our build. I don't think we should make the proposed change to the Protobuf plugin as that'll affect the builds of Boot's users and I don't think it's our place to do that. Could you please update your proposal to that effect? Can you also please use a branch other than main in your repo so that we can push changes to it prior to merging (for example, we'll want to switch the base branch to 3.5.x)? |
|
Hi, @wilkinsona. Yes, I can use a different branch name. Do you know if it's possible to rename it, or do I need to close & reopen a new PR? Regarding the Protobuf plugin issue, I agree and will remove the changes. However, the Spring Boot build is affected by this exact issue. I applied the changes to the wrong location by mistake. Should I reapply the changes to the Spring Boot build instead? |
Frustratingly, I don't think it's possible. I think close and re-open is in order. If it's not too much trouble, two separate PRs would be ideal. One for Kotlin using 3.5.x as the base branch and one for Protobuf using main as the base branch.
Thanks.
Yes please. |
|
New PR here: #49842 |
Overview
This PR improves build cache relocatability by fixing cross-machine cache misses in the Detekt and Protobuf tasks. Previously, absolute paths were leaking into task inputs, causing unnecessary cache invalidation between different environments (e.g., CI servers vs. local developer machines).
Changes
basePathon Detekt tasks to use a relative path from the root project. This prevents absolute paths from being used during analysis.javaExecutablePathon the Protobuf extension. This prevents absolute Java installation paths from being tracked as task inputs. (Note: This is safe becauseprotocandgrpcare configured to use native binaries rather than executable JARs).Impact
Normalizing these inputs ensures both tasks are fully relocatable. This will maximize remote build cache hits and prevent duplicate work across environments.
References
GenerateProtoTaskcaused by inputjavaExecutablePathgoogle/protobuf-gradle-plugin#785