Copilot commented on code in PR #15995:
URL: https://github.com/apache/grails-core/pull/15995#discussion_r3605145430


##########
grails-core/src/main/groovy/org/apache/grails/core/plugins/DefaultPluginDiscovery.java:
##########
@@ -418,16 +418,36 @@ private void loadDelayedPlugins() {
                     delayedLoadPlugins.add(plugin);
                 } else {
                     failedPlugins.put(plugin.getName(), plugin);
-                    LOG.error(
-                            "ERROR: Plugin [{}] cannot be loaded because its 
dependencies [{}}] cannot be resolved",
-                            plugin.getName(),
-                            plugin.getDependsOnNames()
-                    );
+                    logUnresolvedDependencies(plugin);
                 }
             }
         }
     }
 
+    private void logUnresolvedDependencies(PluginInfo plugin) {
+        var unresolvedDependencies = new ArrayList<String>();
+        for (var name : plugin.getDependsOnNames()) {
+            var requiredVersion = 
plugin.getMetadata().getDependentVersion(name);
+            var dependency = findPlugin(name);
+            if (dependency == null) {
+                unresolvedDependencies.add(
+                        "dependency [" + name + "] with required version [" + 
requiredVersion + "] is missing"
+                );
+            } else if 
(!GrailsVersionUtils.isValidVersion(dependency.getPluginVersion(), 
requiredVersion)) {
+                unresolvedDependencies.add(
+                        "dependency [" + name + "] has version [" + 
dependency.getPluginVersion() +
+                                "] but requires [" + requiredVersion + "]"
+                );
+            }
+        }
+        LOG.warn(
+                "Grails plug-in [{}] with version [{}] cannot be loaded: {}",
+                plugin.getName(),
+                plugin.getPluginVersion(),
+                String.join("; ", unresolvedDependencies)
+        );
+    }

Review Comment:
   logUnresolvedDependencies() classifies a dependency as "missing" whenever it 
isn't already registered (findPlugin returns null). That can be misleading when 
the dependency plugin is present but ended up in delayedLoadPlugins or 
failedPlugins (e.g., it exists but failed to load due to its own unresolved 
deps), and it can also lead to an empty reason list if the only unresolved deps 
are failed-but-version-compatible. Consider also checking 
failedPlugins/delayedLoadPlugins by name so the WARN accurately distinguishes 
missing vs failed vs version-incompatible dependencies.



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