Author: epunzalan
Date: Tue Jun 13 00:57:20 2006
New Revision: 413827
URL: http://svn.apache.org/viewvc?rev=413827&view=rev
Log:
Added a new class "DiscovererPath" for use to represent paths processed by the
Discoverer. Currently used to fill KickedOutPaths and ExcludedPaths
Added:
maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DiscovererPath.java
(with props)
Modified:
maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/AbstractDiscoverer.java
maven/repository-manager/trunk/maven-repository-discovery/src/test/java/org/apache/maven/repository/discovery/DefaultArtifactDiscovererTest.java
maven/repository-manager/trunk/maven-repository-discovery/src/test/java/org/apache/maven/repository/discovery/DefaultMetadataDiscovererTest.java
maven/repository-manager/trunk/maven-repository-discovery/src/test/java/org/apache/maven/repository/discovery/LegacyArtifactDiscovererTest.java
Modified:
maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/AbstractDiscoverer.java
URL:
http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/AbstractDiscoverer.java?rev=413827&r1=413826&r2=413827&view=diff
==============================================================================
---
maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/AbstractDiscoverer.java
(original)
+++
maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/AbstractDiscoverer.java
Tue Jun 13 00:57:20 2006
@@ -20,14 +20,13 @@
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.
@@ -38,7 +37,7 @@
extends AbstractLogEnabled
implements Discoverer
{
- private Map kickedOutPaths = new HashMap();
+ private List kickedOutPaths = new ArrayList();
/**
* @plexus.requirement
@@ -57,12 +56,12 @@
*/
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();
}
/**
@@ -78,7 +77,7 @@
allExcludes.addAll( Arrays.asList( excludes ) );
}
- if ( blacklistedPatterns != null && blacklistedPatterns.length() > 0 )
+ if ( !StringUtils.isEmpty( blacklistedPatterns ) )
{
allExcludes.addAll( Arrays.asList( blacklistedPatterns.split( ","
) ) );
}
@@ -93,7 +92,12 @@
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();
}
Added:
maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DiscovererPath.java
URL:
http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DiscovererPath.java?rev=413827&view=auto
==============================================================================
---
maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DiscovererPath.java
(added)
+++
maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DiscovererPath.java
Tue Jun 13 00:57:20 2006
@@ -0,0 +1,56 @@
+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;
+ }
+}
Propchange:
maven/repository-manager/trunk/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DiscovererPath.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
maven/repository-manager/trunk/maven-repository-discovery/src/test/java/org/apache/maven/repository/discovery/DefaultArtifactDiscovererTest.java
URL:
http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-discovery/src/test/java/org/apache/maven/repository/discovery/DefaultArtifactDiscovererTest.java?rev=413827&r1=413826&r2=413827&view=diff
==============================================================================
---
maven/repository-manager/trunk/maven-repository-discovery/src/test/java/org/apache/maven/repository/discovery/DefaultArtifactDiscovererTest.java
(original)
+++
maven/repository-manager/trunk/maven-repository-discovery/src/test/java/org/apache/maven/repository/discovery/DefaultArtifactDiscovererTest.java
Tue Jun 13 00:57:20 2006
@@ -71,7 +71,9 @@
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;
}
@@ -91,7 +93,9 @@
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 );
}
@@ -111,7 +115,9 @@
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(
'\\', '/' ) );
}
@@ -127,7 +133,9 @@
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( '\\', '/'
) );
}
@@ -147,7 +155,9 @@
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( '\\', '/' ) );
@@ -169,7 +179,9 @@
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( '\\',
'/' ) );
}
@@ -189,7 +201,9 @@
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( '\\', '/' ) );
}
@@ -209,7 +223,9 @@
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( '\\', '/' ) );
}
@@ -229,7 +245,9 @@
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( '\\', '/' ) );
}
@@ -249,7 +267,9 @@
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( '\\', '/' ) );
Modified:
maven/repository-manager/trunk/maven-repository-discovery/src/test/java/org/apache/maven/repository/discovery/DefaultMetadataDiscovererTest.java
URL:
http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-discovery/src/test/java/org/apache/maven/repository/discovery/DefaultMetadataDiscovererTest.java?rev=413827&r1=413826&r2=413827&view=diff
==============================================================================
---
maven/repository-manager/trunk/maven-repository-discovery/src/test/java/org/apache/maven/repository/discovery/DefaultMetadataDiscovererTest.java
(original)
+++
maven/repository-manager/trunk/maven-repository-discovery/src/test/java/org/apache/maven/repository/discovery/DefaultMetadataDiscovererTest.java
Tue Jun 13 00:57:20 2006
@@ -75,7 +75,9 @@
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 )
)
{
@@ -95,7 +97,9 @@
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 ) )
{
Modified:
maven/repository-manager/trunk/maven-repository-discovery/src/test/java/org/apache/maven/repository/discovery/LegacyArtifactDiscovererTest.java
URL:
http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-discovery/src/test/java/org/apache/maven/repository/discovery/LegacyArtifactDiscovererTest.java?rev=413827&r1=413826&r2=413827&view=diff
==============================================================================
---
maven/repository-manager/trunk/maven-repository-discovery/src/test/java/org/apache/maven/repository/discovery/LegacyArtifactDiscovererTest.java
(original)
+++
maven/repository-manager/trunk/maven-repository-discovery/src/test/java/org/apache/maven/repository/discovery/LegacyArtifactDiscovererTest.java
Tue Jun 13 00:57:20 2006
@@ -69,7 +69,9 @@
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;
}
@@ -89,7 +91,9 @@
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 );
}
@@ -109,7 +113,9 @@
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( '\\',
'/' ) );
}
@@ -125,7 +131,9 @@
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( '\\', '/'
) );
}
@@ -145,7 +153,9 @@
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(
'\\', '/' ) );
}
@@ -165,7 +175,9 @@
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( '\\',
'/' ) );
}
@@ -185,7 +197,9 @@
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( '\\',
'/' ) );
}
@@ -205,7 +219,9 @@
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( '\\',
'/' ) );
}
@@ -225,7 +241,9 @@
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( '\\', '/'
) );
}