avoid failure when there is a bad path in the repository

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@290364 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-09-20 05:43:03 +00:00
parent 27aa17cb32
commit 2b44ccee57
3 changed files with 16 additions and 9 deletions

View File

@ -17,6 +17,7 @@ package org.apache.maven.tools.repoclean.discover;
*/
import org.apache.maven.tools.repoclean.report.PathLister;
import org.apache.maven.tools.repoclean.report.ReportWriteException;
import org.apache.maven.tools.repoclean.report.Reporter;
import java.io.File;
@ -35,6 +36,6 @@ public interface ArtifactDiscoverer
List discoverArtifacts( File repositoryBase, Reporter reporter, String blacklistedPatterns,
PathLister excludeLister, PathLister kickoutLister, boolean includeSnapshots )
throws Exception;
throws ReportWriteException;
}

View File

@ -19,6 +19,7 @@ package org.apache.maven.tools.repoclean.discover;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.tools.repoclean.report.PathLister;
import org.apache.maven.tools.repoclean.report.ReportWriteException;
import org.apache.maven.tools.repoclean.report.Reporter;
import java.io.File;
@ -39,7 +40,7 @@ public class DefaultArtifactDiscoverer
public List discoverArtifacts( File repositoryBase, Reporter reporter, String blacklistedPatterns,
PathLister excludeLister, PathLister kickoutLister, boolean convertSnapshots )
throws Exception
throws ReportWriteException
{
List artifacts = new ArrayList();
@ -49,7 +50,7 @@ public class DefaultArtifactDiscoverer
{
String path = artifactPaths[i];
Artifact artifact = buildArtifact( path );
Artifact artifact = buildArtifact( path, reporter );
if ( artifact != null )
{
@ -63,8 +64,8 @@ public class DefaultArtifactDiscoverer
return artifacts;
}
private Artifact buildArtifact( String path )
throws Exception
private Artifact buildArtifact( String path, Reporter reporter )
throws ReportWriteException
{
Artifact result;
@ -77,7 +78,11 @@ public class DefaultArtifactDiscoverer
Collections.reverse( pathParts );
int currentPart = 0;
if ( pathParts.size() < 4 )
{
reporter.error( "Not enough parts (4) in path " + path );
return null;
}
//discard the actual artifact filename.
pathParts.remove( 0 );

View File

@ -19,6 +19,7 @@ package org.apache.maven.tools.repoclean.phase;
import org.apache.maven.tools.repoclean.RepositoryCleanerConfiguration;
import org.apache.maven.tools.repoclean.discover.ArtifactDiscoverer;
import org.apache.maven.tools.repoclean.report.PathLister;
import org.apache.maven.tools.repoclean.report.ReportWriteException;
import org.apache.maven.tools.repoclean.report.Reporter;
import org.codehaus.plexus.PlexusConstants;
import org.codehaus.plexus.PlexusContainer;
@ -54,8 +55,8 @@ public class DiscoveryPhase
try
{
artifactDiscoverer = (ArtifactDiscoverer) container.lookup( ArtifactDiscoverer.ROLE, configuration
.getSourceRepositoryLayout() );
artifactDiscoverer = (ArtifactDiscoverer) container.lookup( ArtifactDiscoverer.ROLE,
configuration.getSourceRepositoryLayout() );
if ( logger.isDebugEnabled() )
{
@ -74,7 +75,7 @@ public class DiscoveryPhase
configuration.getBlacklistedPatterns(), excludeLister,
kickoutLister, configuration.isConvertSnapshots() );
}
catch ( Exception e )
catch ( ReportWriteException e )
{
repoReporter.error( "Error discovering artifacts in source repository.", e );