[MNG-4522] Maven3 doesn't fail build when a pom from transitive dependency can't be found

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@902573 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2010-01-24 14:24:34 +00:00
parent 974bf9d27a
commit 3b35b6222a
3 changed files with 43 additions and 6 deletions

View File

@ -569,7 +569,10 @@ public class DefaultArtifactResolver
}
catch ( ArtifactMetadataRetrievalException e )
{
// need to add metadata resolution exception
ArtifactResolutionException are =
new ArtifactResolutionException( "Unable to get dependency information for " + rootArtifact.getId()
+ ": " + e.getMessage(), rootArtifact, metadataRequest.getRemoteRepositories(), e );
result.addMetadataResolutionException( are );
return result;
}
}

View File

@ -583,8 +583,8 @@ public class DefaultLegacyArtifactCollector
{
artifact.setDependencyTrail( node.getDependencyTrail() );
throw new ArtifactResolutionException( "Unable to get dependency information: "
+ e.getMessage(), artifact, childRemoteRepositories, e );
throw new ArtifactResolutionException( "Unable to get dependency information for "
+ artifact.getId() + ": " + e.getMessage(), artifact, childRemoteRepositories, e );
}
ArtifactResolutionRequest subRequest = new ArtifactResolutionRequest( metadataRequest );

View File

@ -54,7 +54,10 @@ import org.apache.maven.model.DependencyManagement;
import org.apache.maven.model.DistributionManagement;
import org.apache.maven.model.Exclusion;
import org.apache.maven.model.Relocation;
import org.apache.maven.model.building.ModelBuildingException;
import org.apache.maven.model.building.ModelBuildingRequest;
import org.apache.maven.model.building.ModelProblem;
import org.apache.maven.model.resolution.UnresolvableModelException;
import org.apache.maven.plugin.LegacySupport;
import org.apache.maven.project.DefaultProjectBuildingRequest;
import org.apache.maven.project.MavenProject;
@ -573,17 +576,26 @@ public class MavenMetadataSource
}
catch ( ProjectBuildingException e )
{
ModelProblem missingParentPom = hasMissingParentPom( e );
if ( missingParentPom != null )
{
throw new ArtifactMetadataRetrievalException( "Failed to process POM for "
+ relocatedArtifact.getId() + ": " + missingParentPom.getMessage(),
missingParentPom.getException(),
relocatedArtifact );
}
String message;
// missing/incompatible POM (e.g. a Maven 1 POM)
if ( e.getCause() instanceof ArtifactResolutionException )
if ( isMissingPom( e ) )
{
message = "Missing artifact metadata for " + relocatedArtifact.getId();
message = "Missing POM for " + relocatedArtifact.getId();
}
else
{
message =
"Invalid artifact metadata for " + relocatedArtifact.getId()
"Invalid POM for " + relocatedArtifact.getId()
+ ", transitive dependencies (if any) will not be available"
+ ", enable debug logging for more details";
}
@ -693,6 +705,28 @@ public class MavenMetadataSource
return rel;
}
private boolean isMissingPom( ProjectBuildingException e )
{
return e.getCause() instanceof ArtifactResolutionException;
}
private ModelProblem hasMissingParentPom( ProjectBuildingException e )
{
if ( e.getCause() instanceof ModelBuildingException )
{
ModelBuildingException mbe = (ModelBuildingException) e.getCause();
for ( ModelProblem problem : mbe.getProblems() )
{
if ( problem.getException() instanceof UnresolvableModelException )
{
return problem;
}
}
}
return null;
}
private Properties getSystemProperties()
{
Properties props = new Properties();