* Correcting LocationArtifactReportProcessor to not throw IllegalStateException as it halts the discovery and indexing.

* Catching InvalidArtifactRTException in DefaultReportExecutor to allow discovery and indexing to proceed to next artifact unhindered.
* Catching InvalidArtifactRTException in StandardArtifactIndexRecordFactory to allow discovery and indexeing to proceed to next artifact unhindered.



git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@480817 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Joakim Erdfelt 2006-11-30 03:32:08 +00:00
parent 372029fa28
commit d839be48a7
4 changed files with 23 additions and 14 deletions

View File

@ -18,6 +18,7 @@ package org.apache.maven.archiva.indexer.record;
import org.apache.maven.archiva.indexer.RepositoryIndexException;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.InvalidArtifactRTException;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.model.Dependency;
@ -251,8 +252,17 @@ public class StandardArtifactIndexRecordFactory
{
// TODO: this can create a -SNAPSHOT.pom when it didn't exist and a timestamped one did. This is harmless, but should be avoided
// TODO: will this pollute with local repo metadata?
MavenProject project = projectBuilder.buildFromRepository( artifact, Collections.EMPTY_LIST, repository );
return project.getModel();
try
{
MavenProject project = projectBuilder.buildFromRepository( artifact, Collections.EMPTY_LIST, repository );
return project.getModel();
}
catch ( InvalidArtifactRTException e )
{
throw new ProjectBuildingException( artifact.getId(), "Unable to build project from invalid artifact ["
+ artifact + "]", e );
}
}
private void populateArchiveEntries( List files, StandardArtifactIndexRecord record, File artifactFile )

View File

@ -21,6 +21,7 @@ import org.apache.maven.archiva.discoverer.DiscovererException;
import org.apache.maven.archiva.discoverer.MetadataDiscoverer;
import org.apache.maven.archiva.discoverer.filter.AcceptAllMetadataFilter;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.InvalidArtifactRTException;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
@ -116,6 +117,10 @@ public class DefaultReportExecutor
model = project.getModel();
}
catch ( InvalidArtifactRTException e )
{
reporter.addWarning( artifact, null, null, "Invalid artifact [" + artifact + "] : " + e );
}
catch ( ProjectBuildingException e )
{
reporter.addWarning( artifact, null, null, "Error reading project model: " + e );

View File

@ -113,7 +113,7 @@ public class LocationArtifactReportProcessor
}
}
//get the location of the artifact itself
// get the location of the artifact itself
File file = new File( repository.getBasedir(), artifactPath );
if ( file.exists() )
@ -140,7 +140,7 @@ public class LocationArtifactReportProcessor
}
else
{
throw new IllegalStateException( "Couldn't find artifact " + file );
addFailure( reporter, artifact, "missing-artifact", "The artifact file [" + file + "] cannot be found for metadata." );
}
}

View File

@ -157,16 +157,10 @@ public class LocationArtifactReportProcessorTest
Artifact artifact = createArtifact( "groupId", "artifactId", "1.0-alpha-2" );
Artifact pomArtifact = createArtifact( "groupId", "artifactId", "1.0-alpha-2", "pom" );
try
{
Model model = readPom( repository.pathOf( pomArtifact ) );
artifactReportProcessor.processArtifact( artifact, model, reportDatabase );
fail( "Should not have passed the artifact" );
}
catch ( IllegalStateException e )
{
// correct!
}
Model model = readPom( repository.pathOf( pomArtifact ) );
artifactReportProcessor.processArtifact( artifact, model, reportDatabase );
assertEquals( 1, reportDatabase.getNumFailures() );
}
/**