return scanForArtifactPaths( repositoryBase, blacklistedPatterns, null, STANDARD_DISCOVERY_EXCLUDES );
}
+ /**
+ * Return a list of artifacts found in a specified repository
+ *
+ * @param repository The ArtifactRepository to discover artifacts
+ * @param blacklistedPatterns Comma-delimited list of string paths that will be excluded in the discovery
+ * @param includeSnapshots if the repository contains snapshots which should also be included
+ * @return list of artifacts
+ */
public List discoverArtifacts( ArtifactRepository repository, String blacklistedPatterns, boolean includeSnapshots )
{
if ( !"file".equals( repository.getProtocol() ) )
{
String path = artifactPaths[i];
- Artifact artifact = null;
+ Artifact artifact;
try
{
artifact = buildArtifactFromPath( path, repository );
return artifacts;
}
+ /**
+ * Returns a list of pom packaging artifacts found in a specified repository
+ *
+ * @param repository The ArtifactRepository to discover artifacts
+ * @param blacklistedPatterns Comma-delimited list of string paths that will be excluded in the discovery
+ * @param includeSnapshots if the repository contains snapshots which should also be included
+ * @return list of pom artifacts
+ */
public List discoverStandalonePoms( ArtifactRepository repository, String blacklistedPatterns,
boolean includeSnapshots )
{
return artifacts;
}
+ /**
+ * Returns an artifact object that is represented by the specified path in a repository
+ *
+ * @param path The path that is pointing to an artifact
+ * @param repository The repository of the artifact
+ * @return Artifact
+ * @throws DiscovererException when the specified path does correspond to an artifact
+ */
public Artifact buildArtifactFromPath( String path, ArtifactRepository repository )
throws DiscovererException
{
kickedOutPaths.add( new DiscovererPath( path, reason ) );
}
+ /**
+ * Returns an iterator for the list if DiscovererPaths that were found to not represent a searched object
+ *
+ * @return Iterator for the DiscovererPath List
+ */
public Iterator getKickedOutPathsIterator()
{
return kickedOutPaths.iterator();
return scanner.getIncludedFiles();
}
+ /**
+ * Returns an iterator for the list if DiscovererPaths that were not processed because they are explicitly excluded
+ *
+ * @return Iterator for the DiscovererPath List
+ */
public Iterator getExcludedPathsIterator()
{
return excludedPaths.iterator();
public class DefaultArtifactDiscoverer
extends AbstractArtifactDiscoverer
{
+ /**
+ * @see org.apache.maven.repository.discovery.ArtifactDiscoverer#buildArtifact(String)
+ */
public Artifact buildArtifact( String path )
throws DiscovererException
{
/**
* Standard patterns to include in discovery of metadata files.
*/
- private static final String[] STANDARD_DISCOVERY_INCLUDES = {"**/*-metadata.xml", "**/*/*-metadata.xml",
- "**/*/*/*-metadata.xml", "**/*-metadata-*.xml", "**/*/*-metadata-*.xml", "**/*/*/*-metadata-*.xml"};
+ private static final String[] STANDARD_DISCOVERY_INCLUDES = {"**/*-metadata.xml",
+ "**/*/*-metadata.xml",
+ "**/*/*/*-metadata.xml",
+ "**/*-metadata-*.xml",
+ "**/*/*-metadata-*.xml",
+ "**/*/*/*-metadata-*.xml"
+ };
/**
- * Search the repository for metadata files.
- *
- * @param repositoryBase
- * @param blacklistedPatterns
+ * @see org.apache.maven.repository.discovery.MetadataDiscoverer#discoverMetadata(java.io.File, String)
*/
public List discoverMetadata( File repositoryBase, String blacklistedPatterns )
{
private RepositoryMetadata buildMetadata( String repo, String metadataPath )
throws DiscovererException
{
- Metadata m = null;
+ Metadata m;
String repoPath = repo + "/" + metadataPath;
try
{
return repositoryMetadata;
}
+ /**
+ * Builds a RepositoryMetadata object from a Metadata object and its path
+ *
+ * @param m Metadata
+ * @param metadataPath path
+ * @return RepositoryMetadata if the parameters represent one; null if not
+ */
private RepositoryMetadata buildMetadata( Metadata m, String metadataPath )
{
String metaGroupId = m.getGroupId();
public class LegacyArtifactDiscoverer
extends AbstractArtifactDiscoverer
{
+ /**
+ * @see org.apache.maven.repository.discovery.ArtifactDiscoverer#buildArtifact(String)
+ */
public Artifact buildArtifact( String path )
throws DiscovererException
{
--- /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.
+ */
+
+import org.codehaus.plexus.PlexusTestCase;
+import org.apache.maven.artifact.factory.ArtifactFactory;
+import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
+import org.apache.maven.artifact.Artifact;
+
+import java.io.File;
+
+/**
+ * @author Edwin Punzalan
+ */
+public abstract class AbstractArtifactDiscovererTest
+ extends PlexusTestCase
+{
+ protected ArtifactDiscoverer discoverer;
+
+ private ArtifactFactory factory;
+
+ protected ArtifactRepository repository;
+
+ protected abstract String getLayout();
+
+ protected abstract File getRepositoryFile();
+
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ discoverer = (ArtifactDiscoverer) lookup( ArtifactDiscoverer.ROLE, getLayout() );
+
+ factory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
+
+ repository = getRepository();
+ }
+
+ protected ArtifactRepository getRepository()
+ throws Exception
+ {
+ File basedir = getRepositoryFile();
+
+ ArtifactRepositoryFactory factory = (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE );
+
+ ArtifactRepositoryLayout layout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, getLayout() );
+
+ return factory.createArtifactRepository( "discoveryRepo", "file://" + basedir, layout, null, null );
+ }
+
+ protected Artifact createArtifact( String groupId, String artifactId, String version )
+ {
+ return factory.createArtifact( groupId, artifactId, version, null, "jar" );
+ }
+
+ protected Artifact createArtifact( String groupId, String artifactId, String version, String type )
+ {
+ return factory.createArtifact( groupId, artifactId, version, null, type );
+ }
+
+ protected Artifact createArtifact( String groupId, String artifactId, String version, String type, String classifier )
+ {
+ return factory.createArtifactWithClassifier( groupId, artifactId, version, type, classifier );
+ }
+}
*/
import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.factory.ArtifactFactory;
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
-import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.apache.maven.model.Model;
-import org.codehaus.plexus.PlexusTestCase;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import java.io.File;
* @todo test location of poms, checksums
*/
public class DefaultArtifactDiscovererTest
- extends PlexusTestCase
+ extends AbstractArtifactDiscovererTest
{
- private ArtifactDiscoverer discoverer;
-
- private ArtifactFactory factory;
-
- private ArtifactRepository repository;
-
- protected void setUp()
- throws Exception
+ protected String getLayout()
{
- super.setUp();
-
- discoverer = (ArtifactDiscoverer) lookup( ArtifactDiscoverer.ROLE, "default" );
-
- factory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
-
- File basedir = getTestFile( "src/test/repository" );
- ArtifactRepositoryFactory factory = (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE );
+ return "default";
+ }
- ArtifactRepositoryLayout layout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "default" );
- repository = factory.createArtifactRepository( "discoveryRepo", "file://" + basedir, layout, null, null );
+ protected File getRepositoryFile()
+ {
+ return getTestFile( "src/test/repository" );
}
public void testDefaultExcludes()
return null;
}
}
-
- private Artifact createArtifact( String groupId, String artifactId, String version )
- {
- return factory.createArtifact( groupId, artifactId, version, null, "jar" );
- }
-
- private Artifact createArtifact( String groupId, String artifactId, String version, String type )
- {
- return factory.createArtifact( groupId, artifactId, version, null, type );
- }
-
- private Artifact createArtifact( String groupId, String artifactId, String version, String type, String classifier )
- {
- return factory.createArtifactWithClassifier( groupId, artifactId, version, type, classifier );
- }
-
}
*/
import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.factory.ArtifactFactory;
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
-import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
-import org.codehaus.plexus.PlexusTestCase;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import java.io.File;
*
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @version $Id$
- * @todo share as much as possible with default via abstract test case
*/
public class LegacyArtifactDiscovererTest
- extends PlexusTestCase
+ extends AbstractArtifactDiscovererTest
{
- private ArtifactDiscoverer discoverer;
-
- private ArtifactFactory factory;
-
- private ArtifactRepository repository;
-
- protected void setUp()
- throws Exception
+ protected String getLayout()
{
- super.setUp();
-
- discoverer = (ArtifactDiscoverer) lookup( ArtifactDiscoverer.ROLE, "legacy" );
-
- factory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
-
- File basedir = getTestFile( "src/test/legacy-repository" );
-
- ArtifactRepositoryFactory factory = (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE );
+ return "legacy";
+ }
- ArtifactRepositoryLayout layout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "legacy" );
- repository = factory.createArtifactRepository( "discoveryRepo", "file://" + basedir, layout, null, null );
+ protected File getRepositoryFile()
+ {
+ return getTestFile( "src/test/legacy-repository" );
}
public void testDefaultExcludes()
return null;
}
}
-
- private Artifact createArtifact( String groupId, String artifactId, String version )
- {
- return factory.createArtifact( groupId, artifactId, version, null, "jar" );
- }
-
- private Artifact createArtifact( String groupId, String artifactId, String version, String type )
- {
- return factory.createArtifact( groupId, artifactId, version, null, type );
- }
-
- private Artifact createArtifact( String groupId, String artifactId, String version, String type, String classifier )
- {
- return factory.createArtifactWithClassifier( groupId, artifactId, version, type, classifier );
- }
-
}