[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.
This commit is contained in:
Christian Schulte 2016-02-11 08:45:19 +01:00 committed by Michael Osipov
parent fd988e78e9
commit f4ede96fd0
2 changed files with 11 additions and 2 deletions

View File

@ -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;
}

View File

@ -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;
}