diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactCollector.java b/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactCollector.java
index fc12a58781..0f70187d6e 100644
--- a/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactCollector.java
+++ b/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactCollector.java
@@ -127,19 +127,14 @@ public class DefaultArtifactCollector
Artifact managedOriginatingArtifact = (Artifact) versionMap.get( originatingArtifact.getDependencyConflictId() );
if ( managedOriginatingArtifact != null )
{
- String managedVersion = managedOriginatingArtifact.getVersion();
- String version = originatingArtifact.getVersion();
- if ( !managedVersion.equals( version ) )
+ // TODO we probably want to warn the user that he is building an artifact with
+ // different values than in dependencyManagement
+ if ( managedVersions instanceof ManagedVersionMap )
{
- // TODO we probably want to warn the user that he is building and artifact with a
- // different version than in dependencyManagement
- if ( managedVersions instanceof ManagedVersionMap )
- {
- /* avoid modifying the managedVersions parameter creating a new map */
- versionMap = new ManagedVersionMap( managedVersions );
- }
- versionMap.remove( originatingArtifact.getDependencyConflictId() );
+ /* avoid modifying the managedVersions parameter creating a new map */
+ versionMap = new ManagedVersionMap( managedVersions );
}
+ versionMap.remove( originatingArtifact.getDependencyConflictId() );
}
return versionMap;
diff --git a/maven-project/src/test/java/org/apache/maven/project/inheritance/t11/ProjectInheritanceTest.java b/maven-project/src/test/java/org/apache/maven/project/inheritance/t11/ProjectInheritanceTest.java
new file mode 100644
index 0000000000..7078891a98
--- /dev/null
+++ b/maven-project/src/test/java/org/apache/maven/project/inheritance/t11/ProjectInheritanceTest.java
@@ -0,0 +1,78 @@
+package org.apache.maven.project.inheritance.t11;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.Iterator;
+
+import org.apache.maven.model.Build;
+import org.apache.maven.model.MailingList;
+import org.apache.maven.model.Plugin;
+import org.apache.maven.model.PluginExecution;
+import org.apache.maven.model.Dependency;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase;
+import org.apache.maven.artifact.Artifact;
+import org.codehaus.plexus.util.xml.Xpp3Dom;
+import org.codehaus.plexus.logging.LoggerManager;
+import org.codehaus.plexus.logging.Logger;
+
+/**
+ * Verifies scope of root project is preserved regardless of parent depenedency management.
+ *
+ * @author Patrick Schneider
+ * @version $Id$
+ * @see MNG-2919
+ */
+public class ProjectInheritanceTest
+ extends AbstractProjectInheritanceTestCase
+{
+ // ----------------------------------------------------------------------
+ //
+ // p1 inherits from p0
+ // p0 inhertis from super model
+ //
+ // or we can show it graphically as:
+ //
+ // p1 ---> p0 --> super model
+ //
+ // ----------------------------------------------------------------------
+
+ public void testDependencyManagementDoesNotOverrideScopeOfCurrentArtifact()
+ throws Exception
+ {
+ File localRepo = getLocalRepositoryPath();
+
+ File pom0 = new File( localRepo, "p0/pom.xml" );
+ File pom0Basedir = pom0.getParentFile();
+ File pom1 = new File( pom0Basedir, "p1/pom.xml" );
+
+ // load the child project, which inherits from p0...
+ MavenProject project0 = getProjectWithDependencies( pom0 );
+ MavenProject project1 = getProjectWithDependencies( pom1 );
+
+ assertEquals( pom0Basedir, project1.getParent().getBasedir() );
+ assertNull( "dependencyManagement has overwritten the scope of the currently building child project",
+ project1.getArtifact().getScope() );
+ }
+}
diff --git a/maven-project/src/test/resources/inheritance-repo/t11/p0/p1/pom.xml b/maven-project/src/test/resources/inheritance-repo/t11/p0/p1/pom.xml
new file mode 100644
index 0000000000..e4c79be457
--- /dev/null
+++ b/maven-project/src/test/resources/inheritance-repo/t11/p0/p1/pom.xml
@@ -0,0 +1,16 @@
+
+
+ p0
+ maven
+ 1.0
+
+ 4.0.0
+ maven
+ p1
+ jar
+ p1
+ 1.0
+
+ scm-url
+
+
diff --git a/maven-project/src/test/resources/inheritance-repo/t11/p0/pom.xml b/maven-project/src/test/resources/inheritance-repo/t11/p0/pom.xml
new file mode 100644
index 0000000000..23b07e2c0a
--- /dev/null
+++ b/maven-project/src/test/resources/inheritance-repo/t11/p0/pom.xml
@@ -0,0 +1,27 @@
+
+ 4.0.0
+ maven
+ p0
+ pom
+ p0
+ 1.0
+
+ Codehaus
+
+
+
+
+
+
+
+ maven
+ p1
+ 1.0
+ test
+
+
+
+
+
+
+