Skip to content

Forge: Remove stale generated sources in the Rocker task - #16383

Merged
jdaugherty merged 1 commit into
apache:7.0.xfrom
matrei:fix/forge-rocker-stale-output
Sep 23, 2026
Merged

jdaugherty merged 1 commit into
apache:7.0.xfrom
matrei:fix/forge-rocker-stale-output

Conversation

@matrei

@matrei matrei commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Summary

The Forge build's RockerTask (grails-forge/buildSrc) generates Java sources from *.rocker.raw templates into build/generated-src/rocker/<sourceSet>, but it never clears that directory. When a template is deleted or renamed, the source generated from it stays behind and keeps being compiled into grails-forge-core.

It gets worse with the build cache. The task is @CacheableTask, so a run that leaves a stale file behind stores that output in the local build cache. After ./gradlew clean, Gradle restores the stale output from the cache and the old class is back.

It only shows up in local builds after a template has been removed or renamed. CI builds from a clean checkout, so CI is not affected.

Changes

  • RockerTask deletes its output directory before generating sources, so the output always matches the current templates. It uses the injected FileSystemOperations service, which keeps the task compatible with the configuration cache.

Testing

buildSrc has no test setup, so I checked this manually on grails-forge-core with --no-build-cache:

  • Before the fix, adding a staleProbe.rocker.raw template, running generateRockerTemplateSource, deleting the template and running the task again left staleProbe.java in the output.
  • After the fix, the same steps leave no staleProbe.java. The first run also removed sources left over from templates deleted on another branch.
  • ./gradlew test in grails-forge passes (forge-core, forge-api, forge-cli, test-core), and so does codeStyle for forge-core and forge-cli.

RockerTask never cleared its output directory, so sources generated
from deleted or renamed templates stayed behind and were compiled into
grails-forge-core. As the task is cacheable, the stale output was also
stored in the build cache and restored after a clean.

Delete the output directory before generating the sources.
@matrei matrei changed the title Remove stale generated sources in the Forge Rocker task Forge: Remove stale generated sources in the Rocker task Sep 23, 2026
@matrei
matrei marked this pull request as ready for review September 23, 2026 11:10
@jdaugherty
jdaugherty merged commit 31bd1ca into apache:7.0.x Sep 23, 2026
52 checks passed
@jdaugherty jdaugherty added this to the grails:8.0.0-RC1 milestone Sep 23, 2026
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.

3 participants