Skip to content

Fix build cache hits for FindMainClassTask and GroovyPageForkCompileTask#15537

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

Fix build cache hits for FindMainClassTask and GroovyPageForkCompileTask#15537
matrei merged 2 commits intoapache: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
Copy link
Copy Markdown

testlens-app bot commented Mar 30, 2026

✅ All tests passed ✅

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


Learn more about TestLens at testlens.app.

Copy link
Copy Markdown
Contributor

@matrei matrei left a comment

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
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