matrei commented on code in PR #16434:
URL: https://github.com/apache/grails-core/pull/16434#discussion_r4146110506


##########
grails-core/src/cli/groovy/org/apache/grails/core/cli/ConfigReportCommand.groovy:
##########
@@ -202,12 +206,26 @@ class ConfigReportCommand implements ApplicationCommand {
     }
 
     MetadataResult loadPropertyMetadata() {
-        Enumeration<URL> resources = 
ConfigReportCommand.classLoader.getResources('META-INF/spring-configuration-metadata.json')
+        loadPropertyMetadata(ConfigReportCommand.classLoader)
+    }
+
+    /**
+     * Loads the configuration metadata on the classpath of the given class 
loader. Properties outside the Grails
+     * namespaces are only included when they are published by a Grails 
plugin, so that the metadata of other
+     * libraries, such as Spring Boot, does not flood the report.
+     *
+     * @param classLoader the class loader to load the metadata from
+     * @return the properties and group descriptions
+     */
+    MetadataResult loadPropertyMetadata(ClassLoader classLoader) {
+        Set<String> pluginRoots = findPluginRoots(classLoader)
+        Enumeration<URL> resources = 
classLoader.getResources(METADATA_RESOURCE)
         List<ConfigPropertyMetadata> metadata = new 
ArrayList<ConfigPropertyMetadata>()
         Map<String, String> groupDescriptions = new LinkedHashMap<String, 
String>()
         JsonSlurper slurper = new JsonSlurper()
         while (resources.hasMoreElements()) {
             URL resource = resources.nextElement()
+            boolean pluginMetadata = 
pluginRoots.contains(resourceRoot(resource, METADATA_RESOURCE))

Review Comment:
   Thanks, good catch. I fixed it rather than documenting it as a limitation.
   
   The exploded variant publishes exactly two directories, 
`compileGroovy.destinationDirectory` and `processResources.destinationDir`, and 
a plugin project running the report on itself has the same two on its 
classpath. So when a descriptor's root is a Gradle classes directory, 
`…/classes/<language>/<sourceSet>/`, `findPluginRoots` now also adds the 
sibling `…/resources/<sourceSet>/` as a root of that plugin.
   
   This doesn't widen anything for applications. An application has no 
`grails-plugin.xml` in its classes directory, so its `build/resources/main` is 
never paired, and its typed properties stay under Other Properties.
   
   - New test `loadPropertyMetadata includes the resources of a plugin on the 
classpath as Gradle output directories` covers your variant: a plugin with its 
descriptor in `build/classes/groovy/main` and its metadata in 
`build/resources/main`, next to an application with the same layout and no 
descriptor. `acme.enabled` is included, and the application's `app.greeting` is 
still left out. The test fails without the change.
   - The guide paragraph no longer says "in its JAR". It now states that 
directory output works too, as long as the default Gradle output directories 
are used. That's the one remaining limitation: custom 
`destinationDirectory`/`destinationDir` locations aren't paired.
   



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