PR: MNG-1108

don't resolve a default POM for a parent or dependency of type POM

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@307047 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-10-07 08:03:25 +00:00
parent bd41253cba
commit 70ab341c64
7 changed files with 56 additions and 17 deletions

View File

@ -231,7 +231,7 @@ public class DefaultPluginManager
Artifact artifact = artifactFactory.createProjectArtifact( plugin.getGroupId(), plugin.getArtifactId(),
plugin.getVersion() );
MavenProject project = mavenProjectBuilder.buildFromRepository( artifact, remoteRepositories,
localRepository );
localRepository, false );
// if we don't have the required Maven version, then ignore an update
if ( project.getPrerequisites() != null && project.getPrerequisites().getMaven() != null )
{

View File

@ -92,12 +92,12 @@ public class DefaultPluginVersionManager
{
// before we do anything else, if this is a self-reference we need to short-circuit the resolution process.
String projectKey = constructPluginKey( project.getGroupId(), project.getArtifactId() );
if ( projectKey.equals( constructPluginKey( groupId, artifactId ) ) )
{
return project.getVersion();
}
// first pass...if the plugin is specified in the pom, try to retrieve the version from there.
String version = getVersionFromPluginConfig( groupId, artifactId, project, resolveAsReportPlugin );
@ -595,8 +595,9 @@ public class DefaultPluginVersionManager
}
catch ( IOException e )
{
getLogger().warn( "Cannot rewrite user-level plugin-registry.xml with new plugin version of plugin: \'"
+ groupId + ":" + artifactId + "\'.", e );
getLogger().warn(
"Cannot rewrite user-level plugin-registry.xml with new plugin version of plugin: \'" + groupId +
":" + artifactId + "\'.", e );
}
finally
{
@ -653,7 +654,7 @@ public class DefaultPluginVersionManager
if ( artifact.getFile() != null )
{
MavenProject project = mavenProjectBuilder.buildFromRepository( artifact, remoteRepositories,
localRepository );
localRepository, false );
boolean pluginValid = true;
@ -672,7 +673,7 @@ public class DefaultPluginVersionManager
}
String artifactVersion = artifact.getVersion();
if ( pluginValid && !metaVersionId.equals( artifactVersion ) )
{
version = artifactVersion;

View File

@ -2,7 +2,7 @@
<parent>
<artifactId>maven-plugin-parent</artifactId>
<groupId>org.apache.maven.plugins</groupId>
<version>2.0-beta-1</version>
<version>2.0-beta-4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>maven-project-info-reports-plugin</artifactId>
@ -10,6 +10,9 @@
<name>Maven Project Info Reports Plugin</name>
<version>2.0-beta-2-SNAPSHOT</version>
<inceptionYear>2005</inceptionYear>
<prerequisites>
<maven>2.0-beta-4-SNAPSHOT</maven>
</prerequisites>
<developers>
<developer>
<id>vsiveton</id>

View File

@ -351,16 +351,18 @@ public class DependenciesReport
{
Artifact projectArtifact = artifact;
boolean allowStubModel = false;
if ( !"pom".equals( artifact.getType() ) )
{
projectArtifact = artifactFactory.createProjectArtifact( artifact.getGroupId(),
artifact.getArtifactId(),
artifact.getVersion(), artifact.getScope() );
allowStubModel = true;
}
// TODO: we should use the MavenMetadataSource instead
return mavenProjectBuilder.buildFromRepository( projectArtifact, project.getRepositories(),
localRepository );
return mavenProjectBuilder.buildFromRepository( projectArtifact, project.getRepositories(), localRepository,
allowStubModel );
}
}

View File

@ -305,6 +305,13 @@ public class DefaultMavenProjectBuilder
public MavenProject buildFromRepository( Artifact artifact, List remoteArtifactRepositories,
ArtifactRepository localRepository )
throws ProjectBuildingException
{
return buildFromRepository( artifact, remoteArtifactRepositories, localRepository, true );
}
public MavenProject buildFromRepository( Artifact artifact, List remoteArtifactRepositories,
ArtifactRepository localRepository, boolean allowStubModel )
throws ProjectBuildingException
{
String cacheKey = createCacheKey( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion() );
MavenProject project = (MavenProject) projectCache.get( cacheKey );
@ -313,14 +320,14 @@ public class DefaultMavenProjectBuilder
return project;
}
Model model = findModelFromRepository( artifact, remoteArtifactRepositories, localRepository );
Model model = findModelFromRepository( artifact, remoteArtifactRepositories, localRepository, allowStubModel );
return build( "Artifact [" + artifact.getId() + "]", model, localRepository, remoteArtifactRepositories, null,
null );
}
private Model findModelFromRepository( Artifact artifact, List remoteArtifactRepositories,
ArtifactRepository localRepository )
ArtifactRepository localRepository, boolean allowStubModel )
throws ProjectBuildingException
{
Artifact projectArtifact;
@ -349,6 +356,7 @@ public class DefaultMavenProjectBuilder
artifactResolver.resolve( projectArtifact, remoteArtifactRepositories, localRepository );
File file = projectArtifact.getFile();
// TODO: how can this not be true?
if ( projectArtifact.isResolved() )
{
model = readModel( file );
@ -408,10 +416,14 @@ public class DefaultMavenProjectBuilder
projectArtifact.setDownloadUrl( model.getUrl() );
}
}
else
else if ( allowStubModel )
{
model = createStubModel( projectArtifact );
}
else
{
throw new ProjectBuildingException( "POM could not be resolved from the repository" );
}
}
catch ( ArtifactResolutionException e )
{
@ -419,7 +431,14 @@ public class DefaultMavenProjectBuilder
}
catch ( ArtifactNotFoundException e )
{
model = createStubModel( projectArtifact );
if ( allowStubModel )
{
model = createStubModel( projectArtifact );
}
else
{
throw new ProjectBuildingException( "POM not found in repository", e );
}
}
}
else
@ -854,7 +873,7 @@ public class DefaultMavenProjectBuilder
// we can't query the parent to ask where it is :)
List remoteRepositories = new ArrayList( aggregatedRemoteWagonRepositories );
remoteRepositories.addAll( parentSearchRepositories );
model = findModelFromRepository( parentArtifact, remoteRepositories, localRepository );
model = findModelFromRepository( parentArtifact, remoteRepositories, localRepository, false );
}
File parentProjectDir = null;

View File

@ -68,6 +68,20 @@ public interface MavenProjectBuilder
ArtifactRepository localRepository )
throws ProjectBuildingException;
/**
* Build the artifact from the local repository, resolving it if necessary.
*
* @param artifact the artifact description
* @param localRepository the local repository
* @param remoteArtifactRepositories the remote repository list
* @param allowStubModel return a stub if the POM is not found
* @return the built project
* @throws ProjectBuildingException
*/
MavenProject buildFromRepository( Artifact artifact, List remoteArtifactRepositories,
ArtifactRepository localRepository, boolean allowStubModel )
throws ProjectBuildingException;
MavenProject buildStandaloneSuperProject( ArtifactRepository localRepository )
throws ProjectBuildingException;
}

View File

@ -106,8 +106,8 @@ public class MavenMetadataSource
{
try
{
project = mavenProjectBuilder.buildFromRepository( pomArtifact, remoteRepositories,
localRepository );
project = mavenProjectBuilder.buildFromRepository( pomArtifact, remoteRepositories, localRepository,
true );
}
catch ( InvalidModelException e )
{