[MNG-5935] Optional true getting lost in managed dependencies when transitive

Updated to correctly map the optional flag of Maven model dependencies to
Aether dependencies. Prior to this change all managed dependencies implicitly
had the optional flag set to 'false' leading to Aether managing that flag to
'false' on all managed dependencies when transitive.


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

Branch: refs/heads/DEPMGMT
Commit: dc300371e9358539324a0d25898d50f9ce9c262d
Parents: f05b4e0
Author: Christian Schulte <schu...@apache.org>
Authored: Thu Feb 11 08:45:19 2016 +0100
Committer: Christian Schulte <schu...@apache.org>
Committed: Tue Jan 31 23:09:10 2017 +0100

----------------------------------------------------------------------
 .../repository/internal/ArtifactDescriptorReaderDelegate.java | 6 +++++-
 .../src/main/java/org/apache/maven/RepositoryUtils.java       | 7 ++++++-
 2 files changed, 11 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven/blob/dc300371/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/ArtifactDescriptorReaderDelegate.java
----------------------------------------------------------------------
diff --git 
a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/ArtifactDescriptorReaderDelegate.java
 
b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/ArtifactDescriptorReaderDelegate.java
index 2395b36..184c327 100644
--- 
a/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/ArtifactDescriptorReaderDelegate.java
+++ 
b/maven-aether-provider/src/main/java/org/apache/maven/repository/internal/ArtifactDescriptorReaderDelegate.java
@@ -124,7 +124,11 @@ public class ArtifactDescriptorReaderDelegate
             exclusions.add( convert( exclusion ) );
         }
 
-        Dependency result = new Dependency( artifact, dependency.getScope(), 
dependency.isOptional(), exclusions );
+        Dependency result = new Dependency( artifact, dependency.getScope(),
+                                            dependency.getOptional() != null
+                                                ? dependency.isOptional()
+                                                : null,
+                                            exclusions );
 
         return result;
     }

http://git-wip-us.apache.org/repos/asf/maven/blob/dc300371/maven-core/src/main/java/org/apache/maven/RepositoryUtils.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/RepositoryUtils.java 
b/maven-core/src/main/java/org/apache/maven/RepositoryUtils.java
index 86eab4e..52442b7 100644
--- a/maven-core/src/main/java/org/apache/maven/RepositoryUtils.java
+++ b/maven-core/src/main/java/org/apache/maven/RepositoryUtils.java
@@ -316,7 +316,12 @@ public class RepositoryUtils
             exclusions.add( toExclusion( exclusion ) );
         }
 
-        Dependency result = new Dependency( artifact, dependency.getScope(), 
dependency.isOptional(), exclusions );
+        Dependency result = new Dependency( artifact,
+                                            dependency.getScope(),
+                                            dependency.getOptional() != null
+                                                ? dependency.isOptional()
+                                                : null,
+                                            exclusions );
 
         return result;
     }

Reply via email to