PR: MRM-9 git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@349671 13f79535-47bb-0310-9956-ffa450edef68tags/archiva-0.9-alpha-1
@@ -107,8 +107,16 @@ public class DefaultArtifactDiscoverer | |||
remainingFilename = remainingFilename.substring( artifactId.length() + 1 ); | |||
if ( result.isSnapshot() ) | |||
{ | |||
result = artifactFactory.createArtifact( groupId, artifactId, version, Artifact.SCOPE_RUNTIME, "jar" ); | |||
result.setResolvedVersion( remainingFilename.substring( 0, remainingFilename.length() - 4 ) ); | |||
result = artifactFactory.createArtifact( groupId, artifactId, | |||
remainingFilename.substring( 0, remainingFilename.length() - 4 ), | |||
Artifact.SCOPE_RUNTIME, "jar" ); | |||
// poor encapsulation requires we do this to populate base version | |||
if ( !result.isSnapshot() ) | |||
{ | |||
addKickedOutPath( path ); | |||
return null; | |||
} | |||
if ( !result.getBaseVersion().equals( version ) ) | |||
{ | |||
addKickedOutPath( path ); |
@@ -170,6 +170,26 @@ public class DefaultArtifactDiscovererTest | |||
} | |||
} | |||
public void testKickoutWithWrongSnapshotVersion() | |||
{ | |||
List artifacts = discoverer.discoverArtifacts( repositoryLocation, null, false ); | |||
assertNotNull( "Check artifacts not null", artifacts ); | |||
boolean found = false; | |||
for ( Iterator i = discoverer.getKickedOutPathsIterator(); i.hasNext() && !found; ) | |||
{ | |||
String path = (String) i.next(); | |||
found = path.replace( '\\', '/' ).equals( "invalid/invalid/1.0-SNAPSHOT/invalid-1.0.jar" ); | |||
} | |||
assertTrue( "Check kickout was found", found ); | |||
for ( Iterator i = artifacts.iterator(); i.hasNext(); ) | |||
{ | |||
Artifact a = (Artifact) i.next(); | |||
assertFalse( "Check not 'invalid-1.0.jar'", a.getFile().getName().equals( "invalid-1.0.jar" ) ); | |||
} | |||
} | |||
public void testSnapshotInclusion() | |||
{ | |||
List artifacts = discoverer.discoverArtifacts( repositoryLocation, null, true ); |