diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/discover/ArtifactDiscoverer.java b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/discover/ArtifactDiscoverer.java index 2981bfaa82..c3cc6ea2f0 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/discover/ArtifactDiscoverer.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/discover/ArtifactDiscoverer.java @@ -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; } \ No newline at end of file diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/discover/DefaultArtifactDiscoverer.java b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/discover/DefaultArtifactDiscoverer.java index b130d58b35..f161a8b656 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/discover/DefaultArtifactDiscoverer.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/discover/DefaultArtifactDiscoverer.java @@ -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 ); diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/phase/DiscoveryPhase.java b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/phase/DiscoveryPhase.java index dfb2101819..2716bc29e9 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/phase/DiscoveryPhase.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/phase/DiscoveryPhase.java @@ -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 );