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(), Artifact artifact = artifactFactory.createProjectArtifact( plugin.getGroupId(), plugin.getArtifactId(),
plugin.getVersion() ); plugin.getVersion() );
MavenProject project = mavenProjectBuilder.buildFromRepository( artifact, remoteRepositories, MavenProject project = mavenProjectBuilder.buildFromRepository( artifact, remoteRepositories,
localRepository ); localRepository, false );
// if we don't have the required Maven version, then ignore an update // if we don't have the required Maven version, then ignore an update
if ( project.getPrerequisites() != null && project.getPrerequisites().getMaven() != null ) if ( project.getPrerequisites() != null && project.getPrerequisites().getMaven() != null )
{ {

View File

@ -595,8 +595,9 @@ public class DefaultPluginVersionManager
} }
catch ( IOException e ) catch ( IOException e )
{ {
getLogger().warn( "Cannot rewrite user-level plugin-registry.xml with new plugin version of plugin: \'" getLogger().warn(
+ groupId + ":" + artifactId + "\'.", e ); "Cannot rewrite user-level plugin-registry.xml with new plugin version of plugin: \'" + groupId +
":" + artifactId + "\'.", e );
} }
finally finally
{ {
@ -653,7 +654,7 @@ public class DefaultPluginVersionManager
if ( artifact.getFile() != null ) if ( artifact.getFile() != null )
{ {
MavenProject project = mavenProjectBuilder.buildFromRepository( artifact, remoteRepositories, MavenProject project = mavenProjectBuilder.buildFromRepository( artifact, remoteRepositories,
localRepository ); localRepository, false );
boolean pluginValid = true; boolean pluginValid = true;

View File

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

View File

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

View File

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

View File

@ -68,6 +68,20 @@ public interface MavenProjectBuilder
ArtifactRepository localRepository ) ArtifactRepository localRepository )
throws ProjectBuildingException; 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 ) MavenProject buildStandaloneSuperProject( ArtifactRepository localRepository )
throws ProjectBuildingException; throws ProjectBuildingException;
} }

View File

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