mirror of https://github.com/apache/maven.git
Resolving: MNG-1008...DependencyManagement can now inject exclusions.
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@291806 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
78e74cd7fe
commit
e41222abd0
|
@ -90,6 +90,22 @@ public class DefaultModelDefaultsInjector
|
|||
{
|
||||
dep.setVersion( def.getVersion() );
|
||||
}
|
||||
|
||||
if ( dep.getClassifier() == null && def.getClassifier() != null )
|
||||
{
|
||||
dep.setClassifier( def.getClassifier() );
|
||||
}
|
||||
|
||||
if ( dep.getType() == null && def.getType() != null )
|
||||
{
|
||||
dep.setType( def.getType() );
|
||||
}
|
||||
|
||||
List exclusions = dep.getExclusions();
|
||||
if ( exclusions == null || exclusions.isEmpty() )
|
||||
{
|
||||
dep.setExclusions( def.getExclusions() );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -19,8 +19,10 @@ package org.apache.maven.project.injection;
|
|||
import junit.framework.TestCase;
|
||||
import org.apache.maven.model.Dependency;
|
||||
import org.apache.maven.model.DependencyManagement;
|
||||
import org.apache.maven.model.Exclusion;
|
||||
import org.apache.maven.model.Model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -65,6 +67,51 @@ public class DefaultModelDefaultsInjectorTest
|
|||
assertEquals( def.getVersion(), result.getVersion() );
|
||||
}
|
||||
|
||||
public void testShouldMergeDependencyExclusionsFromDefaultsToDependency()
|
||||
{
|
||||
Model model = new Model();
|
||||
|
||||
Dependency dep = new Dependency();
|
||||
dep.setGroupId( "myGroup" );
|
||||
dep.setArtifactId( "myArtifact" );
|
||||
|
||||
model.addDependency( dep );
|
||||
|
||||
Dependency def = new Dependency();
|
||||
def.setGroupId( dep.getGroupId() );
|
||||
def.setArtifactId( dep.getArtifactId() );
|
||||
def.setVersion( "1.0.1" );
|
||||
def.setScope( "scope" );
|
||||
|
||||
Exclusion exc = new Exclusion();
|
||||
exc.setArtifactId( "mydep" );
|
||||
exc.setGroupId( "mygrp" );
|
||||
|
||||
def.addExclusion( exc );
|
||||
|
||||
DependencyManagement depMgmt = new DependencyManagement();
|
||||
|
||||
depMgmt.addDependency( def );
|
||||
|
||||
model.setDependencyManagement( depMgmt );
|
||||
|
||||
new DefaultModelDefaultsInjector().injectDefaults( model );
|
||||
|
||||
List deps = model.getDependencies();
|
||||
assertEquals( 1, deps.size() );
|
||||
|
||||
Dependency result = (Dependency) deps.get( 0 );
|
||||
assertEquals( def.getVersion(), result.getVersion() );
|
||||
|
||||
List resultExclusions = result.getExclusions();
|
||||
assertNotNull( resultExclusions );
|
||||
assertEquals( 1, resultExclusions.size() );
|
||||
|
||||
Exclusion resultExclusion = (Exclusion) resultExclusions.get( 0 );
|
||||
assertEquals( "mydep", resultExclusion.getArtifactId() );
|
||||
assertEquals( "mygrp", resultExclusion.getGroupId() );
|
||||
}
|
||||
|
||||
public void testShouldMergeDefaultUrlAndArtifactWhenDependencyDoesntSupplyVersion()
|
||||
{
|
||||
Model model = new Model();
|
||||
|
|
Loading…
Reference in New Issue