Load plugin.yml/plugin.groovy earlier so @Conditional* annotations can be used#15409
Load plugin.yml/plugin.groovy earlier so @Conditional* annotations can be used#15409jdaugherty wants to merge 42 commits intoapache:7.1.xfrom
Conversation
1232204 to
e109334
Compare
46f5e8f to
9f81969
Compare
|
You're right—deprecation annotations should include a reason for clarity. For this method, the reason could be that plugin property sources are now handled early by GrailsPluginEnvironmentPostProcessor. |
|
If this does not require changes in end Grails apps I am OK with this going into 7.0.x, if we think the risk is too high, then 7.1.x is also OK. |
There was a problem hiding this comment.
Looks solid. A few minor items to take a look at.
The GrailsPluginConfigurationClass test removed the "plugin with both yml and groovy throws exception" test. That validation still exists in GrailsPluginEnvironmentPostProcessor.readPluginConfiguration() (line 293), but there's no unit test covering it in the new code. The GrailsPluginEnvironmentPostProcessorSpec should add a test for this.
grails-core/src/main/groovy/org/grails/config/GrailsPluginEnvironmentPostProcessor.java
Outdated
Show resolved
Hide resolved
grails-core/src/main/groovy/org/grails/config/GrailsPluginEnvironmentPostProcessor.java
Outdated
Show resolved
Hide resolved
grails-core/src/main/groovy/org/grails/config/GrailsPluginEnvironmentPostProcessor.java
Outdated
Show resolved
Hide resolved
462035b to
ee32e61
Compare
|
This change is incomplete since the plugin configuration will be loaded potentially when the plugin is disabled. We may be able to post process already loaded configuration and remove them, but I'm not sure without further research. Here's the loading order in Spring: • SpringApplication.run(...) The problem is the plugin manager has different discovery mechanisms (but very similar). Worst, one of those mechanisms appears to require the application context, which won't exist when we need to load configuration. I think the need for the application context (or rather the parent application context) isn't actually used though. I'm doing further research on this to see how best to unify the plugin manager mechanisms so we can share the logic in both places. |
|
I've been working on this and will likely push a significant update in the next day or so. The core issue is the plugin filtering needs shared between the environment & the application post processors. The problem: the plugin manager is what currently does this filtering & it's a bean. The environment post processor can't use a bean b/c the context doesn't exist yet. The only practical place the filtering is used is when in unit tests it filters the plugins. I think the right solution is either moving the filter further out & sharing it between the plugin manager / EPP, or just moving the plugin manager away from being a bean completely. |
406aa4a to
d7175cf
Compare
d7175cf to
13ec1b0
Compare
|
@jdaugherty Why did you choose to write new classes in Java, and not Groovy? |
matrei
left a comment
There was a problem hiding this comment.
This was a great effort @jdaugherty, thank you!
As changes a some of the public API of core functionality, I think it would be wise to target 8.0.x.
|
|
||
| /** | ||
| * Returns the location of the Resource that represents the plugin descriptor (the *GrailsPlugin.groovy file) | ||
| * Returns the location of the Resource that represents the plugin descriptor (the *GrailsPlugin.groovy or grails-plugin.yml file) |
There was a problem hiding this comment.
Isn't the grails-plugin.yml created from the *GrailsPlugin.groovy file so this is essentially the same thing.
There was a problem hiding this comment.
There are 2 code paths - binary plugins load from grails-plugin.yml & source based plugins load from GrailsPlugin. Source based plugins that are loaded dynamically do not have a grails-plugin.yml. I think this really exists today for tests only. I was trying to call out these 2 code paths in this comment.
grails-core/src/main/groovy/grails/boot/config/GrailsEnvironmentPostProcessor.java
Show resolved
Hide resolved
grails-core/src/main/groovy/org/apache/grails/core/plugins/GrailsPluginDiscovery.java
Outdated
Show resolved
Hide resolved
grails-core/src/main/groovy/org/apache/grails/core/plugins/GrailsPluginDiscovery.java
Outdated
Show resolved
Hide resolved
...ng-support-core/src/main/resources/META-INF/services/grails.plugins.GrailsPluginConfigFilter
Outdated
Show resolved
Hide resolved
grails-core/src/main/groovy/org/apache/grails/core/GrailsBootstrapRegistryInitializer.java
Outdated
Show resolved
Hide resolved
grails-core/src/main/groovy/grails/plugins/GrailsPluginSorter.java
Outdated
Show resolved
Hide resolved
grails-core/src/main/groovy/grails/plugins/GrailsPluginSorter.java
Outdated
Show resolved
Hide resolved
| * @return the plugin's property source from the environment, or {@code null} if the | ||
| * GrailsApplication main context is not yet available or no matching property source exists | ||
| */ | ||
| @Deprecated(forRemoval = true) |
There was a problem hiding this comment.
Why Java (general question for all new classes)?
There was a problem hiding this comment.
The classes in this area have historically been java. Looking through the commit history, there have been numerous performance problems in this area and conversion to java was one of the "fixes". I did not want to introduce a new pattern as I was only trying to abstract the existing logic. I think if we introduce a hard contract, we could change this with some significant refactoring.
a7cd577 to
c8e65a8
Compare
c8e65a8 to
11cbf53
Compare
The problem I have with 8.0 is:
|
|
A potential start on backward-compatibility bridge shims for 7.1.x: |
This is excellent, but is it relevant?
Yeah, but not in this way, and that was a hard call.
Unfortunately, not many projects try out milestones.
If we can get the API backwards compatible, I have no problem including this in 7.1. I see that @jamesfredley already started this work in jdaugherty#5. |
|
I plan to approve this once the backward-compatibility bridge shims are in place for 7.1.x. Thank you @jdaugherty |
Fixes #15408
Assisted-by: OpenCode <opencode@opencode.ai>
Assisted-by: Claude <claude@anthropic.com>