jamesfredley commented on code in PR #15409:
URL: https://github.com/apache/grails-core/pull/15409#discussion_r2918544913


##########
grails-core/src/main/groovy/grails/boot/config/GrailsEnvironmentPostProcessor.java:
##########
@@ -0,0 +1,167 @@
+/*
+ *  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 java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.springframework.boot.ConfigurableBootstrapContext;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.env.EnvironmentPostProcessor;
+import org.springframework.core.Ordered;
+import org.springframework.core.env.ConfigurableEnvironment;
+import org.springframework.core.env.EnumerablePropertySource;
+import org.springframework.core.env.MutablePropertySources;
+import org.springframework.core.env.PropertySource;
+import org.springframework.core.io.Resource;
+
+import org.apache.grails.core.plugins.GrailsPluginDiscovery;
+import org.apache.grails.core.plugins.GrailsPluginInfo;
+import org.apache.grails.core.plugins.GrailsPluginUtils;
+import org.grails.config.PrefixedMapPropertySource;
+import org.grails.config.yaml.YamlPropertySourceLoader;
+import org.grails.core.cfg.GroovyConfigPropertySourceLoader;
+
+/**
+ * A Spring Boot {@link EnvironmentPostProcessor} that loads {@code 
plugin.yml} or {@code plugin.groovy} configuration
+ * files from Grails plugins early in the application lifecycle, before 
autoconfiguration conditions
+ * (such as {@code @ConditionalOnProperty}) are evaluated.
+ *
+ * <p>This allows plugin configuration to be available to Spring Boot's {@code 
@ConditionalOnProperty} evaluation on
+ * {@code @Configuration} and {@code @AutoConfiguration} classes.</p>
+ *
+ * @since 7.1
+ * @see GrailsApplicationPostProcessor
+ * @see GrailsPluginDiscovery
+ */
+public class GrailsEnvironmentPostProcessor implements 
EnvironmentPostProcessor, Ordered {
+
+    private static final Logger LOG = 
LoggerFactory.getLogger(GrailsEnvironmentPostProcessor.class);
+
+    private final ConfigurableBootstrapContext bootstrapContext;
+
+    GrailsEnvironmentPostProcessor(ConfigurableBootstrapContext 
bootstrapContext) {
+        this.bootstrapContext = bootstrapContext;
+    }
+
+    @Override
+    public int getOrder() {
+        // Run after Spring Boot property source loading but before 
autoconfiguration evaluation.
+        // We use a value that ensures we run after standard property sources 
are loaded but before
+        // autoconfiguration conditions are evaluated.
+        return Ordered.HIGHEST_PRECEDENCE + 15;
+    }
+
+    @Override
+    public void postProcessEnvironment(ConfigurableEnvironment environment, 
SpringApplication application) {
+        try {
+            GrailsPluginDiscovery pluginDiscovery = 
bootstrapContext.get(GrailsPluginDiscovery.class);
+            Collection<GrailsPluginInfo> plugins = 
pluginDiscovery.getLoadOrderedPlugins(environment);
+            loadPluginConfigurations(plugins, environment);
+        } catch (Exception e) {
+            LOG.warn("Error loading Grails plugin configurations early: {}. " +

Review Comment:
   consider LOG.error - since silent degradation of @ConditionalOnProperty is 
hard to debug



-- 
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]

Reply via email to