Skip to content

Fix build cache hits for FindMainClassTask and GroovyPageForkCompileTask - #15537

Merged
matrei merged 2 commits into
apache:7.0.xfrom
ribafish:fix-findmainclass-cache-hits
Mar 31, 2026
Merged

matrei merged 2 commits into
apache:7.0.xfrom
ribafish:fix-findmainclass-cache-hits

Conversation

@ribafish

Copy link
Copy Markdown
Contributor

Summary

FindMainClassTask: remove upToDateWhen preventing cache hits

  • Remove outputs.upToDateWhen closure that checked if the cache file exists — per Gradle docs, returning false prevents both up-to-date checks and build cache loading, making @CacheableTask ineffective
  • Remove redundant manual cache file deletion in the task action — Gradle automatically cleans task outputs before re-execution

Both checks are redundant since Gradle already tracks the @OutputFile annotation and knows to re-execute when the output is missing.

GroovyPageForkCompileTask: fix overlapping outputs

  • compileGroovyPages and compileWebappGroovyPages both wrote to build/gsp-classes/main, causing Gradle to detect overlapping outputs and disable caching for both tasks
  • Give compileWebappGroovyPages its own output directory (build/gsp-classes/webapp) and update War/Jar packaging to include both directories
  • Runtime classpath is unaffected because output.dir('gsp-classes') already registers the parent directory

The upToDateWhen closure checked whether the cache file existed,
returning false when missing. Per Gradle docs, upToDateWhen returning
false prevents both up-to-date checks and build cache loading, making
the @CacheableTask annotation ineffective.

This check is redundant — Gradle already tracks the @OutputFile and
knows to re-execute when it is missing.

The manual cache file deletion in the task action is also redundant
since Gradle automatically cleans task outputs before re-execution.
compileGroovyPages and compileWebappGroovyPages both wrote to
build/gsp-classes/main, causing Gradle to detect overlapping outputs
and disable caching for both tasks.

Give compileWebappGroovyPages a separate output directory
(build/gsp-classes/webapp) and update War/Jar packaging to include
both directories. The runtime classpath is unaffected because
output.dir('gsp-classes') already registers the parent directory.
@testlens-app

testlens-app Bot commented Mar 30, 2026

Copy link
Copy Markdown

✅ All tests passed ✅

🏷️ Commit: ab6511c
▶️ Tests: 40170 executed
⚪️ Checks: 31/31 completed


Learn more about TestLens at testlens.app.

@matrei matrei left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you @ribafish!

@matrei
matrei merged commit 76b1d6b into apache:7.0.x Mar 31, 2026
32 checks passed
jamesfredley added a commit that referenced this pull request Aug 5, 2026
…ssons

Encode durable Gradle lessons from merged 8.0.x/7.x PRs so agents write
acceptable monorepo build changes on the first try.

- Build cacheability rules from #15483, #15532, #15537 (portable test props,
  no overlapping outputs, SBOM classpath normalization, upToDateWhen traps)
- base.dir dual rule: required @internal compile provider, forbidden absolute
  Test.systemProperties
- Fact fixes: Spring DM regression fixture exception, bootstrap wrapper scope,
  grails-publish plugin id, skipDependencyValidation presence semantics
- Agent quality bar, change workflow, expanded shared scripts and PR lessons
- AGENTS.md: Boot BOM pin 4.1.x, mono-repo-integration table entry, build-logic
  local wrapper command

Assisted-by: Sisyphus:xai/grok-4.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants