Repository navigation
Forge: Remove stale generated sources in the Rocker task - #16383
Merged
Merged
Conversation
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
marked this pull request as ready for review
September 23, 2026 11:10
sbglasius
approved these changes
Sep 23, 2026
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
The Forge build's
RockerTask(grails-forge/buildSrc) generates Java sources from*.rocker.rawtemplates intobuild/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 intograils-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
RockerTaskdeletes its output directory before generating sources, so the output always matches the current templates. It uses the injectedFileSystemOperationsservice, which keeps the task compatible with the configuration cache.Testing
buildSrchas no test setup, so I checked this manually ongrails-forge-corewith--no-build-cache:staleProbe.rocker.rawtemplate, runninggenerateRockerTemplateSource, deleting the template and running the task again leftstaleProbe.javain the output.staleProbe.java. The first run also removed sources left over from templates deleted on another branch../gradlew testingrails-forgepasses (forge-core, forge-api, forge-cli, test-core), and so doescodeStylefor forge-core and forge-cli.