cstamas commented on code in PR #2000:
URL: https://github.com/apache/maven/pull/2000#discussion_r1894990543


##########
impl/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultPluginDependenciesResolver.java:
##########
@@ -208,12 +221,29 @@ private DependencyResult resolveInternal(
             request.setRequestContext(REPOSITORY_CONTEXT);
             request.setRepositories(repositories);
             request.setRoot(new 
org.eclipse.aether.graph.Dependency(pluginArtifact, null));
+            Map<String, org.eclipse.aether.graph.Dependency> core = 
getCoreExportsAsDependencies(session);
+            request.setManagedDependencies(core.values().stream().toList());
             for (Dependency dependency : plugin.getDependencies()) {
                 org.eclipse.aether.graph.Dependency pluginDep =
                         RepositoryUtils.toDependency(dependency, 
session.getArtifactTypeRegistry());
                 if (!DependencyScope.SYSTEM.is(pluginDep.getScope())) {
                     pluginDep = 
pluginDep.setScope(DependencyScope.RUNTIME.id());
                 }
+                org.eclipse.aether.graph.Dependency managedDep =
+                        core.get(pluginDep.getArtifact().getGroupId() + ":"
+                                + pluginDep.getArtifact().getArtifactId());
+                if (managedDep != null) {
+                    // align version if needed
+                    if (!Objects.equals(
+                            pluginDep.getArtifact().getVersion(),
+                            managedDep.getArtifact().getVersion())) {
+                        pluginDep = pluginDep.setArtifact(pluginDep
+                                .getArtifact()
+                                
.setVersion(managedDep.getArtifact().getVersion()));
+                    }
+                    // align scope
+                    pluginDep = pluginDep.setScope(managedDep.getScope());

Review Comment:
   Former contains plugin stuff + maven core (imported), while latter should 
contain all



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