Skip to content

Make Gradle evaluation lazier and fix deprecation warnings#1826

Merged
wmdietl merged 11 commits into
masterfrom
lazy-gradle
Jun 19, 2026
Merged

Make Gradle evaluation lazier and fix deprecation warnings#1826
wmdietl merged 11 commits into
masterfrom
lazy-gradle

Conversation

@wmdietl

@wmdietl wmdietl commented Jun 19, 2026

Copy link
Copy Markdown
Member

No description provided.

wmdietl added 11 commits June 19, 2026 10:29
output of its own task, copied from shadowJar's archive via a tracked
input. shadowJar's pre-existing doLast block still did the same copy
itself, which was:

  - redundant whenever both tasks ran, and
  - an undeclared side effect of shadowJar, so it doesn't run on a
    build-cache hit for shadowJar (only declared outputs are restored
    on a cache hit; this doLast block would simply not execute).

assembleForJavac is now the only place that produces dist/checker.jar,
with proper inputs/outputs tracking. Nothing else in the build depends
on shadowJar alone to populate dist/; everything that needs dist/checker.jar
(exampleTests, demosTests, templateforaCheckerTests, etc.) already depends
on assembleForJavac.
pattern untouched: configuring a built-in task by its bare name (jar { },
test { }, javadoc { }, clean { }, compileJava { }, shadowJar { },
sourcesJar { }, generateGitProperties.dependsOn(...), etc.). That access
pattern realizes the task immediately when the build script line runs,
regardless of what was actually requested -- exactly what task
configuration avoidance is meant to prevent, and a needless cost on every
Gradle invocation across nearly every subproject.

Replace these with 'tasks.named("name") { ... }' (or a lazy
'dependsOn("taskName")' string reference instead of the task object)
everywhere a built-in task is configured directly by name:
build.gradle, checker/build.gradle, checker-qual/build.gradle,
framework/build.gradle, framework-test/build.gradle, and
framework-perf/build.gradle.

Not touched: checker/build.gradle's 'relocators = shadowJar.getRelocators()'
inside the checkerJar task registration. That's a genuine cross-task data
read (checkerJar needs shadowJar's already-configured relocators), already
inside a lazy 'tasks.register' block, and isn't a clean drop-in fix --
left as a known, lower-impact remaining case.
…ectly

at configuration time, but javacutil is declared after framework in
settings.gradle's include order, with nothing forcing javacutil's
build.gradle to evaluate first. That only works today because
javacutil/build.gradle never customizes its sourceSets (so the default
convention Gradle creates before any user script runs happens to be
correct); it's not something Gradle guarantees, and would silently break
if javacutil's sourceSets were ever customized.

Add evaluationDependsOn(':javacutil'), matching the existing guard
checker-qual-android/build.gradle already has for its own direct read of
checker-qual's sourceSets. dataflow doesn't need the same treatment here:
it's declared before framework already, so default evaluation order
already covers it.

This still leaves the underlying pattern (reading another project's
mutable sourceSets directly, rather than through a consumable
configuration or task-output Provider) in place; evaluationDependsOn
is the targeted, low-risk fix for the immediate ordering hazard, not a
replacement for that larger refactor.
configuration in between) by destinationDir.deleteDir() in the same task
registration block, with nothing in between that reads or writes into the
directory. Net effect is the directory doesn't exist either way before
the Javadoc task itself runs and creates it as needed -- the pair is dead
code, not a deliberate 'create then clean' step. Removing both has no
behavioral effect.
@wmdietl wmdietl changed the title Make Gradle evaluation lazy and fix deprecation warnings Make Gradle evaluation lazier and fix deprecation warnings Jun 19, 2026
@wmdietl wmdietl enabled auto-merge (squash) June 19, 2026 20:58
@wmdietl wmdietl merged commit eb8a76f into master Jun 19, 2026
42 checks passed
@wmdietl wmdietl deleted the lazy-gradle branch June 19, 2026 22:38
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.

1 participant