Skip to content

fix: keep plugin templates out of the processResources filters - #16086

Merged
jamesfredley merged 1 commit into
fix/move-plugin-scripts-to-cli-companionfrom
pr-16082
Aug 2, 2026
Merged

jamesfredley merged 1 commit into
fix/move-plugin-scripts-to-cli-companionfrom
pr-16082

Conversation

@jdaugherty

Copy link
Copy Markdown
Contributor

See #16082

Routing src/main/templates through processResources subjected it to the
`**/*.gsp` exclusion that keeps compiled views out of build/resources/main,
because copy patterns set on a task apply to every spec composed into it.
Plugin templates are frequently GSPs, so this silently emptied them: the
grails-scaffolding jar lost all four META-INF/templates/scaffolding/*.gsp that
generate-views renders from, and grails-spring-security-ui lost all 45
META-INF/templates/views/**/*.gsp behind s2ui-override. Both shipped bare
directory entries instead.

copyCommands and copyTemplates now each own one directory that nothing else
writes, laid out as the archive sees it, attached to a source set output rather
than copied again by process*Resources. They stay Copy tasks, so build scripts
keep using tasks.named('copyTemplates', Copy), and they are registered when the
plugin is applied instead of in afterEvaluate - only the companion routing has
to defer, since grails-plugin-cli is applied after this plugin.

A plain Copy only ever adds, and a private staging directory gets no stale-state
cleanup from Gradle - not even when registered through SourceSetOutput.dir. Each
task therefore clears its own destination in a task action, so a deleted script
or template stops being packaged. Being an action rather than a separate clean
task, it runs only when the task executes and leaves up-to-date checks intact.
Sync would give the same result but would change a task type build scripts
depend on.

src/main/templates was also being contributed twice, once by enableNative2Ascii
and once by copyTemplates, an overlap that DuplicatesStrategy.INCLUDE was
hiding. That wiring moves out of enableNative2Ascii, which it never belonged to,
into an overridable configureTemplateResources that Grails plugins turn off
because copyTemplates already packages them.

PluginScriptCommandPackagingSpec covers companion and non-companion packaging,
GSP templates surviving alongside excluded plugin views, neither copy task
writing into a process*Resources output, and deletions taking effect without a
clean.
@jdaugherty
jdaugherty requested a review from jamesfredley August 2, 2026 17:45
@jdaugherty
jdaugherty marked this pull request as ready for review August 2, 2026 17:50
@jamesfredley

Copy link
Copy Markdown
Contributor

Reviewed and merged into #16082 (fast-forward to 82ebbd775e).

This is the right fix for GSP templates being dropped by the processResources **/*.gsp exclude. Thanks.

@jamesfredley
jamesfredley merged commit 82ebbd7 into fix/move-plugin-scripts-to-cli-companion Aug 2, 2026
48 checks passed
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.

2 participants