Revert 578553

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@579086 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Ralph Goers 2007-09-25 06:27:01 +00:00
parent 63c8806450
commit 0c84fd3f65
26 changed files with 0 additions and 585 deletions

View File

@ -100,7 +100,6 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
/*:apt
@ -759,8 +758,6 @@ public class DefaultMavenProjectBuilder
}
}
mergeManagedDependencies(project.getModel(), localRepository, parentSearchRepositories);
try
{
project = processProjectLogic( pomLocation, project, externalProfileManager, projectDir, strict );
@ -1110,66 +1107,6 @@ public class DefaultMavenProjectBuilder
return result;
}
private void mergeManagedDependencies(Model model, ArtifactRepository localRepository, List parentSearchRepositories)
throws ProjectBuildingException
{
DependencyManagement modelDepMgmt = model.getDependencyManagement();
if (modelDepMgmt != null)
{
Map depsMap = new TreeMap();
Iterator iter = modelDepMgmt.getDependencies().iterator();
boolean doInclude = false;
while (iter.hasNext())
{
Dependency dep = (Dependency) iter.next();
depsMap.put( dep.getManagementKey(), dep );
if (dep.getType().equals("pom") && Artifact.SCOPE_IMPORT.equals(dep.getScope()))
{
doInclude = true;
}
}
Map newDeps = new TreeMap(depsMap);
iter = modelDepMgmt.getDependencies().iterator();
if (doInclude)
{
while (iter.hasNext())
{
Dependency dep = (Dependency)iter.next();
if (dep.getType().equals("pom") && Artifact.SCOPE_IMPORT.equals(dep.getScope()))
{
Artifact artifact = artifactFactory.createProjectArtifact( dep.getGroupId(), dep.getArtifactId(),
dep.getVersion(), dep.getScope() );
MavenProject project = buildFromRepository(artifact, parentSearchRepositories, localRepository, false);
DependencyManagement depMgmt = project.getDependencyManagement();
if (depMgmt != null)
{
if ( getLogger().isDebugEnabled() )
{
getLogger().debug( "Importing managed dependencies for " + dep.toString() );
}
for ( Iterator it = depMgmt.getDependencies().iterator(); it.hasNext(); )
{
Dependency includedDep = (Dependency) it.next();
String key = includedDep.getManagementKey();
if (!newDeps.containsKey(key))
{
newDeps.put( includedDep.getManagementKey(), includedDep );
}
}
newDeps.remove(dep.getManagementKey());
}
}
}
List deps = new ArrayList(newDeps.values());
modelDepMgmt.setDependencies(deps);
}
}
}
private Model readModel( String projectId,
File file,
boolean strict )

View File

@ -1,53 +0,0 @@
package org.apache.maven.project.imports;
/*
* 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 org.apache.maven.project.AbstractMavenProjectTestCase;
import java.io.File;
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id: AbstractProjectInheritanceTestCase.java 495147 2007-01-11 07:47:53Z jvanzyl $
*/
public abstract class AbstractProjectImportsTestCase
extends AbstractMavenProjectTestCase
{
protected String getTestSeries()
{
String className = getClass().getPackage().getName();
return className.substring( className.lastIndexOf( "." ) + 1 );
}
protected File projectFile( String name )
{
return new File( getLocalRepositoryPath(), "/maven/poms/" + name + "-1.0.pom" );
}
// ----------------------------------------------------------------------
// The local repository for this category of tests
// ----------------------------------------------------------------------
protected File getLocalRepositoryPath()
{
return getTestFile( "src/test/resources/imports-repo/" + getTestSeries() );
}
}

View File

@ -1,130 +0,0 @@
package org.apache.maven.project.imports.t01;
/*
* 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.Map;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.imports.AbstractProjectImportsTestCase;
import org.apache.maven.artifact.Artifact;
/**
* Verifies managed dependencies are imported into other projects correctly.
*
* @version $Id: $
*/
public class ProjectImportsTest extends AbstractProjectImportsTestCase
{
// ----------------------------------------------------------------------
//
// p1 inherits from p0
// p0 inhertis from super model
//
// or we can show it graphically as:
//
// p1 ---> p0 --> super model
//
// ----------------------------------------------------------------------
public void testDependencyManagementImportsVersions() throws Exception
{
File localRepo = getLocalRepositoryPath();
File pom0 = new File( localRepo, "p0/pom.xml" );
File pom0Basedir = pom0.getParentFile();
System.out.println("basedir " + pom0Basedir.getAbsolutePath());
File pom1 = new File( pom0Basedir, "p1/pom.xml" );
File pom2 = new File( pom0Basedir, "p2/pom.xml" );
File pom3 = new File( pom0Basedir, "p3/pom.xml" );
File pom4 = new File( pom0Basedir, "p4/pom.xml" );
getProjectWithDependencies( pom0 );
// load the child project, which inherits from p0...
// MavenProject project0 = getProjectWithDependencies( pom0 );
MavenProject project1 = getProjectWithDependencies( pom1 );
assertEquals( pom0Basedir, project1.getParent().getBasedir() );
Map map = project1.getArtifactMap();
assertNotNull("No artifacts", map);
assertTrue("No Artifacts", map.size() > 0);
assertTrue("Set size should be 2, is " + map.size(), map.size() == 2);
Artifact a = (Artifact) map.get("maven-test:maven-test-a");
Artifact b = (Artifact) map.get("maven-test:maven-test-b");
assertTrue("Incorrect version for " + a.getDependencyConflictId(), a.getVersion().equals("1.0"));
assertTrue("Incorrect version for " + b.getDependencyConflictId(), b.getVersion().equals("1.0"));
// load the child project, which inherits from p0...
// MavenProject project0 = getProjectWithDependencies( pom0 );
MavenProject project2 = getProjectWithDependencies( pom2 );
map = project2.getArtifactMap();
assertNotNull("No artifacts", map);
assertTrue("No Artifacts", map.size() > 0);
assertTrue("Set size should be 3, is " + map.size(), map.size() == 3);
a = (Artifact) map.get("maven-test:maven-test-a");
b = (Artifact) map.get("maven-test:maven-test-b");
Artifact c = (Artifact) map.get("maven-test:maven-test-c");
assertTrue("Incorrect version for " + a.getDependencyConflictId(), a.getVersion().equals("1.0"));
assertTrue("Incorrect version for " + b.getDependencyConflictId(), b.getVersion().equals("1.0"));
assertTrue("Incorrect version for " + c.getDependencyConflictId(), c.getVersion().equals("1.0"));
// load the child project, which inherits from p0...
// MavenProject project0 = getProjectWithDependencies( pom0 );
MavenProject project3 = getProjectWithDependencies( pom3 );
map = project3.getArtifactMap();
assertNotNull("No artifacts", map);
assertTrue("No Artifacts", map.size() > 0);
assertTrue("Set size should be 3, is " + map.size(), map.size() == 3);
a = (Artifact) map.get("maven-test:maven-test-a");
c = (Artifact) map.get("maven-test:maven-test-c");
Artifact d = (Artifact) map.get("maven-test:maven-test-d");
assertTrue("Incorrect version for " + a.getDependencyConflictId(), a.getVersion().equals("1.1"));
assertTrue("Incorrect version for " + c.getDependencyConflictId(), c.getVersion().equals("1.1"));
assertTrue("Incorrect version for " + d.getDependencyConflictId(), d.getVersion().equals("1.0"));
// load the child project, which inherits from p0...
// MavenProject project0 = getProjectWithDependencies( pom0 );
MavenProject project4 = getProjectWithDependencies( pom4 );
map = project4.getArtifactMap();
assertNotNull("No artifacts", map);
assertTrue("No Artifacts", map.size() > 0);
assertTrue("Set size should be 4, is " + map.size(), map.size() == 4);
a = (Artifact) map.get("maven-test:maven-test-a");
b = (Artifact) map.get("maven-test:maven-test-b");
c = (Artifact) map.get("maven-test:maven-test-c");
d = (Artifact) map.get("maven-test:maven-test-d");
assertTrue("Incorrect version for " + a.getDependencyConflictId(), a.getVersion().equals("1.0"));
assertTrue("Incorrect version for " + b.getDependencyConflictId(), b.getVersion().equals("1.1"));
assertTrue("Incorrect version for " + c.getDependencyConflictId(), c.getVersion().equals("1.0"));
assertTrue("Incorrect version for " + d.getDependencyConflictId(), d.getVersion().equals("1.0"));
}
}

View File

@ -1,14 +0,0 @@
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>maven-test</groupId>
<artifactId>maven-test-a</artifactId>
<packaging>jar</packaging>
<version>1.0</version>
<repositories>
<repository>
<id>central</id>
<name>Fake Maven Central Repository</name>
<url>file://dummy</url>
</repository>
</repositories>
</project>

View File

@ -1,14 +0,0 @@
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>maven-test</groupId>
<artifactId>maven-test-a</artifactId>
<packaging>jar</packaging>
<version>1.1</version>
<repositories>
<repository>
<id>central</id>
<name>Fake Maven Central Repository</name>
<url>file://dummy</url>
</repository>
</repositories>
</project>

View File

@ -1,7 +0,0 @@
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>maven-test</groupId>
<artifactId>maven-test-b</artifactId>
<packaging>jar</packaging>
<version>1.0</version>
</project>

View File

@ -1,7 +0,0 @@
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>maven-test</groupId>
<artifactId>maven-test-b</artifactId>
<packaging>jar</packaging>
<version>1.1</version>
</project>

View File

@ -1,7 +0,0 @@
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>maven-test</groupId>
<artifactId>maven-test-c</artifactId>
<packaging>jar</packaging>
<version>1.0</version>
</project>

View File

@ -1,7 +0,0 @@
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>maven-test</groupId>
<artifactId>maven-test-c</artifactId>
<packaging>jar</packaging>
<version>1.1</version>
</project>

View File

@ -1,7 +0,0 @@
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>maven-test</groupId>
<artifactId>maven-test-d</artifactId>
<packaging>jar</packaging>
<version>1.0</version>
</project>

View File

@ -1,7 +0,0 @@
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>maven-test</groupId>
<artifactId>maven-test-d</artifactId>
<packaging>jar</packaging>
<version>1.1</version>
</project>

View File

@ -1,7 +0,0 @@
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>maven-test</groupId>
<artifactId>maven-test-d</artifactId>
<packaging>jar</packaging>
<version>1.2</version>
</project>

View File

@ -1,45 +0,0 @@
<project>
<parent>
<artifactId>p0</artifactId>
<groupId>maven</groupId>
<version>1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>maven</groupId>
<artifactId>p1</artifactId>
<packaging>pom</packaging>
<name>p1</name>
<version>1.0</version>
<scm>
<url>scm-url</url>
</scm>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>maven-test</groupId>
<artifactId>maven-test-b</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>maven-test</groupId>
<artifactId>maven-test-a</artifactId>
</dependency>
<dependency>
<groupId>maven-test</groupId>
<artifactId>maven-test-b</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<configuration>
<tasks><echo>${project.parent.basedir}</echo></tasks>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -1,56 +0,0 @@
<project>
<parent>
<artifactId>p0</artifactId>
<groupId>maven</groupId>
<version>1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>maven</groupId>
<artifactId>p2</artifactId>
<packaging>pom</packaging>
<name>p2</name>
<version>1.0</version>
<scm>
<url>scm-url</url>
</scm>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>maven</groupId>
<artifactId>p1</artifactId>
<version>1.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>maven-test</groupId>
<artifactId>maven-test-c</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>maven-test</groupId>
<artifactId>maven-test-a</artifactId>
</dependency>
<dependency>
<groupId>maven-test</groupId>
<artifactId>maven-test-b</artifactId>
</dependency>
<dependency>
<groupId>maven-test</groupId>
<artifactId>maven-test-c</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<configuration>
<tasks><echo>${project.parent.basedir}</echo></tasks>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -1,59 +0,0 @@
<project>
<parent>
<artifactId>p0</artifactId>
<groupId>maven</groupId>
<version>1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>maven</groupId>
<artifactId>p3</artifactId>
<packaging>pom</packaging>
<name>p3</name>
<version>1.0</version>
<scm>
<url>scm-url</url>
</scm>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>maven-test</groupId>
<artifactId>maven-test-a</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>maven-test</groupId>
<artifactId>maven-test-c</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>maven-test</groupId>
<artifactId>maven-test-d</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>maven-test</groupId>
<artifactId>maven-test-a</artifactId>
</dependency>
<dependency>
<groupId>maven-test</groupId>
<artifactId>maven-test-c</artifactId>
</dependency>
<dependency>
<groupId>maven-test</groupId>
<artifactId>maven-test-d</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<configuration>
<tasks><echo>${project.parent.basedir}</echo></tasks>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -1,67 +0,0 @@
<project>
<parent>
<artifactId>p0</artifactId>
<groupId>maven</groupId>
<version>1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>maven</groupId>
<artifactId>p4</artifactId>
<packaging>pom</packaging>
<name>p4</name>
<version>1.0</version>
<scm>
<url>scm-url</url>
</scm>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>maven</groupId>
<artifactId>p2</artifactId>
<version>1.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>maven</groupId>
<artifactId>p3</artifactId>
<version>1.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>maven-test</groupId>
<artifactId>maven-test-b</artifactId>
<version>1.1</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>maven-test</groupId>
<artifactId>maven-test-a</artifactId>
</dependency>
<dependency>
<groupId>maven-test</groupId>
<artifactId>maven-test-b</artifactId>
</dependency>
<dependency>
<groupId>maven-test</groupId>
<artifactId>maven-test-c</artifactId>
</dependency>
<dependency>
<groupId>maven-test</groupId>
<artifactId>maven-test-d</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<configuration>
<tasks><echo>${project.parent.basedir}</echo></tasks>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -1,26 +0,0 @@
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>maven</groupId>
<artifactId>p0</artifactId>
<packaging>pom</packaging>
<name>p0</name>
<version>1.0</version>
<organization>
<name>Codehaus</name>
</organization>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>maven-test</groupId>
<artifactId>maven-test-a</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
</dependencyManagement>
<modules>
<module>p1</module>
<module>p2</module>
<module>p3</module>
<module>p4</module>
</modules>
</project>