codeconsole opened a new pull request, #16200:
URL: https://github.com/apache/grails-core/pull/16200
Follow-up to #16102.
## The gap
`generateI18nDescriptor` fails a plugin build when a base name sits outside
the plugin's namespace. That default is right, and this PR does not change it —
Spring resolves a base name to the first match on the classpath rather than
merging, so two artifacts shipping the same base name shadow one another with
nothing at runtime to say which won. Failing the plugin's own build puts the
error in front of the only person who can rename the bundle.
What it lacks is an escape hatch, and `grails { i18n { basenames } }` is not
one: declared base names are folded into the index *before*
`validatePluginNamespace` runs, so a plugin cannot declare its way past the
check.
That leaves a plugin that genuinely cannot rename — a base name that is part
of a published contract, or a bundle vendored from somewhere else — with two
options:
- `-x generateI18nDescriptor`, which ships no descriptor at all and
therefore drops the plugin's messages entirely, or
- a fork.
## The change
```groovy
grails {
i18n {
enforceNamespace = false
}
}
```
Downgrades the same diagnosis to a build warning and writes the descriptor
as it stands. Default unchanged (`true`).
The wording is identical whether it throws or warns — what is wrong and how
to fix it do not depend on the severity — so `validatePluginNamespace` becomes
`describeNamespaceViolation`, returning the message or `null`, and the caller
decides. Both the message and the upgrade guide say plainly that the opt-out
silences the build, not the collision.
## Tests
- `GenerateI18nDescriptorTaskSpec` — the check is on by convention;
`enforceNamespace = false` records the bundle and does not throw; the message
names the opt-out and its caveat.
- `I18nDescriptorFunctionalSpec` + a new
`i18n-descriptor-plugin-namespace-off` test project — the same colliding bundle
as `i18n-descriptor-plugin-collision`, plus the `i18n` block, exercised end to
end through `processResources`: the build succeeds, still reports the
collision, and the descriptor records `basenames=messages`.
`:grails-gradle-plugins:check` passes (including `validatePlugins`), and
`rat` passes.
## Context
Found while upgrading an app to 8.0.0-M6. Its Spring Security fork shipped
the base name it inherited from the upstream plugin — a real collision, and the
check caught it, so this is not a complaint about the rule. Renaming was the
right fix there. The opt-out is for the cases where it isn't available.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]