Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.apache.maven.model.Build;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.DependencyManagement;
import org.apache.maven.model.Exclusion;
import org.apache.maven.model.InputLocation;
import org.apache.maven.model.InputSource;
import org.apache.maven.model.Model;
Expand Down Expand Up @@ -1407,7 +1408,40 @@ private void importDependencyManagement( Model model, ModelBuildingRequest reque
importMgmt = new DependencyManagement();
}

intoCache( request.getModelCache(), groupId, artifactId, version, ModelCacheTag.IMPORT, importMgmt );
// [MNG-5600] Dependency management import should support exclusions.
if ( !dependency.getExclusions().isEmpty() )
{
for ( final Exclusion exclusion : dependency.getExclusions() )
{
if ( exclusion.getGroupId() != null && exclusion.getArtifactId() != null )
{
for ( final Iterator<Dependency> dependencies = importMgmt.getDependencies().iterator();
dependencies.hasNext(); )
{
final Dependency candidate = dependencies.next();

if ( ( exclusion.getGroupId().equals( "*" )
|| exclusion.getGroupId().equals( candidate.getGroupId() ) )
&& ( exclusion.getArtifactId().equals( "*" )
|| exclusion.getArtifactId().equals( candidate.getArtifactId() ) ) )
{
// Dependency excluded from import.
dependencies.remove();
}
}
}
}

for ( final Dependency includedDependency : importMgmt.getDependencies() )
{
includedDependency.getExclusions().addAll( dependency.getExclusions() );
}
}
else
{
// Only dependency managements without exclusion processing applied can be cached.
intoCache( request.getModelCache(), groupId, artifactId, version, ModelCacheTag.IMPORT, importMgmt );
}
}

if ( importMgmts == null )
Expand Down