import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.codehaus.plexus.util.DirectoryScanner;
import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.StringUtils;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
-import java.util.Map;
-import java.util.HashMap;
/**
* Base class for the artifact and metadata discoverers.
extends AbstractLogEnabled
implements Discoverer
{
- private Map kickedOutPaths = new HashMap();
+ private List kickedOutPaths = new ArrayList();
/**
* @plexus.requirement
*/
protected void addKickedOutPath( String path, String reason )
{
- kickedOutPaths.put( path, reason );
+ kickedOutPaths.add( new DiscovererPath( path, reason ) );
}
public Iterator getKickedOutPathsIterator()
{
- return kickedOutPaths.keySet().iterator();
+ return kickedOutPaths.iterator();
}
/**
allExcludes.addAll( Arrays.asList( excludes ) );
}
- if ( blacklistedPatterns != null && blacklistedPatterns.length() > 0 )
+ if ( !StringUtils.isEmpty( blacklistedPatterns ) )
{
allExcludes.addAll( Arrays.asList( blacklistedPatterns.split( "," ) ) );
}
scanner.scan();
- excludedPaths.addAll( Arrays.asList( scanner.getExcludedFiles() ) );
+ for ( Iterator files = Arrays.asList( scanner.getExcludedFiles() ).iterator(); files.hasNext(); )
+ {
+ String path = files.next().toString();
+
+ excludedPaths.add( new DiscovererPath( path, "Excluded by DirectoryScanner" ) );
+ }
return scanner.getIncludedFiles();
}
--- /dev/null
+package org.apache.maven.repository.discovery;
+
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Edwin Punzalan
+ */
+public class DiscovererPath
+{
+ private String path;
+ private String comment;
+
+ public DiscovererPath()
+ {
+ }
+
+ public DiscovererPath( String path, String comment )
+ {
+ setPath( path );
+ setComment( comment );
+ }
+
+ public String getPath()
+ {
+ return path;
+ }
+
+ public void setPath( String path )
+ {
+ this.path = path;
+ }
+
+ public String getComment()
+ {
+ return comment;
+ }
+
+ public void setComment( String comment )
+ {
+ this.comment = comment;
+ }
+}
boolean found = false;
for ( Iterator i = discoverer.getExcludedPathsIterator(); i.hasNext() && !found; )
{
- String path = (String) i.next();
+ DiscovererPath dPath = (DiscovererPath) i.next();
+
+ String path = dPath.getPath();
found = path.indexOf( ".svn" ) >= 0;
}
boolean found = false;
for ( Iterator i = discoverer.getExcludedPathsIterator(); i.hasNext() && !found; )
{
- String path = (String) i.next();
+ DiscovererPath dPath = (DiscovererPath) i.next();
+
+ String path = dPath.getPath();
found = "KEYS".equals( path );
}
boolean found = false;
for ( Iterator i = discoverer.getExcludedPathsIterator(); i.hasNext() && !found; )
{
- String path = (String) i.next();
+ DiscovererPath dPath = (DiscovererPath) i.next();
+
+ String path = dPath.getPath();
found = "javax/sql/jdbc/2.0/jdbc-2.0.jar".equals( path.replace( '\\', '/' ) );
}
boolean found = false;
for ( Iterator i = discoverer.getKickedOutPathsIterator(); i.hasNext() && !found; )
{
- String path = (String) i.next();
+ DiscovererPath dPath = (DiscovererPath) i.next();
+
+ String path = dPath.getPath();
found = "invalid/invalid-1.0.jar".equals( path.replace( '\\', '/' ) );
}
boolean found = false;
for ( Iterator i = discoverer.getKickedOutPathsIterator(); i.hasNext() && !found; )
{
- String path = (String) i.next();
+ DiscovererPath dPath = (DiscovererPath) i.next();
+
+ String path = dPath.getPath();
found = "org/apache/maven/test/1.0-SNAPSHOT/wrong-artifactId-1.0-20050611.112233-1.jar".equals(
path.replace( '\\', '/' ) );
boolean found = false;
for ( Iterator i = discoverer.getKickedOutPathsIterator(); i.hasNext() && !found; )
{
- String path = (String) i.next();
+ DiscovererPath dPath = (DiscovererPath) i.next();
+
+ String path = dPath.getPath();
found = "invalid/invalid/1/invalid-1".equals( path.replace( '\\', '/' ) );
}
boolean found = false;
for ( Iterator i = discoverer.getKickedOutPathsIterator(); i.hasNext() && !found; )
{
- String path = (String) i.next();
+ DiscovererPath dPath = (DiscovererPath) i.next();
+
+ String path = dPath.getPath();
found = "invalid/invalid/1.0/invalid-2.0.jar".equals( path.replace( '\\', '/' ) );
}
boolean found = false;
for ( Iterator i = discoverer.getKickedOutPathsIterator(); i.hasNext() && !found; )
{
- String path = (String) i.next();
+ DiscovererPath dPath = (DiscovererPath) i.next();
+
+ String path = dPath.getPath();
found = "invalid/invalid/1.0/invalid-1.0b.jar".equals( path.replace( '\\', '/' ) );
}
boolean found = false;
for ( Iterator i = discoverer.getKickedOutPathsIterator(); i.hasNext() && !found; )
{
- String path = (String) i.next();
+ DiscovererPath dPath = (DiscovererPath) i.next();
+
+ String path = dPath.getPath();
found = "invalid/invalid/1.0-SNAPSHOT/invalid-1.0.jar".equals( path.replace( '\\', '/' ) );
}
boolean found = false;
for ( Iterator i = discoverer.getKickedOutPathsIterator(); i.hasNext() && !found; )
{
- String path = (String) i.next();
+ DiscovererPath dPath = (DiscovererPath) i.next();
+
+ String path = dPath.getPath();
found = "invalid/invalid/1.0-20050611.123456-1/invalid-1.0-20050611.123456-1.jar".equals(
path.replace( '\\', '/' ) );
boolean found = false;
while ( iter.hasNext() && !found )
{
- String dir = (String) iter.next();
+ DiscovererPath dPath = (DiscovererPath) iter.next();
+ String dir = dPath.getPath();
+
String normalizedDir = dir.replace( '\\', '/' );
if ( "javax/maven-metadata-repository.xml".equals( normalizedDir ) )
{
boolean found = false;
while ( iter.hasNext() && !found )
{
- String dir = (String) iter.next();
+ DiscovererPath dPath = (DiscovererPath) iter.next();
+ String dir = dPath.getPath();
+
String normalizedDir = dir.replace( '\\', '/' );
if ( "org/apache/maven/some-ejb/1.0/maven-metadata-repository.xml".equals( normalizedDir ) )
{
boolean found = false;
for ( Iterator i = discoverer.getExcludedPathsIterator(); i.hasNext() && !found; )
{
- String path = (String) i.next();
+ DiscovererPath dPath = (DiscovererPath) i.next();
+
+ String path = dPath.getPath();
found = path.indexOf( ".svn" ) >= 0;
}
boolean found = false;
for ( Iterator i = discoverer.getExcludedPathsIterator(); i.hasNext() && !found; )
{
- String path = (String) i.next();
+ DiscovererPath dPath = (DiscovererPath) i.next();
+
+ String path = dPath.getPath();
found = "KEYS".equals( path );
}
boolean found = false;
for ( Iterator i = discoverer.getExcludedPathsIterator(); i.hasNext() && !found; )
{
- String path = (String) i.next();
+ DiscovererPath dPath = (DiscovererPath) i.next();
+
+ String path = dPath.getPath();
found = "javax.sql/jars/jdbc-2.0.jar".equals( path.replace( '\\', '/' ) );
}
boolean found = false;
for ( Iterator i = discoverer.getKickedOutPathsIterator(); i.hasNext() && !found; )
{
- String path = (String) i.next();
+ DiscovererPath dPath = (DiscovererPath) i.next();
+
+ String path = dPath.getPath();
found = "invalid/invalid-1.0.jar".equals( path.replace( '\\', '/' ) );
}
boolean found = false;
for ( Iterator i = discoverer.getKickedOutPathsIterator(); i.hasNext() && !found; )
{
- String path = (String) i.next();
+ DiscovererPath dPath = (DiscovererPath) i.next();
+
+ String path = dPath.getPath();
found = "invalid/jars/1.0/invalid-1.0.jar".equals( path.replace( '\\', '/' ) );
}
boolean found = false;
for ( Iterator i = discoverer.getKickedOutPathsIterator(); i.hasNext() && !found; )
{
- String path = (String) i.next();
+ DiscovererPath dPath = (DiscovererPath) i.next();
+
+ String path = dPath.getPath();
found = "invalid/foo/invalid-1.0.foo".equals( path.replace( '\\', '/' ) );
}
boolean found = false;
for ( Iterator i = discoverer.getKickedOutPathsIterator(); i.hasNext() && !found; )
{
- String path = (String) i.next();
+ DiscovererPath dPath = (DiscovererPath) i.next();
+
+ String path = dPath.getPath();
found = "invalid/jars/no-extension".equals( path.replace( '\\', '/' ) );
}
boolean found = false;
for ( Iterator i = discoverer.getKickedOutPathsIterator(); i.hasNext() && !found; )
{
- String path = (String) i.next();
+ DiscovererPath dPath = (DiscovererPath) i.next();
+
+ String path = dPath.getPath();
found = "invalid/jars/invalid-1.0.rar".equals( path.replace( '\\', '/' ) );
}
boolean found = false;
for ( Iterator i = discoverer.getKickedOutPathsIterator(); i.hasNext() && !found; )
{
- String path = (String) i.next();
+ DiscovererPath dPath = (DiscovererPath) i.next();
+
+ String path = dPath.getPath();
found = "invalid/jars/invalid.jar".equals( path.replace( '\\', '/' ) );
}