mirror of
https://github.com/apache/archiva.git
synced 2025-02-22 10:17:25 +00:00
set repository on discovery of artifacts
git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@369128 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ed95fbe763
commit
881f7b7017
@ -16,7 +16,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
@ -33,7 +34,7 @@ public interface ArtifactDiscoverer
|
||||
/**
|
||||
* Discover artifacts in the repository.
|
||||
*
|
||||
* @param repositoryBase the base directory of the repository on the local filesystem
|
||||
* @param repository the location of the repository
|
||||
* @param blacklistedPatterns pattern that lists any files to prevent from being included when scanning
|
||||
* @param includeSnapshots whether to discover snapshots
|
||||
* @return the list of artifacts discovered
|
||||
@ -42,7 +43,7 @@ public interface ArtifactDiscoverer
|
||||
* @todo should includeSnapshots be configuration on the component?
|
||||
* @todo instead of a returned list, should a listener be passed in?
|
||||
*/
|
||||
List discoverArtifacts( File repositoryBase, String blacklistedPatterns, boolean includeSnapshots );
|
||||
List discoverArtifacts( ArtifactRepository repository, String blacklistedPatterns, boolean includeSnapshots );
|
||||
|
||||
/**
|
||||
* Get the list of paths kicked out during the discovery process.
|
||||
|
@ -18,6 +18,8 @@
|
||||
|
||||
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.codehaus.plexus.util.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
@ -42,8 +44,15 @@ public class DefaultArtifactDiscoverer
|
||||
*/
|
||||
private ArtifactFactory artifactFactory;
|
||||
|
||||
public List discoverArtifacts( File repositoryBase, String blacklistedPatterns, boolean includeSnapshots )
|
||||
public List discoverArtifacts( ArtifactRepository repository, String blacklistedPatterns, boolean includeSnapshots )
|
||||
{
|
||||
if ( !"file".equals( repository.getProtocol() ) )
|
||||
{
|
||||
throw new UnsupportedOperationException( "Only filesystem repositories are supported" );
|
||||
}
|
||||
|
||||
File repositoryBase = new File( repository.getBasedir() );
|
||||
|
||||
List artifacts = new ArrayList();
|
||||
|
||||
String[] artifactPaths = scanForArtifactPaths( repositoryBase, blacklistedPatterns );
|
||||
@ -52,7 +61,7 @@ public List discoverArtifacts( File repositoryBase, String blacklistedPatterns,
|
||||
{
|
||||
String path = artifactPaths[i];
|
||||
|
||||
Artifact artifact = buildArtifact( repositoryBase, path );
|
||||
Artifact artifact = buildArtifact( repositoryBase, path, repository );
|
||||
|
||||
if ( artifact != null )
|
||||
{
|
||||
@ -66,7 +75,7 @@ public List discoverArtifacts( File repositoryBase, String blacklistedPatterns,
|
||||
return artifacts;
|
||||
}
|
||||
|
||||
private Artifact buildArtifact( File repositoryBase, String path )
|
||||
private Artifact buildArtifact( File repositoryBase, String path, ArtifactRepository repository )
|
||||
{
|
||||
List pathParts = new ArrayList();
|
||||
StringTokenizer st = new StringTokenizer( path, "/\\" );
|
||||
@ -216,6 +225,7 @@ else if ( !remainingFilename.equals( version ) )
|
||||
|
||||
if ( finalResult != null )
|
||||
{
|
||||
finalResult.setRepository( repository );
|
||||
finalResult.setFile( new File( repositoryBase, path ) );
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
*/
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.factory.ArtifactFactory;
|
||||
|
||||
import java.io.File;
|
||||
@ -43,17 +44,18 @@ public class LegacyArtifactDiscoverer
|
||||
*/
|
||||
private ArtifactFactory artifactFactory;
|
||||
|
||||
public List discoverArtifacts( File repositoryBase, String blacklistedPatterns, boolean includeSnapshots )
|
||||
public List discoverArtifacts( ArtifactRepository repository, String blacklistedPatterns, boolean includeSnapshots )
|
||||
{
|
||||
List artifacts = new ArrayList();
|
||||
|
||||
File repositoryBase = new File( repository.getBasedir() );
|
||||
String[] artifactPaths = scanForArtifactPaths( repositoryBase, blacklistedPatterns );
|
||||
|
||||
for ( int i = 0; i < artifactPaths.length; i++ )
|
||||
{
|
||||
String path = artifactPaths[i];
|
||||
|
||||
Artifact artifact = buildArtifact( repositoryBase, path );
|
||||
Artifact artifact = buildArtifact( repositoryBase, path, repository );
|
||||
if ( artifact != null )
|
||||
{
|
||||
if ( includeSnapshots || !artifact.isSnapshot() )
|
||||
@ -69,7 +71,7 @@ public List discoverArtifacts( File repositoryBase, String blacklistedPatterns,
|
||||
/**
|
||||
* @noinspection CollectionDeclaredAsConcreteClass
|
||||
*/
|
||||
private Artifact buildArtifact( File repositoryBase, String path )
|
||||
private Artifact buildArtifact( File repositoryBase, String path, ArtifactRepository repository )
|
||||
{
|
||||
StringTokenizer tokens = new StringTokenizer( path, "/\\" );
|
||||
|
||||
@ -326,6 +328,7 @@ else if ( lastAvceToken.endsWith( ".zip" ) )
|
||||
Artifact.SCOPE_RUNTIME, type );
|
||||
}
|
||||
|
||||
result.setRepository( repository );
|
||||
result.setFile( new File( repositoryBase, path ) );
|
||||
}
|
||||
}
|
||||
|
@ -18,9 +18,13 @@
|
||||
|
||||
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 java.io.File;
|
||||
import java.net.MalformedURLException;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
@ -38,7 +42,7 @@ public class DefaultArtifactDiscovererTest
|
||||
|
||||
private ArtifactFactory factory;
|
||||
|
||||
private File repositoryLocation;
|
||||
private ArtifactRepository repository;
|
||||
|
||||
protected void setUp()
|
||||
throws Exception
|
||||
@ -49,12 +53,17 @@ protected void setUp()
|
||||
|
||||
factory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
|
||||
|
||||
repositoryLocation = getTestFile( "src/test/repository" );
|
||||
File basedir = getTestFile( "src/test/repository" );
|
||||
|
||||
ArtifactRepositoryFactory factory = (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE );
|
||||
|
||||
ArtifactRepositoryLayout layout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "default" );
|
||||
repository = factory.createArtifactRepository( "discoveryRepo", "file://" + basedir, layout, null, null );
|
||||
}
|
||||
|
||||
public void testDefaultExcludes()
|
||||
{
|
||||
List artifacts = discoverer.discoverArtifacts( repositoryLocation, null, false );
|
||||
List artifacts = discoverer.discoverArtifacts( repository, null, false );
|
||||
assertNotNull( "Check artifacts not null", artifacts );
|
||||
boolean found = false;
|
||||
for ( Iterator i = discoverer.getExcludedPathsIterator(); i.hasNext() && !found; )
|
||||
@ -74,7 +83,7 @@ public void testDefaultExcludes()
|
||||
|
||||
public void testStandardExcludes()
|
||||
{
|
||||
List artifacts = discoverer.discoverArtifacts( repositoryLocation, null, false );
|
||||
List artifacts = discoverer.discoverArtifacts( repository, null, false );
|
||||
assertNotNull( "Check artifacts not null", artifacts );
|
||||
boolean found = false;
|
||||
for ( Iterator i = discoverer.getExcludedPathsIterator(); i.hasNext() && !found; )
|
||||
@ -94,7 +103,7 @@ public void testStandardExcludes()
|
||||
|
||||
public void testBlacklistedExclude()
|
||||
{
|
||||
List artifacts = discoverer.discoverArtifacts( repositoryLocation, "javax/**", false );
|
||||
List artifacts = discoverer.discoverArtifacts( repository, "javax/**", false );
|
||||
assertNotNull( "Check artifacts not null", artifacts );
|
||||
boolean found = false;
|
||||
for ( Iterator i = discoverer.getExcludedPathsIterator(); i.hasNext() && !found; )
|
||||
@ -110,7 +119,7 @@ public void testBlacklistedExclude()
|
||||
|
||||
public void testKickoutWithShortPath()
|
||||
{
|
||||
List artifacts = discoverer.discoverArtifacts( repositoryLocation, null, false );
|
||||
List artifacts = discoverer.discoverArtifacts( repository, null, false );
|
||||
assertNotNull( "Check artifacts not null", artifacts );
|
||||
boolean found = false;
|
||||
for ( Iterator i = discoverer.getKickedOutPathsIterator(); i.hasNext() && !found; )
|
||||
@ -130,7 +139,7 @@ public void testKickoutWithShortPath()
|
||||
|
||||
public void testKickoutWithWrongArtifactId()
|
||||
{
|
||||
List artifacts = discoverer.discoverArtifacts( repositoryLocation, null, false );
|
||||
List artifacts = discoverer.discoverArtifacts( repository, null, false );
|
||||
assertNotNull( "Check artifacts not null", artifacts );
|
||||
boolean found = false;
|
||||
for ( Iterator i = discoverer.getKickedOutPathsIterator(); i.hasNext() && !found; )
|
||||
@ -152,7 +161,7 @@ public void testKickoutWithWrongArtifactId()
|
||||
|
||||
public void testKickoutWithNoType()
|
||||
{
|
||||
List artifacts = discoverer.discoverArtifacts( repositoryLocation, null, false );
|
||||
List artifacts = discoverer.discoverArtifacts( repository, null, false );
|
||||
assertNotNull( "Check artifacts not null", artifacts );
|
||||
boolean found = false;
|
||||
for ( Iterator i = discoverer.getKickedOutPathsIterator(); i.hasNext() && !found; )
|
||||
@ -172,7 +181,7 @@ public void testKickoutWithNoType()
|
||||
|
||||
public void testKickoutWithWrongVersion()
|
||||
{
|
||||
List artifacts = discoverer.discoverArtifacts( repositoryLocation, null, false );
|
||||
List artifacts = discoverer.discoverArtifacts( repository, null, false );
|
||||
assertNotNull( "Check artifacts not null", artifacts );
|
||||
boolean found = false;
|
||||
for ( Iterator i = discoverer.getKickedOutPathsIterator(); i.hasNext() && !found; )
|
||||
@ -192,7 +201,7 @@ public void testKickoutWithWrongVersion()
|
||||
|
||||
public void testKickoutWithLongerVersion()
|
||||
{
|
||||
List artifacts = discoverer.discoverArtifacts( repositoryLocation, null, false );
|
||||
List artifacts = discoverer.discoverArtifacts( repository, null, false );
|
||||
assertNotNull( "Check artifacts not null", artifacts );
|
||||
boolean found = false;
|
||||
for ( Iterator i = discoverer.getKickedOutPathsIterator(); i.hasNext() && !found; )
|
||||
@ -212,7 +221,7 @@ public void testKickoutWithLongerVersion()
|
||||
|
||||
public void testKickoutWithWrongSnapshotVersion()
|
||||
{
|
||||
List artifacts = discoverer.discoverArtifacts( repositoryLocation, null, false );
|
||||
List artifacts = discoverer.discoverArtifacts( repository, null, false );
|
||||
assertNotNull( "Check artifacts not null", artifacts );
|
||||
boolean found = false;
|
||||
for ( Iterator i = discoverer.getKickedOutPathsIterator(); i.hasNext() && !found; )
|
||||
@ -232,7 +241,7 @@ public void testKickoutWithWrongSnapshotVersion()
|
||||
|
||||
public void testKickoutWithSnapshotBaseVersion()
|
||||
{
|
||||
List artifacts = discoverer.discoverArtifacts( repositoryLocation, null, false );
|
||||
List artifacts = discoverer.discoverArtifacts( repository, null, false );
|
||||
assertNotNull( "Check artifacts not null", artifacts );
|
||||
boolean found = false;
|
||||
for ( Iterator i = discoverer.getKickedOutPathsIterator(); i.hasNext() && !found; )
|
||||
@ -254,7 +263,7 @@ public void testKickoutWithSnapshotBaseVersion()
|
||||
|
||||
public void testInclusion()
|
||||
{
|
||||
List artifacts = discoverer.discoverArtifacts( repositoryLocation, null, true );
|
||||
List artifacts = discoverer.discoverArtifacts( repository, null, true );
|
||||
assertNotNull( "Check artifacts not null", artifacts );
|
||||
|
||||
assertTrue( "Check normal included",
|
||||
@ -263,7 +272,7 @@ public void testInclusion()
|
||||
|
||||
public void testArtifactWithClassifier()
|
||||
{
|
||||
List artifacts = discoverer.discoverArtifacts( repositoryLocation, null, true );
|
||||
List artifacts = discoverer.discoverArtifacts( repository, null, true );
|
||||
assertNotNull( "Check artifacts not null", artifacts );
|
||||
|
||||
assertTrue( "Check normal included",
|
||||
@ -272,7 +281,7 @@ public void testArtifactWithClassifier()
|
||||
|
||||
public void testJavaSourcesInclusion()
|
||||
{
|
||||
List artifacts = discoverer.discoverArtifacts( repositoryLocation, null, true );
|
||||
List artifacts = discoverer.discoverArtifacts( repository, null, true );
|
||||
assertNotNull( "Check artifacts not null", artifacts );
|
||||
|
||||
assertTrue( "Check normal included", artifacts.contains(
|
||||
@ -281,7 +290,7 @@ public void testJavaSourcesInclusion()
|
||||
|
||||
public void testDistributionInclusion()
|
||||
{
|
||||
List artifacts = discoverer.discoverArtifacts( repositoryLocation, null, true );
|
||||
List artifacts = discoverer.discoverArtifacts( repository, null, true );
|
||||
assertNotNull( "Check artifacts not null", artifacts );
|
||||
|
||||
assertTrue( "Check zip included",
|
||||
@ -293,7 +302,7 @@ public void testDistributionInclusion()
|
||||
|
||||
public void testSnapshotInclusion()
|
||||
{
|
||||
List artifacts = discoverer.discoverArtifacts( repositoryLocation, null, true );
|
||||
List artifacts = discoverer.discoverArtifacts( repository, null, true );
|
||||
assertNotNull( "Check artifacts not null", artifacts );
|
||||
|
||||
assertTrue( "Check normal included", artifacts.contains( createArtifact( "javax.sql", "jdbc", "2.0" ) ) );
|
||||
@ -303,7 +312,7 @@ public void testSnapshotInclusion()
|
||||
|
||||
public void testSnapshotInclusionWithClassifier()
|
||||
{
|
||||
List artifacts = discoverer.discoverArtifacts( repositoryLocation, null, true );
|
||||
List artifacts = discoverer.discoverArtifacts( repository, null, true );
|
||||
assertNotNull( "Check artifacts not null", artifacts );
|
||||
|
||||
assertTrue( "Check snapshot included", artifacts.contains(
|
||||
@ -312,7 +321,7 @@ public void testSnapshotInclusionWithClassifier()
|
||||
|
||||
public void testSnapshotExclusion()
|
||||
{
|
||||
List artifacts = discoverer.discoverArtifacts( repositoryLocation, null, false );
|
||||
List artifacts = discoverer.discoverArtifacts( repository, null, false );
|
||||
assertNotNull( "Check artifacts not null", artifacts );
|
||||
|
||||
assertTrue( "Check normal included", artifacts.contains( createArtifact( "javax.sql", "jdbc", "2.0" ) ) );
|
||||
@ -320,6 +329,33 @@ public void testSnapshotExclusion()
|
||||
artifacts.contains( createArtifact( "org.apache.maven", "test", "1.0-SNAPSHOT" ) ) );
|
||||
}
|
||||
|
||||
public void testFileSet()
|
||||
{
|
||||
List artifacts = discoverer.discoverArtifacts( repository, null, true );
|
||||
assertNotNull( "Check artifacts not null", artifacts );
|
||||
|
||||
for ( Iterator i = artifacts.iterator(); i.hasNext(); )
|
||||
{
|
||||
Artifact artifact = (Artifact) i.next();
|
||||
assertNotNull( "Check file is set", artifact.getFile() );
|
||||
}
|
||||
}
|
||||
|
||||
public void testRepositorySet()
|
||||
throws MalformedURLException
|
||||
{
|
||||
List artifacts = discoverer.discoverArtifacts( repository, null, true );
|
||||
assertNotNull( "Check artifacts not null", artifacts );
|
||||
|
||||
String url = repository.getUrl();
|
||||
for ( Iterator i = artifacts.iterator(); i.hasNext(); )
|
||||
{
|
||||
Artifact artifact = (Artifact) i.next();
|
||||
assertNotNull( "Check repository set", artifact.getRepository() );
|
||||
assertEquals( "Check repository url is correct", url, artifact.getRepository().getUrl() );
|
||||
}
|
||||
}
|
||||
|
||||
private Artifact createArtifact( String groupId, String artifactId, String version )
|
||||
{
|
||||
return factory.createArtifact( groupId, artifactId, version, null, "jar" );
|
||||
|
@ -17,12 +17,16 @@
|
||||
*/
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
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.artifact.factory.ArtifactFactory;
|
||||
import org.codehaus.plexus.PlexusTestCase;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.net.MalformedURLException;
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* Test the legacy artifact discoverer.
|
||||
@ -38,7 +42,7 @@ public class LegacyArtifactDiscovererTest
|
||||
|
||||
private ArtifactFactory factory;
|
||||
|
||||
private File repositoryLocation;
|
||||
private ArtifactRepository repository;
|
||||
|
||||
protected void setUp()
|
||||
throws Exception
|
||||
@ -49,12 +53,17 @@ protected void setUp()
|
||||
|
||||
factory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
|
||||
|
||||
repositoryLocation = getTestFile( "src/test/legacy-repository" );
|
||||
File basedir = getTestFile( "src/test/legacy-repository" );
|
||||
|
||||
ArtifactRepositoryFactory factory = (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE );
|
||||
|
||||
ArtifactRepositoryLayout layout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "legacy" );
|
||||
repository = factory.createArtifactRepository( "discoveryRepo", "file://" + basedir, layout, null, null );
|
||||
}
|
||||
|
||||
public void testDefaultExcludes()
|
||||
{
|
||||
List artifacts = discoverer.discoverArtifacts( repositoryLocation, null, false );
|
||||
List artifacts = discoverer.discoverArtifacts( repository, null, false );
|
||||
assertNotNull( "Check artifacts not null", artifacts );
|
||||
boolean found = false;
|
||||
for ( Iterator i = discoverer.getExcludedPathsIterator(); i.hasNext() && !found; )
|
||||
@ -74,7 +83,7 @@ public void testDefaultExcludes()
|
||||
|
||||
public void testStandardExcludes()
|
||||
{
|
||||
List artifacts = discoverer.discoverArtifacts( repositoryLocation, null, false );
|
||||
List artifacts = discoverer.discoverArtifacts( repository, null, false );
|
||||
assertNotNull( "Check artifacts not null", artifacts );
|
||||
boolean found = false;
|
||||
for ( Iterator i = discoverer.getExcludedPathsIterator(); i.hasNext() && !found; )
|
||||
@ -94,7 +103,7 @@ public void testStandardExcludes()
|
||||
|
||||
public void testBlacklistedExclude()
|
||||
{
|
||||
List artifacts = discoverer.discoverArtifacts( repositoryLocation, "javax.sql/**", false );
|
||||
List artifacts = discoverer.discoverArtifacts( repository, "javax.sql/**", false );
|
||||
assertNotNull( "Check artifacts not null", artifacts );
|
||||
boolean found = false;
|
||||
for ( Iterator i = discoverer.getExcludedPathsIterator(); i.hasNext() && !found; )
|
||||
@ -110,7 +119,7 @@ public void testBlacklistedExclude()
|
||||
|
||||
public void testKickoutWithShortPath()
|
||||
{
|
||||
List artifacts = discoverer.discoverArtifacts( repositoryLocation, null, false );
|
||||
List artifacts = discoverer.discoverArtifacts( repository, null, false );
|
||||
assertNotNull( "Check artifacts not null", artifacts );
|
||||
boolean found = false;
|
||||
for ( Iterator i = discoverer.getKickedOutPathsIterator(); i.hasNext() && !found; )
|
||||
@ -130,7 +139,7 @@ public void testKickoutWithShortPath()
|
||||
|
||||
public void testKickoutWithLongPath()
|
||||
{
|
||||
List artifacts = discoverer.discoverArtifacts( repositoryLocation, null, false );
|
||||
List artifacts = discoverer.discoverArtifacts( repository, null, false );
|
||||
assertNotNull( "Check artifacts not null", artifacts );
|
||||
boolean found = false;
|
||||
for ( Iterator i = discoverer.getKickedOutPathsIterator(); i.hasNext() && !found; )
|
||||
@ -150,7 +159,7 @@ public void testKickoutWithLongPath()
|
||||
|
||||
public void testKickoutWithInvalidType()
|
||||
{
|
||||
List artifacts = discoverer.discoverArtifacts( repositoryLocation, null, false );
|
||||
List artifacts = discoverer.discoverArtifacts( repository, null, false );
|
||||
assertNotNull( "Check artifacts not null", artifacts );
|
||||
boolean found = false;
|
||||
for ( Iterator i = discoverer.getKickedOutPathsIterator(); i.hasNext() && !found; )
|
||||
@ -170,7 +179,7 @@ public void testKickoutWithInvalidType()
|
||||
|
||||
public void testKickoutWithNoExtension()
|
||||
{
|
||||
List artifacts = discoverer.discoverArtifacts( repositoryLocation, null, false );
|
||||
List artifacts = discoverer.discoverArtifacts( repository, null, false );
|
||||
assertNotNull( "Check artifacts not null", artifacts );
|
||||
boolean found = false;
|
||||
for ( Iterator i = discoverer.getKickedOutPathsIterator(); i.hasNext() && !found; )
|
||||
@ -190,7 +199,7 @@ public void testKickoutWithNoExtension()
|
||||
|
||||
public void testKickoutWithWrongExtension()
|
||||
{
|
||||
List artifacts = discoverer.discoverArtifacts( repositoryLocation, null, false );
|
||||
List artifacts = discoverer.discoverArtifacts( repository, null, false );
|
||||
assertNotNull( "Check artifacts not null", artifacts );
|
||||
boolean found = false;
|
||||
for ( Iterator i = discoverer.getKickedOutPathsIterator(); i.hasNext() && !found; )
|
||||
@ -210,7 +219,7 @@ public void testKickoutWithWrongExtension()
|
||||
|
||||
public void testKickoutWithNoVersion()
|
||||
{
|
||||
List artifacts = discoverer.discoverArtifacts( repositoryLocation, null, false );
|
||||
List artifacts = discoverer.discoverArtifacts( repository, null, false );
|
||||
assertNotNull( "Check artifacts not null", artifacts );
|
||||
boolean found = false;
|
||||
for ( Iterator i = discoverer.getKickedOutPathsIterator(); i.hasNext() && !found; )
|
||||
@ -230,7 +239,7 @@ public void testKickoutWithNoVersion()
|
||||
|
||||
public void testInclusion()
|
||||
{
|
||||
List artifacts = discoverer.discoverArtifacts( repositoryLocation, null, true );
|
||||
List artifacts = discoverer.discoverArtifacts( repository, null, true );
|
||||
assertNotNull( "Check artifacts not null", artifacts );
|
||||
|
||||
assertTrue( "Check normal included",
|
||||
@ -239,7 +248,7 @@ public void testInclusion()
|
||||
|
||||
public void testTextualVersion()
|
||||
{
|
||||
List artifacts = discoverer.discoverArtifacts( repositoryLocation, null, true );
|
||||
List artifacts = discoverer.discoverArtifacts( repository, null, true );
|
||||
assertNotNull( "Check artifacts not null", artifacts );
|
||||
|
||||
assertTrue( "Check normal included",
|
||||
@ -248,7 +257,7 @@ public void testTextualVersion()
|
||||
|
||||
public void testArtifactWithClassifier()
|
||||
{
|
||||
List artifacts = discoverer.discoverArtifacts( repositoryLocation, null, true );
|
||||
List artifacts = discoverer.discoverArtifacts( repository, null, true );
|
||||
assertNotNull( "Check artifacts not null", artifacts );
|
||||
|
||||
assertTrue( "Check normal included",
|
||||
@ -257,7 +266,7 @@ public void testArtifactWithClassifier()
|
||||
|
||||
public void testJavaSourcesInclusion()
|
||||
{
|
||||
List artifacts = discoverer.discoverArtifacts( repositoryLocation, null, true );
|
||||
List artifacts = discoverer.discoverArtifacts( repository, null, true );
|
||||
assertNotNull( "Check artifacts not null", artifacts );
|
||||
|
||||
assertTrue( "Check normal included", artifacts.contains(
|
||||
@ -266,7 +275,7 @@ public void testJavaSourcesInclusion()
|
||||
|
||||
public void testDistributionInclusion()
|
||||
{
|
||||
List artifacts = discoverer.discoverArtifacts( repositoryLocation, null, true );
|
||||
List artifacts = discoverer.discoverArtifacts( repository, null, true );
|
||||
assertNotNull( "Check artifacts not null", artifacts );
|
||||
|
||||
assertTrue( "Check zip included",
|
||||
@ -278,7 +287,7 @@ public void testDistributionInclusion()
|
||||
|
||||
public void testSnapshotInclusion()
|
||||
{
|
||||
List artifacts = discoverer.discoverArtifacts( repositoryLocation, null, true );
|
||||
List artifacts = discoverer.discoverArtifacts( repository, null, true );
|
||||
assertNotNull( "Check artifacts not null", artifacts );
|
||||
|
||||
assertTrue( "Check normal included", artifacts.contains( createArtifact( "javax.sql", "jdbc", "2.0" ) ) );
|
||||
@ -288,7 +297,7 @@ public void testSnapshotInclusion()
|
||||
|
||||
public void testSnapshotExclusion()
|
||||
{
|
||||
List artifacts = discoverer.discoverArtifacts( repositoryLocation, null, false );
|
||||
List artifacts = discoverer.discoverArtifacts( repository, null, false );
|
||||
assertNotNull( "Check artifacts not null", artifacts );
|
||||
|
||||
assertTrue( "Check normal included", artifacts.contains( createArtifact( "javax.sql", "jdbc", "2.0" ) ) );
|
||||
@ -296,6 +305,33 @@ public void testSnapshotExclusion()
|
||||
artifacts.contains( createArtifact( "org.apache.maven", "testing", "1.0-20050611.112233-1" ) ) );
|
||||
}
|
||||
|
||||
public void testFileSet()
|
||||
{
|
||||
List artifacts = discoverer.discoverArtifacts( repository, null, true );
|
||||
assertNotNull( "Check artifacts not null", artifacts );
|
||||
|
||||
for ( Iterator i = artifacts.iterator(); i.hasNext(); )
|
||||
{
|
||||
Artifact artifact = (Artifact) i.next();
|
||||
assertNotNull( "Check file is set", artifact.getFile() );
|
||||
}
|
||||
}
|
||||
|
||||
public void testRepositorySet()
|
||||
throws MalformedURLException
|
||||
{
|
||||
List artifacts = discoverer.discoverArtifacts( repository, null, true );
|
||||
assertNotNull( "Check artifacts not null", artifacts );
|
||||
|
||||
String url = repository.getUrl();
|
||||
for ( Iterator i = artifacts.iterator(); i.hasNext(); )
|
||||
{
|
||||
Artifact artifact = (Artifact) i.next();
|
||||
assertNotNull( "Check repository set", artifact.getRepository() );
|
||||
assertEquals( "Check repository url is correct", url, artifact.getRepository().getUrl() );
|
||||
}
|
||||
}
|
||||
|
||||
private Artifact createArtifact( String groupId, String artifactId, String version )
|
||||
{
|
||||
return factory.createArtifact( groupId, artifactId, version, null, "jar" );
|
||||
|
Loading…
x
Reference in New Issue
Block a user