-
-
Notifications
You must be signed in to change notification settings - Fork 974
Register plugin beans before Spring Boot auto-configuration by retiming doWithSpring #15934
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jdaugherty
merged 18 commits into
apache:8.0.x
from
codeconsole:feat/plugin-beans-before-autoconfig
Jul 10, 2026
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
a853dda
Retime plugin doWithSpring to run before Spring Boot auto-configuration
codeconsole de3dd94
Add BeanRegistrar plugin hook and deprecate the doWithSpring bean DSL
codeconsole 12ffe36
Verify application bean overriding and add end-to-end early plugin ph…
codeconsole eb79849
Resolve application classes for early artefact discovery via classes()
codeconsole 0a84ee5
Detect web applications without relying on the dispatcherServlet bean
codeconsole e16f609
Merge branch '8.0.x' into feat/plugin-beans-before-autoconfig
codeconsole 4a30a7d
Merge branch '8.0.x' into feat/plugin-beans-before-autoconfig
jdaugherty dd5ac78
Remove the duplicate annotation handler mapping and adapter beans
codeconsole a1a6a20
Merge remote-tracking branch 'upstream/8.0.x' into feat/plugin-beans-…
codeconsole c082a42
Merge branch '8.0.x' into feat/plugin-beans-before-autoconfig
codeconsole 78b225e
Address review feedback on the plugin lifecycle change
codeconsole e737052
Add test coverage for review-audit gaps
codeconsole d054328
test(grails-data-mongodb): add unit-testable Mongo OSIV coverage
borinquenkid 1af592c
Replace the mongo OSIV integration test with a unit test of the share…
codeconsole 193eb45
Merge remote-tracking branch 'origin/feat/plugin-beans-before-autocon…
codeconsole c1cb748
Merge branch '8.0.x' into feat/plugin-beans-before-autoconfig
codeconsole 1dea040
Merge remote-tracking branch 'upstream/8.0.x' into feat/plugin-beans-…
codeconsole c825ffe
Merge remote-tracking branch 'origin/feat/plugin-beans-before-autocon…
codeconsole File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
85 changes: 85 additions & 0 deletions
85
grails-core/src/main/groovy/grails/boot/config/ApplicationArtefactScanner.groovy
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
| package grails.boot.config | ||
|
|
||
| import groovy.transform.CompileStatic | ||
|
|
||
| import grails.boot.config.tools.ClassPathScanner | ||
| import org.grails.compiler.injection.AbstractGrailsArtefactTransformer | ||
|
|
||
| /** | ||
| * Discovers the artefact classes that make up a Grails application by scanning the classpath relative | ||
| * to an application class. This is the single implementation of the default scanning performed by | ||
| * {@link GrailsAutoConfiguration#classes()}, also used by | ||
| * {@link GrailsEarlyPluginRegistrationPostProcessor} to perform artefact discovery before Spring | ||
| * Boot auto-configuration is processed. | ||
| * | ||
| * @since 8.0 | ||
| */ | ||
| @CompileStatic | ||
| final class ApplicationArtefactScanner { | ||
|
|
||
| private ApplicationArtefactScanner() { | ||
| } | ||
|
|
||
| /** | ||
| * Scans for application classes in the package of the given application class, including any | ||
| * classes registered by Grails artefact transformations. | ||
| * | ||
| * @param applicationClass The application class to scan relative to | ||
| * @return The classes that constitute the Grails application | ||
| */ | ||
| static Collection<Class> scanApplicationClasses(Class<?> applicationClass) { | ||
| Package applicationPackage = applicationClass.package | ||
| Collection<String> packageNames = applicationPackage != null ? [applicationPackage.name] : new ArrayList<String>() | ||
| return scanApplicationClasses(applicationClass, packageNames) | ||
| } | ||
|
|
||
| /** | ||
| * Scans for application classes in the given packages relative to the given application class, | ||
| * including any classes registered by Grails artefact transformations. | ||
| * | ||
| * @param applicationClass The application class to scan relative to | ||
| * @param packageNames The package names to scan | ||
| * @return The classes that constitute the Grails application | ||
| */ | ||
| static Collection<Class> scanApplicationClasses(Class<?> applicationClass, Collection<String> packageNames) { | ||
| Collection<Class> classes = new HashSet<>() | ||
| classes.addAll(new ClassPathScanner().scan(applicationClass, packageNames)) | ||
| classes.addAll(loadTransformedClasses(applicationClass.classLoader)) | ||
| return classes | ||
| } | ||
|
|
||
| /** | ||
| * Loads the classes registered by Grails artefact transformations at compile time. | ||
| * | ||
| * @param classLoader The class loader to load the classes with | ||
| * @return The transformed classes resolvable by the given class loader | ||
| */ | ||
| static Collection<Class> loadTransformedClasses(ClassLoader classLoader) { | ||
| Collection<Class> classes = [] | ||
| for (String className in AbstractGrailsArtefactTransformer.transformedClassNames) { | ||
| try { | ||
| classes << classLoader.loadClass(className) | ||
| } catch (ClassNotFoundException ignored) { | ||
| } | ||
| } | ||
| return classes | ||
| } | ||
| } |
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.