Fix: MNG-3978

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@733133 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Britton Isbell 2009-01-09 19:44:19 +00:00
parent 9c7e082906
commit e3bde472f9
2 changed files with 21 additions and 1 deletions

View File

@ -406,7 +406,27 @@ public class PomTransformer
List<ModelProperty> tmp = domainModel.getModelProperties();
List clearedProperties = new ArrayList<ModelProperty>();
//Default Dependency Scope Rule
ModelDataSource s = new DefaultModelDataSource();
s.init( tmp, Arrays.asList( new ArtifactModelContainerFactory()) );
for(ModelContainer mc : s.queryFor(ProjectUri.Dependencies.Dependency.xUri))
{
boolean containsScope = false;
for(ModelProperty mp :mc.getProperties())
{
if(mp.getUri().equals(ProjectUri.Dependencies.Dependency.scope)) {
containsScope = true;
break;
}
}
if(!containsScope)
{
tmp.add(tmp.indexOf(mc.getProperties().get(0)) + 1, new ModelProperty(ProjectUri.Dependencies.Dependency.scope, "compile"));
}
}
//Missing Version Rule
if ( getPropertyFor( ProjectUri.version, tmp ) == null )
{

View File

@ -82,7 +82,7 @@ public class ProjectInheritanceTest
assertNotNull( c );
// inherited from depMgmt
assertTrue("Incorrect scope for " + a.getDependencyConflictId(), a.getScope().equals("test"));
assertTrue("Incorrect scope for " + a.getDependencyConflictId(), a.getScope().equals("compile"));
// transitive dep, overridden b depMgmt
assertTrue("Incorrect scope for " + b.getDependencyConflictId(), b.getScope().equals("runtime"));