diff --git a/impl/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultPluginDependenciesResolver.java b/impl/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultPluginDependenciesResolver.java index f922ea06fa91..775fba84321c 100644 --- a/impl/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultPluginDependenciesResolver.java +++ b/impl/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultPluginDependenciesResolver.java @@ -232,14 +232,17 @@ private DependencyResult resolveInternal( org.eclipse.aether.graph.Dependency managedDep = core.get(pluginDep.getArtifact().getGroupId() + ":" + pluginDep.getArtifact().getArtifactId()); - if (managedDep != null - && !Objects.equals( - pluginDep.getArtifact().getVersion(), - managedDep.getArtifact().getVersion())) { - pluginDep = pluginDep.setArtifact(pluginDep - .getArtifact() - .setVersion(managedDep.getArtifact().getVersion())); - pluginDep = pluginDep.setScope(DependencyScope.PROVIDED.id()); + 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()); } request.addDependency(pluginDep); }