mirror of
https://github.com/apache/maven.git
synced 2025-02-28 21:59:13 +00:00
Make sure that all calls to buildFromRepository use a normalized List of remote repositories (a list of ArtifactRepository instances, not of model Repository instances, for example)...this should be less of a concern when we can use Java5 generics (someday).
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@616610 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ba9624676d
commit
30342818f0
@ -24,6 +24,7 @@
|
||||
import org.apache.maven.artifact.ArtifactStatus;
|
||||
import org.apache.maven.artifact.ArtifactUtils;
|
||||
import org.apache.maven.artifact.InvalidRepositoryException;
|
||||
import org.apache.maven.artifact.UnknownRepositoryLayoutException;
|
||||
import org.apache.maven.artifact.factory.ArtifactFactory;
|
||||
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
@ -46,6 +47,7 @@
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.Plugin;
|
||||
import org.apache.maven.model.ReportPlugin;
|
||||
import org.apache.maven.model.Repository;
|
||||
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
|
||||
import org.apache.maven.profiles.MavenProfilesBuilder;
|
||||
import org.apache.maven.profiles.ProfileManager;
|
||||
@ -159,13 +161,13 @@ public class DefaultMavenProjectBuilder
|
||||
private ProfileAdvisor profileAdvisor;
|
||||
|
||||
private MavenTools mavenTools;
|
||||
|
||||
|
||||
//DO NOT USE, it is here only for backward compatibility reasons. The existing
|
||||
// maven-assembly-plugin (2.2-beta-1) is accessing it via reflection.
|
||||
|
||||
// the aspect weaving seems not to work for reflection from plugin.
|
||||
private Map processedProjectCache = new HashMap();
|
||||
|
||||
|
||||
|
||||
public static final String MAVEN_MODEL_VERSION = "4.0.0";
|
||||
|
||||
@ -456,6 +458,10 @@ private Model findModelFromRepository( Artifact artifact,
|
||||
ArtifactRepository localRepository )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
String projectId = safeVersionlessKey( artifact.getGroupId(), artifact.getArtifactId() );
|
||||
|
||||
remoteArtifactRepositories = normalizeToArtifactRepositories( remoteArtifactRepositories, projectId );
|
||||
|
||||
Artifact projectArtifact;
|
||||
|
||||
// if the artifact is not a POM, we need to construct a POM artifact based on the artifact parameter given.
|
||||
@ -477,8 +483,6 @@ private Model findModelFromRepository( Artifact artifact,
|
||||
|
||||
Model model;
|
||||
|
||||
String projectId = ArtifactUtils.versionlessKey( projectArtifact );
|
||||
|
||||
try
|
||||
{
|
||||
artifactResolver.resolve( projectArtifact, remoteArtifactRepositories, localRepository );
|
||||
@ -525,6 +529,52 @@ private Model findModelFromRepository( Artifact artifact,
|
||||
return model;
|
||||
}
|
||||
|
||||
private List normalizeToArtifactRepositories( List remoteArtifactRepositories,
|
||||
String projectId )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
List normalized = new ArrayList( remoteArtifactRepositories.size() );
|
||||
|
||||
boolean normalizationNeeded = false;
|
||||
for ( Iterator it = remoteArtifactRepositories.iterator(); it.hasNext(); )
|
||||
{
|
||||
Object item = it.next();
|
||||
|
||||
if ( item instanceof ArtifactRepository )
|
||||
{
|
||||
normalized.add( item );
|
||||
}
|
||||
else if ( item instanceof Repository )
|
||||
{
|
||||
Repository repo = (Repository) item;
|
||||
try
|
||||
{
|
||||
item = mavenTools.buildArtifactRepository( repo );
|
||||
|
||||
normalized.add( item );
|
||||
normalizationNeeded = true;
|
||||
}
|
||||
catch ( UnknownRepositoryLayoutException e )
|
||||
{
|
||||
throw new ProjectBuildingException( projectId, "Error building artifact repository for id: " + repo.getId(), e );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ProjectBuildingException( projectId, "Error building artifact repository from non-repository information item: " + item );
|
||||
}
|
||||
}
|
||||
|
||||
if ( normalizationNeeded )
|
||||
{
|
||||
return normalized;
|
||||
}
|
||||
else
|
||||
{
|
||||
return remoteArtifactRepositories;
|
||||
}
|
||||
}
|
||||
|
||||
private void checkStatusAndUpdate( Artifact projectArtifact,
|
||||
ArtifactStatus status,
|
||||
File file,
|
||||
|
Loading…
x
Reference in New Issue
Block a user