Make generateJava cacheable and relocatable - #967
Merged
Merged
Conversation
iuliiasobolevska
requested review from
asibross,
iparadiso,
jjacobs44,
kilink,
kzwang and
srinivasankavitha
as code owners
September 23, 2026 15:40
jiholee17
approved these changes
Sep 23, 2026
iuliiasobolevska
force-pushed
the
perf/cacheable-generate-java
branch
from
September 23, 2026 20:35
c1963d1 to
c488b60
Compare
iuliiasobolevska
force-pushed
the
perf/cacheable-generate-java
branch
from
September 24, 2026 00:50
c488b60 to
11c5109
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GenerateJavaTaskcacheable with relative schema inputs and lazyDirectoryPropertyoutputsgeneratedSourcesDir,schemaPaths,getOutputDir, andgetExampleOutputDirDSL/JVM accessors as compatibility bridgesValidation
BUILD SUCCESSFULon Gradle 9.4.1. The cross-directory TestKit test reportsFROM-CACHE; the unchanged local rerun reportsUP-TO-DATE; changed scalar, boolean, map, list, and schema inputs execute the task again.Adversarial review
An independent line-by-line review of commit
c1963d11found no correctness issues after verification:doNotCacheIfto always return false makes the timestamped-annotation test fail because the second workspace goesFROM-CACHE, proving the opt-out test detects the regressionvalidatePlugins --rerunpasses without missing-annotation or overlapping-output warnings, including the twoDirectoryPropertyoutputs and the@Internalcompatibility accessorsThe review also confirmed that the self-assignment in
initintentionally invokes the custom setter for the initialized default,flatMap(GenerateJavaTask::generatedSourcesDirectory)preserves lazy source-set wiring, and the cache predicate reads the final configured values at execution time.The example output directory remains outside Gradle source-set wiring, as it was before this change; that pre-existing behavior is out of scope.
Benchmark
An external consumer fixture using a shared local cache executed
generateJavain the first workspace and restored itFROM-CACHEin a second absolute workspace path. The generated output trees were byte-identical. End-to-end wall time was 19.51s for the initial included-build run and 0.88s for the warm cached run. This is directional because the first number includes daemon and included-build setup; the material result is that code generation is skipped entirely on the cache hit.