mirror of https://github.com/apache/maven.git
o slimming down the interface for the mirror builder
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@748649 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7040079ca9
commit
e51635bf44
|
@ -47,26 +47,6 @@ public class DefaultMirrorBuilder
|
||||||
mirrors.put( mirrorOf, mirror );
|
mirrors.put( mirrorOf, mirror );
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArtifactRepository getMirrorRepository( ArtifactRepository repository )
|
|
||||||
{
|
|
||||||
ArtifactRepository mirror = getMirror( repository );
|
|
||||||
if ( mirror != null )
|
|
||||||
{
|
|
||||||
String id = mirror.getId();
|
|
||||||
if ( id == null )
|
|
||||||
{
|
|
||||||
// TODO: this should be illegal in settings.xml
|
|
||||||
id = repository.getId();
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.debug( "Using mirror: " + mirror.getId() + " for repository: " + repository.getId() + "\n(mirror url: " + mirror.getUrl() + ")" );
|
|
||||||
repository = repositoryFactory.createArtifactRepository( id, mirror.getUrl(),
|
|
||||||
repository.getLayout(), repository.getSnapshots(),
|
|
||||||
repository.getReleases() );
|
|
||||||
}
|
|
||||||
return repository;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method finds a matching mirror for the selected repository. If there is an exact match,
|
* This method finds a matching mirror for the selected repository. If there is an exact match,
|
||||||
* this will be used. If there is no exact match, then the list of mirrors is examined to see if
|
* this will be used. If there is no exact match, then the list of mirrors is examined to see if
|
||||||
|
@ -98,6 +78,34 @@ public class DefaultMirrorBuilder
|
||||||
return selectedMirror;
|
return selectedMirror;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void clearMirrors()
|
||||||
|
{
|
||||||
|
mirrors.clear();
|
||||||
|
anonymousMirrorIdSeed = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make these available to tests
|
||||||
|
|
||||||
|
ArtifactRepository getMirrorRepository( ArtifactRepository repository )
|
||||||
|
{
|
||||||
|
ArtifactRepository mirror = getMirror( repository );
|
||||||
|
if ( mirror != null )
|
||||||
|
{
|
||||||
|
String id = mirror.getId();
|
||||||
|
if ( id == null )
|
||||||
|
{
|
||||||
|
// TODO: this should be illegal in settings.xml
|
||||||
|
id = repository.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.debug( "Using mirror: " + mirror.getId() + " for repository: " + repository.getId() + "\n(mirror url: " + mirror.getUrl() + ")" );
|
||||||
|
repository = repositoryFactory.createArtifactRepository( id, mirror.getUrl(),
|
||||||
|
repository.getLayout(), repository.getSnapshots(),
|
||||||
|
repository.getReleases() );
|
||||||
|
}
|
||||||
|
return repository;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method checks if the pattern matches the originalRepository. Valid patterns: * =
|
* This method checks if the pattern matches the originalRepository. Valid patterns: * =
|
||||||
* everything external:* = everything not on the localhost and not file based. repo,repo1 = repo
|
* everything external:* = everything not on the localhost and not file based. repo,repo1 = repo
|
||||||
|
@ -107,7 +115,7 @@ public class DefaultMirrorBuilder
|
||||||
* @param pattern used for match. Currently only '*' is supported.
|
* @param pattern used for match. Currently only '*' is supported.
|
||||||
* @return true if the repository is a match to this pattern.
|
* @return true if the repository is a match to this pattern.
|
||||||
*/
|
*/
|
||||||
public boolean matchPattern( ArtifactRepository originalRepository, String pattern )
|
boolean matchPattern( ArtifactRepository originalRepository, String pattern )
|
||||||
{
|
{
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
String originalId = originalRepository.getId();
|
String originalId = originalRepository.getId();
|
||||||
|
@ -162,7 +170,7 @@ public class DefaultMirrorBuilder
|
||||||
* @param originalRepository
|
* @param originalRepository
|
||||||
* @return true if external.
|
* @return true if external.
|
||||||
*/
|
*/
|
||||||
public boolean isExternalRepo( ArtifactRepository originalRepository )
|
boolean isExternalRepo( ArtifactRepository originalRepository )
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -175,10 +183,4 @@ public class DefaultMirrorBuilder
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearMirrors()
|
|
||||||
{
|
|
||||||
mirrors.clear();
|
|
||||||
anonymousMirrorIdSeed = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,17 +4,9 @@ import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
|
||||||
public interface MirrorBuilder
|
public interface MirrorBuilder
|
||||||
{
|
{
|
||||||
ArtifactRepository getMirror( ArtifactRepository originalRepository );
|
ArtifactRepository getMirror( ArtifactRepository repository );
|
||||||
|
|
||||||
void addMirror( String id, String mirrorOf, String url );
|
void addMirror( String id, String mirrorOf, String url );
|
||||||
|
|
||||||
void clearMirrors();
|
void clearMirrors();
|
||||||
|
|
||||||
// These need to go
|
|
||||||
|
|
||||||
boolean isExternalRepo( ArtifactRepository originalRepository );
|
|
||||||
|
|
||||||
boolean matchPattern( ArtifactRepository originalRepository, String pattern );
|
|
||||||
|
|
||||||
ArtifactRepository getMirrorRepository( ArtifactRepository repository );
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,12 +8,12 @@ import org.codehaus.plexus.PlexusTestCase;
|
||||||
public class MirrorProcessorTest
|
public class MirrorProcessorTest
|
||||||
extends PlexusTestCase
|
extends PlexusTestCase
|
||||||
{
|
{
|
||||||
private MirrorBuilder mirrorBuilder;
|
private DefaultMirrorBuilder mirrorBuilder;
|
||||||
|
|
||||||
protected void setUp()
|
protected void setUp()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
mirrorBuilder = lookup( MirrorBuilder.class );
|
mirrorBuilder = (DefaultMirrorBuilder) lookup( MirrorBuilder.class );
|
||||||
mirrorBuilder.clearMirrors();
|
mirrorBuilder.clearMirrors();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue