Let autoConfigurationName name a package as well as a class - #16221
Open
codeconsole wants to merge 1 commit into
Open
Let autoConfigurationName name a package as well as a class#16221codeconsole wants to merge 1 commit into
codeconsole wants to merge 1 commit into
Conversation
The attribute exists to preserve the identity of an auto-configuration class a plugin descriptor is being converted from, which its own documentation gives as the reason to set it: an exclude=, a before=/after= from another module, an entry in AutoConfiguration.imports, a test importing it by name. Each of those names the qualified name, and the attribute set only the simple one - the sibling was always generated in the descriptor's own package. A plugin descriptor conventionally sits in the package its implementation classes sit beneath rather than alongside them, so the class being converted is usually in another package and its identity changed anyway. Accepting a qualified name lets it be kept. A bare identifier still names the sibling in the plugin's package, so nothing that compiles today changes: a dot was rejected outright before this.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 8.0.x #16221 +/- ##
==================================================
+ Coverage 54.1129% 54.1267% +0.0138%
- Complexity 20301 20312 +11
==================================================
Files 2107 2107
Lines 101146 101146
Branches 17922 17922
==================================================
+ Hits 54733 54747 +14
+ Misses 38605 38595 -10
+ Partials 7808 7804 -4
🚀 New features to boost your workflow:
|
✅ All tests passed ✅🏷️ Commit: ae65d13 Learn more about TestLens at testlens.app/docs. |
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.
@GrailsBeans(autoConfigurationName = "...")sets only the simple name of the generated sibling; the package is always the plugin descriptor's own. Its documented purpose, though, is preserving the identity of an auto-configuration class a descriptor is being converted from:Every one of those references names the qualified name. And a plugin descriptor conventionally sits in the package its implementation classes sit beneath rather than alongside them, so the class being converted is usually in a different package — which means identity changed anyway and the attribute could not prevent it.
This came up converting
asset-pipeline, whose descriptor isasset.pipeline.AssetPipelineGrailsPluginwhile its hand-written auto-configuration isasset.pipeline.grails.AssetPipelineAutoConfiguration. There is no value ofautoConfigurationNamethat keeps that name today.The change
siblingSimpleName()becomessiblingName()and returns the qualified name, socreateAutoConfigurationSiblingno longer prepends the descriptor's package unconditionally. Validation moves fromSourceVersion.isIdentifiertoSourceVersion.isName, which accepts a dotted sequence and rejects any part that is a keyword.Backward compatible. A dot was rejected outright before this, so every value that compiles today is a bare identifier and still resolves in the plugin's package. The non-literal and blank error paths are untouched; only the "is not a valid name" message extends to mention qualified names.
I deliberately did not restrict the package to one the plugin already owns — that would block legitimate conversions such as a descriptor at
com.foo.plugins.BarGrailsPluginreplacingcom.foo.bar.BarAutoConfiguration. Instead the javadoc and the guide both warn that generating into a package the plugin does not otherwise own splits that package across two jars, which modular and native-image consumers pay for. Happy to enforce rather than document it if you would prefer.Tests
Eight cases added to
GrailsBeansASTTransformationSpec:@AutoConfiguration,@ConditionalOnWebApplication), and they still leave the plugin class@Unrolled rejections: keyword package part, leading dot, trailing dot, empty part, space in a part173 specs in
grails-beans-dsl, 0 failures. Every module consuming the DSL was also run:grails-core,grails-i18n,grails-domain-class,grails-sitemesh3, and bothbeans-dsltest-example applications../gradlew codeStyleis clean.Docs
GrailsBeans.java's javadoc no longer promises identity preservation it could not deliver, andhookingIntoRuntimeConfiguration.adochad an explicit "(still generated in the plugin's own package)" that is replaced with the qualified-name form and a worked example.Targets
8.0.x, where@GrailsBeansis new and unreleased. No ticket — happy to file one if you want it for the change log.