From c3007ad151f6caca0d30d31fad0953c84d0be766 Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Thu, 19 Dec 2024 15:08:56 +0100 Subject: [PATCH] Split the two --- .../DefaultPluginDependenciesResolver.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) 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 f922ea06fa9..775fba84321 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); }