[MNG-5227] The 'optional' flag of a dependency should be manageable.

Project: http://git-wip-us.apache.org/repos/asf/maven/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/f4ad1fdd
Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/f4ad1fdd
Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/f4ad1fdd

Branch: refs/heads/DEPMGMT
Commit: f4ad1fdd47e9ad0093655de0ba3d8742899645c3
Parents: a4fa5a4
Author: Christian Schulte <schu...@apache.org>
Authored: Wed Jan 27 03:46:11 2016 +0100
Committer: Christian Schulte <schu...@apache.org>
Committed: Wed Feb 1 21:32:27 2017 +0100

----------------------------------------------------------------------
 .../maven/project/DefaultProjectDependenciesResolver.java    | 8 ++++++++
 .../management/DefaultDependencyManagementInjector.java      | 7 -------
 2 files changed, 8 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven/blob/f4ad1fdd/maven-core/src/main/java/org/apache/maven/project/DefaultProjectDependenciesResolver.java
----------------------------------------------------------------------
diff --git 
a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectDependenciesResolver.java
 
b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectDependenciesResolver.java
index 50c9e35..7f2f902 100644
--- 
a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectDependenciesResolver.java
+++ 
b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectDependenciesResolver.java
@@ -273,6 +273,14 @@ public class DefaultProjectDependenciesResolver
                     appendManagementSource( buffer, art, "version" );
                     buffer.append( ")" );
                 }
+
+                Boolean premanagedOptional = 
DependencyManagerUtils.getPremanagedOptional( node );
+                if ( premanagedOptional != null && !premanagedOptional.equals( 
dep.getOptional() ) )
+                {
+                    buffer.append( " (optionality managed from " ).append( 
premanagedOptional );
+                    appendManagementSource( buffer, art, "optional" );
+                    buffer.append( ')' );
+                }
             }
             else
             {

http://git-wip-us.apache.org/repos/asf/maven/blob/f4ad1fdd/maven-model-builder/src/main/java/org/apache/maven/model/management/DefaultDependencyManagementInjector.java
----------------------------------------------------------------------
diff --git 
a/maven-model-builder/src/main/java/org/apache/maven/model/management/DefaultDependencyManagementInjector.java
 
b/maven-model-builder/src/main/java/org/apache/maven/model/management/DefaultDependencyManagementInjector.java
index e611973..731cdd8 100644
--- 
a/maven-model-builder/src/main/java/org/apache/maven/model/management/DefaultDependencyManagementInjector.java
+++ 
b/maven-model-builder/src/main/java/org/apache/maven/model/management/DefaultDependencyManagementInjector.java
@@ -82,13 +82,6 @@ public class DefaultDependencyManagementInjector
         }
 
         @Override
-        protected void mergeDependency_Optional( Dependency target, Dependency 
source, boolean sourceDominant,
-                                                 Map<Object, Object> context )
-        {
-            // optional flag is not managed
-        }
-
-        @Override
         protected void mergeDependency_Exclusions( Dependency target, 
Dependency source, boolean sourceDominant,
                                                    Map<Object, Object> context 
)
         {

Reply via email to