mirror of https://github.com/apache/maven.git
o Better error reporting.
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163187 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d8c9056f67
commit
3045b7fcfc
|
@ -1,19 +1,20 @@
|
||||||
package org.apache.maven.artifact;
|
package org.apache.maven.artifact;
|
||||||
|
|
||||||
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
|
|
||||||
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
|
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
|
||||||
import org.apache.maven.artifact.resolver.ArtifactResolver;
|
|
||||||
import org.apache.maven.model.Dependency;
|
|
||||||
import org.apache.maven.model.Model;
|
|
||||||
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
|
|
||||||
|
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
|
||||||
|
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
|
||||||
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
||||||
|
import org.apache.maven.artifact.resolver.ArtifactResolver;
|
||||||
|
import org.apache.maven.model.Dependency;
|
||||||
|
import org.apache.maven.model.Model;
|
||||||
|
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2001-2004 The Apache Software Foundation.
|
* Copyright 2001-2004 The Apache Software Foundation.
|
||||||
*
|
*
|
||||||
|
@ -61,22 +62,26 @@ public class MavenMetadataSource
|
||||||
{
|
{
|
||||||
Set artifacts;
|
Set artifacts;
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Artifact metadataArtifact = new DefaultArtifact( artifact.getGroupId(),
|
Artifact metadataArtifact = new DefaultArtifact( artifact.getGroupId(),
|
||||||
artifact.getArtifactId(),
|
artifact.getArtifactId(),
|
||||||
artifact.getVersion(),
|
artifact.getVersion(),
|
||||||
"pom" );
|
"pom" );
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
artifactResolver.resolve( metadataArtifact, remoteRepositories, localRepository );
|
artifactResolver.resolve( metadataArtifact, remoteRepositories, localRepository );
|
||||||
|
|
||||||
Model model = reader.read( new FileReader( metadataArtifact.getFile() ) );
|
Model model = reader.read( new FileReader( metadataArtifact.getFile() ) );
|
||||||
|
|
||||||
artifacts = createArtifacts( model.getDependencies(), localRepository );
|
artifacts = createArtifacts( model.getDependencies(), localRepository );
|
||||||
}
|
}
|
||||||
|
catch ( ArtifactResolutionException e )
|
||||||
|
{
|
||||||
|
throw new ArtifactMetadataRetrievalException( "Error while resolving metadata artifact", e );
|
||||||
|
}
|
||||||
catch ( Exception e )
|
catch ( Exception e )
|
||||||
{
|
{
|
||||||
throw new ArtifactMetadataRetrievalException( "Cannot read artifact source: ", e );
|
throw new ArtifactMetadataRetrievalException( "Cannot read artifact source: " + metadataArtifact.getFile(), e );
|
||||||
}
|
}
|
||||||
|
|
||||||
return artifacts;
|
return artifacts;
|
||||||
|
|
Loading…
Reference in New Issue