o Fixing the parent POM downloading problem.

{issue:MNG-19}


git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@162954 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jason van Zyl 2004-08-10 17:59:30 +00:00
parent d65f17e823
commit 676c9b5e74
4 changed files with 59 additions and 20 deletions

View File

@ -18,6 +18,7 @@
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DefaultArtifact;
import org.apache.maven.artifact.resolver.ArtifactResolver;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.model.Dependency;

View File

@ -56,6 +56,8 @@
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.Collection;
import java.util.Collections;
public class DefaultMavenProjectBuilder
extends AbstractLogEnabled
@ -102,11 +104,10 @@ public MavenProject build( File projectDescriptor, ArtifactRepository localRepos
LinkedList lineage = new LinkedList();
MavenProject project = assembleLineage( projectDescriptor, localRepository, lineage );
// I think we will need to move this into the assembleLineage method in order to
// have access to any repositories set in any of the models. Otherwise we don't
// have the information required to to retrieve parent poms.
MavenProject project = assembleLineage( projectDescriptor,
localRepository,
lineage,
superModel.getRepositories() );
modelInheritanceAssembler.assembleModelInheritance( ( (MavenProject) lineage.get( 0 ) ).getModel(), superModel );
@ -165,7 +166,10 @@ public MavenProject build( File projectDescriptor, ArtifactRepository localRepos
}
}
private MavenProject assembleLineage( File projectDescriptor, ArtifactRepository localRepository, LinkedList lineage )
private MavenProject assembleLineage( File projectDescriptor,
ArtifactRepository localRepository,
LinkedList lineage,
List remoteRepositories )
throws Exception
{
Map properties = createProjectProperties( projectDescriptor.getParentFile() );
@ -197,18 +201,20 @@ else if ( isEmpty( parentModel.getVersion() ) )
//!! (**)
// ----------------------------------------------------------------------
// Do the have the necessary information to actually find the parent
// Do we have the necessary information to actually find the parent
// POMs here?? I don't think so ... Say only one remote repository is
// specified and that is ibiblio then this model that we just read doesn't
// have any repository information ... I think we might have to inherit
// as we go in order to do this.
// ----------------------------------------------------------------------
remoteRepositories.addAll( model.getRepositories() );
File parentPom = findParentModel( parentModel,
RepositoryUtils.mavenToWagon( model.getRepositories() ),
RepositoryUtils.mavenToWagon( remoteRepositories ),
localRepository );
MavenProject parent = assembleLineage( parentPom, localRepository, lineage );
MavenProject parent = assembleLineage( parentPom, localRepository, lineage, remoteRepositories );
project.setParent( parent );
}

View File

@ -1,11 +0,0 @@
-----
Bugs
-----
Jason van Zyl
-----
Bugs
* Need apt form of navigation.xml.
* XML doesn't render correctly in source blobs. (fixed)

View File

@ -0,0 +1,43 @@
-----
Inheritance in Maven
-----
Jason van Zyl
-----
Inheritance in Maven
In order the understand how inheritance works in Maven there are a few notions that you must be familiar with:
* The maven super model
* how parent poms are processed
* the order in which elements in the POM are overridden
Maven super model
Inheritance is recursive in Maven but there is a special model which is the implicit super parent in the lineage
of models you may specify:
all of the models that you specify are collected to produce a lineage and then the super model is place at
the top of that lineage to provide default values.
The super model is where we place all the values which we believe to be standard, values that can be shared and
utilized across all your maven projects.
m0 <- m1 <- m2
which is transformed into
super model <- m0 <- m1 <- m2
<project>
<modelVersion></modelVersion>
<parent>
<groupId></groupId>
<artifactId></artifactId>
<version></version>
</parent>
</project>