mirror of https://github.com/apache/maven.git
o remove more methods to the repository system, starting to get close to the final set of methods and then we can move on to the classes of the binding to the repository system
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@750738 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a2666d2c9f
commit
f4ec59594c
|
@ -80,7 +80,7 @@ public class DefaultArtifactDeployer
|
||||||
FileUtils.copyFile( source, artifactFile );
|
FileUtils.copyFile( source, artifactFile );
|
||||||
}
|
}
|
||||||
|
|
||||||
wagonManager.putArtifact( source, artifact, deploymentRepository );
|
wagonManager.putArtifact( source, artifact, deploymentRepository, null );
|
||||||
|
|
||||||
// must be after the artifact is installed
|
// must be after the artifact is installed
|
||||||
for ( ArtifactMetadata metadata : artifact.getMetadataList() )
|
for ( ArtifactMetadata metadata : artifact.getMetadataList() )
|
||||||
|
|
|
@ -24,19 +24,16 @@ import java.io.IOException;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.apache.maven.artifact.Artifact;
|
import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.artifact.metadata.ArtifactMetadata;
|
import org.apache.maven.artifact.metadata.ArtifactMetadata;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
|
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
|
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
|
||||||
import org.apache.maven.artifact.repository.DefaultArtifactRepository;
|
|
||||||
import org.apache.maven.wagon.ConnectionException;
|
import org.apache.maven.wagon.ConnectionException;
|
||||||
import org.apache.maven.wagon.ResourceDoesNotExistException;
|
import org.apache.maven.wagon.ResourceDoesNotExistException;
|
||||||
import org.apache.maven.wagon.TransferFailedException;
|
import org.apache.maven.wagon.TransferFailedException;
|
||||||
|
@ -51,7 +48,6 @@ import org.apache.maven.wagon.proxy.ProxyInfo;
|
||||||
import org.apache.maven.wagon.proxy.ProxyInfoProvider;
|
import org.apache.maven.wagon.proxy.ProxyInfoProvider;
|
||||||
import org.apache.maven.wagon.repository.Repository;
|
import org.apache.maven.wagon.repository.Repository;
|
||||||
import org.apache.maven.wagon.repository.RepositoryPermissions;
|
import org.apache.maven.wagon.repository.RepositoryPermissions;
|
||||||
import org.codehaus.plexus.PlexusConstants;
|
|
||||||
import org.codehaus.plexus.PlexusContainer;
|
import org.codehaus.plexus.PlexusContainer;
|
||||||
import org.codehaus.plexus.component.annotations.Component;
|
import org.codehaus.plexus.component.annotations.Component;
|
||||||
import org.codehaus.plexus.component.annotations.Requirement;
|
import org.codehaus.plexus.component.annotations.Requirement;
|
||||||
|
@ -59,26 +55,23 @@ import org.codehaus.plexus.component.configurator.BasicComponentConfigurator;
|
||||||
import org.codehaus.plexus.component.configurator.ComponentConfigurationException;
|
import org.codehaus.plexus.component.configurator.ComponentConfigurationException;
|
||||||
import org.codehaus.plexus.component.configurator.ComponentConfigurator;
|
import org.codehaus.plexus.component.configurator.ComponentConfigurator;
|
||||||
import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException;
|
import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException;
|
||||||
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
|
|
||||||
import org.codehaus.plexus.configuration.PlexusConfiguration;
|
import org.codehaus.plexus.configuration.PlexusConfiguration;
|
||||||
import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration;
|
import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration;
|
||||||
import org.codehaus.plexus.context.Context;
|
import org.codehaus.plexus.logging.Logger;
|
||||||
import org.codehaus.plexus.context.ContextException;
|
|
||||||
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
|
||||||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
|
|
||||||
import org.codehaus.plexus.util.FileUtils;
|
import org.codehaus.plexus.util.FileUtils;
|
||||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
|
||||||
|
|
||||||
@Component(role=WagonManager.class)
|
@Component(role=WagonManager.class)
|
||||||
public class DefaultWagonManager
|
public class DefaultWagonManager
|
||||||
extends AbstractLogEnabled
|
|
||||||
implements WagonManager
|
implements WagonManager
|
||||||
{
|
{
|
||||||
private static final String[] CHECKSUM_IDS = {"md5", "sha1"};
|
private static final String[] CHECKSUM_IDS = {"md5", "sha1"};
|
||||||
|
|
||||||
/** have to match the CHECKSUM_IDS */
|
/** have to match the CHECKSUM_IDS */
|
||||||
private static final String[] CHECKSUM_ALGORITHMS = {"MD5", "SHA-1"};
|
private static final String[] CHECKSUM_ALGORITHMS = {"MD5", "SHA-1"};
|
||||||
|
|
||||||
|
@Requirement
|
||||||
|
private Logger logger;
|
||||||
|
|
||||||
@Requirement
|
@Requirement
|
||||||
private PlexusContainer container;
|
private PlexusContainer container;
|
||||||
|
|
||||||
|
@ -96,12 +89,6 @@ public class DefaultWagonManager
|
||||||
/** Map( String, XmlPlexusConfiguration ) with the repository id and the wagon configuration */
|
/** Map( String, XmlPlexusConfiguration ) with the repository id and the wagon configuration */
|
||||||
private Map<String,XmlPlexusConfiguration> serverConfigurationMap = new HashMap<String,XmlPlexusConfiguration>();
|
private Map<String,XmlPlexusConfiguration> serverConfigurationMap = new HashMap<String,XmlPlexusConfiguration>();
|
||||||
|
|
||||||
private TransferListener downloadMonitor;
|
|
||||||
|
|
||||||
private boolean online = true;
|
|
||||||
|
|
||||||
private boolean interactive = true;
|
|
||||||
|
|
||||||
private RepositoryPermissions defaultRepositoryPermissions;
|
private RepositoryPermissions defaultRepositoryPermissions;
|
||||||
|
|
||||||
// Components
|
// Components
|
||||||
|
@ -120,6 +107,13 @@ public class DefaultWagonManager
|
||||||
|
|
||||||
private String httpUserAgent = "Apache-Maven/3.0-alpha-1";
|
private String httpUserAgent = "Apache-Maven/3.0-alpha-1";
|
||||||
|
|
||||||
|
private TransferListener downloadMonitor;
|
||||||
|
|
||||||
|
public void setDownloadMonitor( TransferListener downloadMonitor )
|
||||||
|
{
|
||||||
|
this.downloadMonitor = downloadMonitor;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: this leaks the component in the public api - it is never released back to the container
|
// TODO: this leaks the component in the public api - it is never released back to the container
|
||||||
public Wagon getWagon( Repository repository )
|
public Wagon getWagon( Repository repository )
|
||||||
throws UnsupportedProtocolException, WagonConfigurationException
|
throws UnsupportedProtocolException, WagonConfigurationException
|
||||||
|
@ -160,27 +154,26 @@ public class DefaultWagonManager
|
||||||
return wagon;
|
return wagon;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void putArtifact( File source,
|
public void putArtifact( File source, Artifact artifact, ArtifactRepository deploymentRepository )
|
||||||
Artifact artifact,
|
throws TransferFailedException
|
||||||
ArtifactRepository deploymentRepository )
|
{
|
||||||
|
putRemoteFile( deploymentRepository, source, deploymentRepository.pathOf( artifact ), downloadMonitor );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void putArtifact( File source, Artifact artifact, ArtifactRepository deploymentRepository, TransferListener downloadMonitor )
|
||||||
throws TransferFailedException
|
throws TransferFailedException
|
||||||
{
|
{
|
||||||
putRemoteFile( deploymentRepository, source, deploymentRepository.pathOf( artifact ), downloadMonitor );
|
putRemoteFile( deploymentRepository, source, deploymentRepository.pathOf( artifact ), downloadMonitor );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void putArtifactMetadata( File source,
|
public void putArtifactMetadata( File source, ArtifactMetadata artifactMetadata, ArtifactRepository repository )
|
||||||
ArtifactMetadata artifactMetadata,
|
|
||||||
ArtifactRepository repository )
|
|
||||||
throws TransferFailedException
|
throws TransferFailedException
|
||||||
{
|
{
|
||||||
getLogger().info( "Uploading " + artifactMetadata );
|
logger.info( "Uploading " + artifactMetadata );
|
||||||
putRemoteFile( repository, source, repository.pathOfRemoteRepositoryMetadata( artifactMetadata ), null );
|
putRemoteFile( repository, source, repository.pathOfRemoteRepositoryMetadata( artifactMetadata ), null );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void putRemoteFile( ArtifactRepository repository,
|
private void putRemoteFile( ArtifactRepository repository, File source, String remotePath, TransferListener downloadMonitor )
|
||||||
File source,
|
|
||||||
String remotePath,
|
|
||||||
TransferListener downloadMonitor )
|
|
||||||
throws TransferFailedException
|
throws TransferFailedException
|
||||||
{
|
{
|
||||||
String protocol = repository.getProtocol();
|
String protocol = repository.getProtocol();
|
||||||
|
@ -233,7 +226,7 @@ public class DefaultWagonManager
|
||||||
catch ( CredentialsDataSourceException e )
|
catch ( CredentialsDataSourceException e )
|
||||||
{
|
{
|
||||||
String err = "Problem with server credentials: " + e.getMessage();
|
String err = "Problem with server credentials: " + e.getMessage();
|
||||||
getLogger().error( err );
|
logger.error( err );
|
||||||
throw new TransferFailedException( err );
|
throw new TransferFailedException( err );
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
@ -315,22 +308,31 @@ public class DefaultWagonManager
|
||||||
|
|
||||||
// NOTE: It is not possible that this method throws TransferFailedException under current conditions.
|
// NOTE: It is not possible that this method throws TransferFailedException under current conditions.
|
||||||
// FIXME: Change the throws clause to reflect the fact that we're never throwing TransferFailedException
|
// FIXME: Change the throws clause to reflect the fact that we're never throwing TransferFailedException
|
||||||
public void getArtifact( Artifact artifact,
|
public void getArtifact( Artifact artifact, ArtifactRepository remoteRepository, boolean force )
|
||||||
List<ArtifactRepository> remoteRepositories )
|
throws TransferFailedException, ResourceDoesNotExistException
|
||||||
|
{
|
||||||
|
getArtifact( artifact, remoteRepository, downloadMonitor, force );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void getArtifact( Artifact artifact, ArtifactRepository remoteRepository )
|
||||||
|
throws TransferFailedException, ResourceDoesNotExistException
|
||||||
|
{
|
||||||
|
getArtifact( artifact, remoteRepository, downloadMonitor, true );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void getArtifact( Artifact artifact, List<ArtifactRepository> remoteRepositories, TransferListener downloadMonitor )
|
||||||
throws TransferFailedException, ResourceDoesNotExistException
|
throws TransferFailedException, ResourceDoesNotExistException
|
||||||
{
|
{
|
||||||
getArtifact( artifact, remoteRepositories, true );
|
getArtifact( artifact, remoteRepositories, downloadMonitor, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getArtifact( Artifact artifact,
|
public void getArtifact( Artifact artifact, List<ArtifactRepository> remoteRepositories, TransferListener downloadMonitor, boolean force )
|
||||||
List<ArtifactRepository> remoteRepositories,
|
|
||||||
boolean force )
|
|
||||||
throws TransferFailedException, ResourceDoesNotExistException
|
throws TransferFailedException, ResourceDoesNotExistException
|
||||||
{
|
{
|
||||||
for (ArtifactRepository repository : remoteRepositories) {
|
for (ArtifactRepository repository : remoteRepositories) {
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
getArtifact( artifact, repository, force );
|
getArtifact( artifact, repository, downloadMonitor, force );
|
||||||
|
|
||||||
if (artifact.isResolved())
|
if (artifact.isResolved())
|
||||||
{
|
{
|
||||||
|
@ -342,12 +344,12 @@ public class DefaultWagonManager
|
||||||
// This one we will eat when looking through remote repositories
|
// This one we will eat when looking through remote repositories
|
||||||
// because we want to cycle through them all before squawking.
|
// because we want to cycle through them all before squawking.
|
||||||
|
|
||||||
getLogger().debug( "Unable to get resource '" + artifact.getId() + "' from repository " +
|
logger.debug( "Unable to get resource '" + artifact.getId() + "' from repository " +
|
||||||
repository.getId() + " (" + repository.getUrl() + ")", e );
|
repository.getId() + " (" + repository.getUrl() + ")", e );
|
||||||
}
|
}
|
||||||
catch ( TransferFailedException e )
|
catch ( TransferFailedException e )
|
||||||
{
|
{
|
||||||
getLogger().debug( "Unable to get resource '" + artifact.getId() + "' from repository " +
|
logger.debug( "Unable to get resource '" + artifact.getId() + "' from repository " +
|
||||||
repository.getId() + " (" + repository.getUrl() + ")", e );
|
repository.getId() + " (" + repository.getUrl() + ")", e );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -359,17 +361,14 @@ public class DefaultWagonManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getArtifact( Artifact artifact,
|
public void getArtifact( Artifact artifact, ArtifactRepository repository, TransferListener downloadMonitor )
|
||||||
ArtifactRepository repository )
|
|
||||||
throws TransferFailedException,
|
throws TransferFailedException,
|
||||||
ResourceDoesNotExistException
|
ResourceDoesNotExistException
|
||||||
{
|
{
|
||||||
getArtifact( artifact, repository, true );
|
getArtifact( artifact, repository, downloadMonitor, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getArtifact( Artifact artifact,
|
public void getArtifact( Artifact artifact, ArtifactRepository repository, TransferListener downloadMonitor, boolean force )
|
||||||
ArtifactRepository repository,
|
|
||||||
boolean force )
|
|
||||||
throws TransferFailedException, ResourceDoesNotExistException
|
throws TransferFailedException, ResourceDoesNotExistException
|
||||||
{
|
{
|
||||||
String remotePath = repository.pathOf( artifact );
|
String remotePath = repository.pathOf( artifact );
|
||||||
|
@ -378,18 +377,18 @@ public class DefaultWagonManager
|
||||||
|
|
||||||
if ( !policy.isEnabled() )
|
if ( !policy.isEnabled() )
|
||||||
{
|
{
|
||||||
getLogger().debug( "Skipping disabled repository " + repository.getId() );
|
logger.debug( "Skipping disabled repository " + repository.getId() );
|
||||||
}
|
}
|
||||||
else if ( repository.isBlacklisted() )
|
else if ( repository.isBlacklisted() )
|
||||||
{
|
{
|
||||||
getLogger().debug( "Skipping blacklisted repository " + repository.getId() );
|
logger.debug( "Skipping blacklisted repository " + repository.getId() );
|
||||||
}
|
}
|
||||||
// If the artifact is a snapshot, we need to determine whether it's time to check this repository for an update:
|
// If the artifact is a snapshot, we need to determine whether it's time to check this repository for an update:
|
||||||
// 1. If it's forced, then check
|
// 1. If it's forced, then check
|
||||||
// 2. If the updateInterval has been exceeded since the last check for this artifact on this repository, then check.
|
// 2. If the updateInterval has been exceeded since the last check for this artifact on this repository, then check.
|
||||||
else if ( artifact.isSnapshot() && ( force || updateCheckManager.isUpdateRequired( artifact, repository ) ) )
|
else if ( artifact.isSnapshot() && ( force || updateCheckManager.isUpdateRequired( artifact, repository ) ) )
|
||||||
{
|
{
|
||||||
getLogger().debug( "Trying repository " + repository.getId() );
|
logger.debug( "Trying repository " + repository.getId() );
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -400,7 +399,7 @@ public class DefaultWagonManager
|
||||||
updateCheckManager.touch( artifact, repository );
|
updateCheckManager.touch( artifact, repository );
|
||||||
}
|
}
|
||||||
|
|
||||||
getLogger().debug( " Artifact resolved" );
|
logger.debug( " Artifact resolved" );
|
||||||
|
|
||||||
artifact.setResolved( true );
|
artifact.setResolved( true );
|
||||||
}
|
}
|
||||||
|
@ -414,7 +413,7 @@ public class DefaultWagonManager
|
||||||
// if POM is not present locally, try and get it if it's forced, out of date, or has not been attempted yet
|
// if POM is not present locally, try and get it if it's forced, out of date, or has not been attempted yet
|
||||||
if ( force || updateCheckManager.isPomUpdateRequired( artifact, repository ) )
|
if ( force || updateCheckManager.isPomUpdateRequired( artifact, repository ) )
|
||||||
{
|
{
|
||||||
getLogger().debug( "Trying repository " + repository.getId() );
|
logger.debug( "Trying repository " + repository.getId() );
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -428,7 +427,7 @@ public class DefaultWagonManager
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
getLogger().debug( " Artifact resolved" );
|
logger.debug( " Artifact resolved" );
|
||||||
|
|
||||||
artifact.setResolved( true );
|
artifact.setResolved( true );
|
||||||
}
|
}
|
||||||
|
@ -448,11 +447,11 @@ public class DefaultWagonManager
|
||||||
// don't write touch-file for release artifacts.
|
// don't write touch-file for release artifacts.
|
||||||
else if ( !artifact.isSnapshot() )
|
else if ( !artifact.isSnapshot() )
|
||||||
{
|
{
|
||||||
getLogger().debug( "Trying repository " + repository.getId() );
|
logger.debug( "Trying repository " + repository.getId() );
|
||||||
|
|
||||||
getRemoteFile( repository, artifact.getFile(), remotePath, downloadMonitor, policy.getChecksumPolicy(), false );
|
getRemoteFile( repository, artifact.getFile(), remotePath, downloadMonitor, policy.getChecksumPolicy(), false );
|
||||||
|
|
||||||
getLogger().debug( " Artifact resolved" );
|
logger.debug( " Artifact resolved" );
|
||||||
|
|
||||||
artifact.setResolved( true );
|
artifact.setResolved( true );
|
||||||
}
|
}
|
||||||
|
@ -598,7 +597,7 @@ public class DefaultWagonManager
|
||||||
// repository's checksum checking policy.
|
// repository's checksum checking policy.
|
||||||
if ( firstRun )
|
if ( firstRun )
|
||||||
{
|
{
|
||||||
getLogger().warn( "*** CHECKSUM FAILED - " + e.getMessage() + " - RETRYING" );
|
logger.warn( "*** CHECKSUM FAILED - " + e.getMessage() + " - RETRYING" );
|
||||||
retry = true;
|
retry = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -608,7 +607,7 @@ public class DefaultWagonManager
|
||||||
}
|
}
|
||||||
catch ( ResourceDoesNotExistException sha1TryException )
|
catch ( ResourceDoesNotExistException sha1TryException )
|
||||||
{
|
{
|
||||||
getLogger().debug( "SHA1 not found, trying MD5", sha1TryException );
|
logger.debug( "SHA1 not found, trying MD5", sha1TryException );
|
||||||
|
|
||||||
// if this IS NOT a ChecksumFailedException, it was a problem with transfer/read of the checksum
|
// if this IS NOT a ChecksumFailedException, it was a problem with transfer/read of the checksum
|
||||||
// file...we'll try again with the MD5 checksum.
|
// file...we'll try again with the MD5 checksum.
|
||||||
|
@ -719,7 +718,7 @@ public class DefaultWagonManager
|
||||||
else if ( !ArtifactRepositoryPolicy.CHECKSUM_POLICY_IGNORE.equals( checksumPolicy ) )
|
else if ( !ArtifactRepositoryPolicy.CHECKSUM_POLICY_IGNORE.equals( checksumPolicy ) )
|
||||||
{
|
{
|
||||||
// warn if it is set to anything other than ignore
|
// warn if it is set to anything other than ignore
|
||||||
getLogger().warn( "*** CHECKSUM FAILED - " + message + " - IGNORING" );
|
logger.warn( "*** CHECKSUM FAILED - " + message + " - IGNORING" );
|
||||||
}
|
}
|
||||||
// otherwise it is ignore
|
// otherwise it is ignore
|
||||||
}
|
}
|
||||||
|
@ -794,7 +793,7 @@ public class DefaultWagonManager
|
||||||
}
|
}
|
||||||
catch ( ConnectionException e )
|
catch ( ConnectionException e )
|
||||||
{
|
{
|
||||||
getLogger().error( "Problem disconnecting from wagon - ignoring: " + e.getMessage() );
|
logger.error( "Problem disconnecting from wagon - ignoring: " + e.getMessage() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -807,8 +806,8 @@ public class DefaultWagonManager
|
||||||
}
|
}
|
||||||
catch ( ComponentLifecycleException e )
|
catch ( ComponentLifecycleException e )
|
||||||
{
|
{
|
||||||
getLogger().error( "Problem releasing wagon - ignoring: " + e.getMessage() );
|
logger.error( "Problem releasing wagon - ignoring: " + e.getMessage() );
|
||||||
getLogger().debug( "", e );
|
logger.debug( "", e );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -918,32 +917,6 @@ public class DefaultWagonManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setInteractive( boolean interactive )
|
|
||||||
{
|
|
||||||
this.interactive = interactive;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void findAndRegisterWagons( PlexusContainer container )
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Map wagons = container.lookupMap( Wagon.ROLE );
|
|
||||||
|
|
||||||
registerWagons( wagons.keySet(), container );
|
|
||||||
}
|
|
||||||
catch ( ComponentLookupException e )
|
|
||||||
{
|
|
||||||
// no wagons found in the extension
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @deprecated Wagons are discovered in plugin and extension realms now. */
|
|
||||||
@Deprecated
|
|
||||||
public void registerWagons( Collection wagons,
|
|
||||||
PlexusContainer extensionContainer )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Applies the server configuration to the wagon
|
* Applies the server configuration to the wagon
|
||||||
*
|
*
|
||||||
|
@ -986,7 +959,7 @@ public class DefaultWagonManager
|
||||||
}
|
}
|
||||||
catch ( ComponentLifecycleException e )
|
catch ( ComponentLifecycleException e )
|
||||||
{
|
{
|
||||||
getLogger().error( "Problem releasing configurator - ignoring: " + e.getMessage() );
|
logger.error( "Problem releasing configurator - ignoring: " + e.getMessage() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1009,11 +982,4 @@ public class DefaultWagonManager
|
||||||
{
|
{
|
||||||
return httpUserAgent;
|
return httpUserAgent;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Things to remove
|
|
||||||
|
|
||||||
public void setDownloadMonitor( TransferListener listener )
|
|
||||||
{
|
|
||||||
this.downloadMonitor = listener;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,12 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
public interface WagonManager
|
public interface WagonManager
|
||||||
{
|
{
|
||||||
String ROLE = WagonManager.class.getName();
|
|
||||||
|
void getArtifact( Artifact artifact, ArtifactRepository repository, TransferListener downloadMonitor, boolean forceUpdateCheck )
|
||||||
|
throws TransferFailedException, ResourceDoesNotExistException;
|
||||||
|
|
||||||
|
void putArtifact( File source, Artifact artifact, ArtifactRepository deploymentRepository, TransferListener downloadMonitor )
|
||||||
|
throws TransferFailedException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a Wagon provider that understands the protocol passed as argument.
|
* Get a Wagon provider that understands the protocol passed as argument.
|
||||||
|
@ -66,48 +71,21 @@ public interface WagonManager
|
||||||
Wagon getWagon( Repository repository )
|
Wagon getWagon( Repository repository )
|
||||||
throws UnsupportedProtocolException, WagonConfigurationException;
|
throws UnsupportedProtocolException, WagonConfigurationException;
|
||||||
|
|
||||||
void getArtifact( Artifact artifact,
|
void getArtifact( Artifact artifact, List<ArtifactRepository> remoteRepositories, TransferListener tl, boolean force )
|
||||||
List<ArtifactRepository> remoteRepositories )
|
|
||||||
throws TransferFailedException, ResourceDoesNotExistException;
|
throws TransferFailedException, ResourceDoesNotExistException;
|
||||||
|
|
||||||
void getArtifact( Artifact artifact,
|
void getArtifact( Artifact artifact, ArtifactRepository repository, TransferListener tl )
|
||||||
List<ArtifactRepository> remoteRepositories,
|
|
||||||
boolean forceUpdateCheck )
|
|
||||||
throws TransferFailedException, ResourceDoesNotExistException;
|
|
||||||
|
|
||||||
void getArtifact( Artifact artifact,
|
|
||||||
ArtifactRepository repository )
|
|
||||||
throws TransferFailedException, ResourceDoesNotExistException;
|
throws TransferFailedException, ResourceDoesNotExistException;
|
||||||
|
|
||||||
void getArtifact( Artifact artifact,
|
void putArtifactMetadata( File source, ArtifactMetadata artifactMetadata, ArtifactRepository repository )
|
||||||
ArtifactRepository repository,
|
|
||||||
boolean forceUpdateCheck )
|
|
||||||
throws TransferFailedException, ResourceDoesNotExistException;
|
|
||||||
|
|
||||||
void putArtifact( File source,
|
|
||||||
Artifact artifact,
|
|
||||||
ArtifactRepository deploymentRepository )
|
|
||||||
throws TransferFailedException;
|
throws TransferFailedException;
|
||||||
|
|
||||||
void putArtifactMetadata( File source,
|
void getArtifactMetadata( ArtifactMetadata metadata, ArtifactRepository remoteRepository, File destination, String checksumPolicy )
|
||||||
ArtifactMetadata artifactMetadata,
|
|
||||||
ArtifactRepository repository )
|
|
||||||
throws TransferFailedException;
|
|
||||||
|
|
||||||
void getArtifactMetadata( ArtifactMetadata metadata,
|
|
||||||
ArtifactRepository remoteRepository,
|
|
||||||
File destination,
|
|
||||||
String checksumPolicy )
|
|
||||||
throws TransferFailedException, ResourceDoesNotExistException;
|
throws TransferFailedException, ResourceDoesNotExistException;
|
||||||
|
|
||||||
void getArtifactMetadataFromDeploymentRepository( ArtifactMetadata metadata, ArtifactRepository remoteRepository,
|
void getArtifactMetadataFromDeploymentRepository( ArtifactMetadata metadata, ArtifactRepository remoteRepository, File file, String checksumPolicyWarn )
|
||||||
File file, String checksumPolicyWarn )
|
|
||||||
throws TransferFailedException, ResourceDoesNotExistException;
|
throws TransferFailedException, ResourceDoesNotExistException;
|
||||||
|
|
||||||
// All the tests fail that are specifically look for the contents of the listener fail without this.
|
void addAuthenticationInfo( String repositoryId, String username, String password, String privateKey, String passphrase );
|
||||||
void setDownloadMonitor( TransferListener listener );
|
|
||||||
|
|
||||||
void addAuthenticationInfo( String repositoryId, String username, String password, String privateKey,
|
|
||||||
String passphrase );
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
|
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
|
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
|
||||||
|
import org.apache.maven.wagon.events.TransferListener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A resolution request allows you to either use an existing MavenProject, or a coordinate (gid:aid:version)
|
* A resolution request allows you to either use an existing MavenProject, or a coordinate (gid:aid:version)
|
||||||
|
@ -41,6 +42,8 @@ public class ArtifactResolutionRequest
|
||||||
// This should not be in here, it's a component
|
// This should not be in here, it's a component
|
||||||
private ArtifactMetadataSource metadataSource;
|
private ArtifactMetadataSource metadataSource;
|
||||||
|
|
||||||
|
private TransferListener transferListener;
|
||||||
|
|
||||||
private boolean resolveRoot = true;
|
private boolean resolveRoot = true;
|
||||||
|
|
||||||
public ArtifactResolutionRequest()
|
public ArtifactResolutionRequest()
|
||||||
|
@ -171,8 +174,19 @@ public class ArtifactResolutionRequest
|
||||||
public boolean isResolveRoot()
|
public boolean isResolveRoot()
|
||||||
{
|
{
|
||||||
return resolveRoot;
|
return resolveRoot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TransferListener getTransferListener()
|
||||||
|
{
|
||||||
|
return transferListener;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArtifactResolutionRequest setTransferListener( TransferListener transferListener )
|
||||||
|
{
|
||||||
|
this.transferListener = transferListener;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
StringBuffer sb = new StringBuffer()
|
StringBuffer sb = new StringBuffer()
|
||||||
|
|
|
@ -8,6 +8,7 @@ import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
|
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
|
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
|
||||||
|
import org.apache.maven.wagon.events.TransferListener;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
@ -62,7 +63,12 @@ public interface ArtifactResolver
|
||||||
|
|
||||||
// USED BY REMOTE RESOURCES PLUGIN
|
// USED BY REMOTE RESOURCES PLUGIN
|
||||||
@Deprecated
|
@Deprecated
|
||||||
void resolve( Artifact artifact, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepositor )
|
void resolve( Artifact artifact, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository )
|
||||||
throws ArtifactResolutionException, ArtifactNotFoundException;
|
throws ArtifactResolutionException, ArtifactNotFoundException;
|
||||||
|
|
||||||
|
// USED BY REMOTE RESOURCES PLUGIN
|
||||||
|
@Deprecated
|
||||||
|
void resolve( Artifact artifact, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository, TransferListener downloadMonitor )
|
||||||
|
throws ArtifactResolutionException, ArtifactNotFoundException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,9 +38,10 @@ import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
|
||||||
import org.apache.maven.artifact.transform.ArtifactTransformationManager;
|
import org.apache.maven.artifact.transform.ArtifactTransformationManager;
|
||||||
import org.apache.maven.wagon.ResourceDoesNotExistException;
|
import org.apache.maven.wagon.ResourceDoesNotExistException;
|
||||||
import org.apache.maven.wagon.TransferFailedException;
|
import org.apache.maven.wagon.TransferFailedException;
|
||||||
|
import org.apache.maven.wagon.events.TransferListener;
|
||||||
import org.codehaus.plexus.component.annotations.Component;
|
import org.codehaus.plexus.component.annotations.Component;
|
||||||
import org.codehaus.plexus.component.annotations.Requirement;
|
import org.codehaus.plexus.component.annotations.Requirement;
|
||||||
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
import org.codehaus.plexus.logging.Logger;
|
||||||
import org.codehaus.plexus.util.FileUtils;
|
import org.codehaus.plexus.util.FileUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -48,7 +49,6 @@ import org.codehaus.plexus.util.FileUtils;
|
||||||
*/
|
*/
|
||||||
@Component(role = ArtifactResolver.class)
|
@Component(role = ArtifactResolver.class)
|
||||||
public class DefaultArtifactResolver
|
public class DefaultArtifactResolver
|
||||||
extends AbstractLogEnabled
|
|
||||||
implements ArtifactResolver
|
implements ArtifactResolver
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -58,6 +58,9 @@ public class DefaultArtifactResolver
|
||||||
// Components
|
// Components
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
@Requirement
|
||||||
|
private Logger logger;
|
||||||
|
|
||||||
@Requirement
|
@Requirement
|
||||||
private WagonManager wagonManager;
|
private WagonManager wagonManager;
|
||||||
|
|
||||||
|
@ -87,19 +90,19 @@ public class DefaultArtifactResolver
|
||||||
return online;
|
return online;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resolve( Artifact artifact, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository )
|
public void resolve( Artifact artifact, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository, TransferListener resolutionListener )
|
||||||
throws ArtifactResolutionException, ArtifactNotFoundException
|
throws ArtifactResolutionException, ArtifactNotFoundException
|
||||||
{
|
{
|
||||||
resolve( artifact, remoteRepositories, localRepository, false );
|
resolve( artifact, remoteRepositories, localRepository, resolutionListener, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resolveAlways( Artifact artifact, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository )
|
public void resolveAlways( Artifact artifact, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository, TransferListener downloadMonitor )
|
||||||
throws ArtifactResolutionException, ArtifactNotFoundException
|
throws ArtifactResolutionException, ArtifactNotFoundException
|
||||||
{
|
{
|
||||||
resolve( artifact, remoteRepositories, localRepository, true );
|
resolve( artifact, remoteRepositories, localRepository, downloadMonitor, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resolve( Artifact artifact, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository, boolean force )
|
private void resolve( Artifact artifact, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository, TransferListener downloadMonitor, boolean force )
|
||||||
throws ArtifactResolutionException, ArtifactNotFoundException
|
throws ArtifactResolutionException, ArtifactNotFoundException
|
||||||
{
|
{
|
||||||
if ( artifact == null )
|
if ( artifact == null )
|
||||||
|
@ -167,11 +170,11 @@ public class DefaultArtifactResolver
|
||||||
if ( artifact.getRepository() != null )
|
if ( artifact.getRepository() != null )
|
||||||
{
|
{
|
||||||
// the transformations discovered the artifact - so use it exclusively
|
// the transformations discovered the artifact - so use it exclusively
|
||||||
wagonManager.getArtifact( artifact, artifact.getRepository(), force );
|
wagonManager.getArtifact( artifact, artifact.getRepository(), downloadMonitor, force );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wagonManager.getArtifact( artifact, remoteRepositories, force );
|
wagonManager.getArtifact( artifact, remoteRepositories, downloadMonitor, force );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !artifact.isResolved() && !destination.exists() )
|
if ( !artifact.isResolved() && !destination.exists() )
|
||||||
|
@ -350,12 +353,12 @@ public class DefaultArtifactResolver
|
||||||
{
|
{
|
||||||
listeners = new ArrayList<ResolutionListener>();
|
listeners = new ArrayList<ResolutionListener>();
|
||||||
|
|
||||||
if ( getLogger().isDebugEnabled() )
|
if ( logger.isDebugEnabled() )
|
||||||
{
|
{
|
||||||
listeners.add( new DebugResolutionListener( getLogger() ) );
|
listeners.add( new DebugResolutionListener( logger ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
listeners.add( new WarningResolutionListener( getLogger() ) );
|
listeners.add( new WarningResolutionListener( logger ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
ArtifactResolutionResult result = new ArtifactResolutionResult();
|
ArtifactResolutionResult result = new ArtifactResolutionResult();
|
||||||
|
@ -407,7 +410,7 @@ public class DefaultArtifactResolver
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
resolve( artifact, remoteRepositories, localRepository );
|
resolve( artifact, remoteRepositories, localRepository, request.getTransferListener() );
|
||||||
}
|
}
|
||||||
catch ( ArtifactNotFoundException anfe )
|
catch ( ArtifactNotFoundException anfe )
|
||||||
{
|
{
|
||||||
|
@ -428,4 +431,10 @@ public class DefaultArtifactResolver
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void resolve( Artifact artifact, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository )
|
||||||
|
throws ArtifactResolutionException, ArtifactNotFoundException
|
||||||
|
{
|
||||||
|
resolve( artifact, remoteRepositories, localRepository, null );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ public class DefaultWagonManagerTest
|
||||||
{
|
{
|
||||||
super.setUp();
|
super.setUp();
|
||||||
|
|
||||||
wagonManager = (DefaultWagonManager) lookup( WagonManager.ROLE );
|
wagonManager = (DefaultWagonManager) lookup( WagonManager.class );
|
||||||
|
|
||||||
artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
|
artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ public class DefaultWagonManagerTest
|
||||||
};
|
};
|
||||||
TransferListener listener = new TransferListener();
|
TransferListener listener = new TransferListener();
|
||||||
wagonManager.setDownloadMonitor(listener);
|
wagonManager.setDownloadMonitor(listener);
|
||||||
wagonManager.getArtifact( artifact, repos, false );
|
wagonManager.getArtifact( artifact, repos, listener, false );
|
||||||
assertEquals(1, listener.events.size());
|
assertEquals(1, listener.events.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,347 +0,0 @@
|
||||||
package org.apache.maven.artifact.resolver;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
* or more contributor license agreements. See the NOTICE file
|
|
||||||
* distributed with this work for additional information
|
|
||||||
* regarding copyright ownership. The ASF licenses this file
|
|
||||||
* to you 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 java.io.File;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.apache.maven.artifact.AbstractArtifactComponentTestCase;
|
|
||||||
import org.apache.maven.artifact.Artifact;
|
|
||||||
import org.apache.maven.artifact.manager.WagonManager;
|
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
|
|
||||||
import org.apache.maven.artifact.repository.DefaultArtifactRepository;
|
|
||||||
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
|
||||||
import org.apache.maven.artifact.repository.metadata.Metadata;
|
|
||||||
import org.apache.maven.artifact.repository.metadata.Snapshot;
|
|
||||||
import org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata;
|
|
||||||
import org.apache.maven.artifact.repository.metadata.Versioning;
|
|
||||||
import org.codehaus.plexus.util.FileUtils;
|
|
||||||
|
|
||||||
public class ArtifactUpdatePolicyTest
|
|
||||||
extends AbstractArtifactComponentTestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
private static final String PATH = "org/apache/maven/o/0.0.1-SNAPSHOT/o-0.0.1-SNAPSHOT.jar";
|
|
||||||
|
|
||||||
private static final long TWO_SECONDS = 2 * 1000L;
|
|
||||||
|
|
||||||
private static final long TWO_DAYS = 2 * 86400L * 1000L;
|
|
||||||
|
|
||||||
private DefaultArtifactResolver artifactResolver;
|
|
||||||
|
|
||||||
private List<ArtifactRepository> remoteRepositories;
|
|
||||||
|
|
||||||
private WagonManager wagonManager;
|
|
||||||
|
|
||||||
private TestTransferListener listener;
|
|
||||||
|
|
||||||
private ArtifactRepository localRepository;
|
|
||||||
|
|
||||||
private DefaultArtifactRepository remoteRepository;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String component()
|
|
||||||
{
|
|
||||||
return "artifact-update-policy";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void setUp()
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
super.setUp();
|
|
||||||
|
|
||||||
artifactResolver = (DefaultArtifactResolver) lookup( ArtifactResolver.class );
|
|
||||||
|
|
||||||
remoteRepositories = remoteRepositories();
|
|
||||||
remoteRepository = (DefaultArtifactRepository) remoteRepositories.get( 0 );
|
|
||||||
remoteRepository.setProtocol( "testfile" );
|
|
||||||
remoteRepository.getSnapshots().setChecksumPolicy( ArtifactRepositoryPolicy.CHECKSUM_POLICY_IGNORE );
|
|
||||||
remoteRepository.getReleases().setChecksumPolicy( ArtifactRepositoryPolicy.CHECKSUM_POLICY_IGNORE );
|
|
||||||
FileUtils.deleteDirectory( new File( remoteRepository.getBasedir() ) );
|
|
||||||
|
|
||||||
wagonManager = (WagonManager) lookup( WagonManager.ROLE );
|
|
||||||
listener = new TestTransferListener();
|
|
||||||
wagonManager.setDownloadMonitor( listener );
|
|
||||||
|
|
||||||
localRepository = localRepository();
|
|
||||||
FileUtils.deleteDirectory( new File( localRepository.getBasedir() ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void tearDown()
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
super.tearDown();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void assertTransfers( String[] expected )
|
|
||||||
{
|
|
||||||
StringBuffer expectedSB = new StringBuffer();
|
|
||||||
for ( String anExpected : expected )
|
|
||||||
{
|
|
||||||
expectedSB.append( anExpected ).append( "\n" );
|
|
||||||
}
|
|
||||||
|
|
||||||
List<String> actual = listener.getTransfers();
|
|
||||||
StringBuffer actualSB = new StringBuffer();
|
|
||||||
for ( String anActual : actual )
|
|
||||||
{
|
|
||||||
actualSB.append( anActual ).append( "\n" );
|
|
||||||
}
|
|
||||||
|
|
||||||
assertEquals( expectedSB.toString(), actualSB.toString() );
|
|
||||||
}
|
|
||||||
|
|
||||||
private void deleteFromLocalRepository( Artifact o )
|
|
||||||
{
|
|
||||||
File file = new File( localRepository.getBasedir(), localRepository.pathOf( o ) );
|
|
||||||
file.delete();
|
|
||||||
}
|
|
||||||
|
|
||||||
private Artifact createLocalCopy( String artifactId, String version )
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
Artifact a = createArtifact( artifactId, version );
|
|
||||||
|
|
||||||
createArtifact( a, localRepository );
|
|
||||||
|
|
||||||
SnapshotArtifactRepositoryMetadata snapshotMetadata = new SnapshotArtifactRepositoryMetadata( a );
|
|
||||||
Metadata metadata = new Metadata();
|
|
||||||
Versioning versioning = new Versioning();
|
|
||||||
Snapshot snapshot = new Snapshot();
|
|
||||||
snapshot.setLocalCopy( true );
|
|
||||||
versioning.setSnapshot( snapshot );
|
|
||||||
metadata.setVersioning( versioning );
|
|
||||||
snapshotMetadata.setMetadata( metadata );
|
|
||||||
a.addMetadata( snapshotMetadata );
|
|
||||||
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testForceButNoNewUpdates()
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
Artifact a = createRemoteArtifact( "o", "0.0.1-SNAPSHOT" );
|
|
||||||
createArtifact( a, localRepository );
|
|
||||||
|
|
||||||
artifactResolver.resolveAlways( a, remoteRepositories, localRepository );
|
|
||||||
|
|
||||||
assertTransfers( new String[] { "getIfNewer " + PATH } );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testForceNewUpdate()
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
Artifact a = createRemoteArtifact( "o", "0.0.1-SNAPSHOT" );
|
|
||||||
createArtifact( a, localRepository );
|
|
||||||
setLastModified( a, System.currentTimeMillis() - 2000L, localRepository );
|
|
||||||
|
|
||||||
artifactResolver.resolveAlways( a, remoteRepositories, localRepository );
|
|
||||||
|
|
||||||
assertTransfers( new String[] { "getIfNewer " + PATH, "getTransfer " + PATH, "get " + PATH + ".sha1",
|
|
||||||
"get " + PATH + ".md5" } );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testForceUpdateMissing()
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
Artifact a = createArtifact( "o", "0.0.1-SNAPSHOT" );
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
artifactResolver.resolveAlways( a, remoteRepositories, localRepository );
|
|
||||||
fail( "Expected missing artifact" );
|
|
||||||
}
|
|
||||||
catch ( ArtifactNotFoundException expected )
|
|
||||||
{
|
|
||||||
// expected
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
artifactResolver.resolveAlways( a, remoteRepositories, localRepository );
|
|
||||||
fail( "Expected missing artifact" );
|
|
||||||
}
|
|
||||||
catch ( ArtifactNotFoundException expected )
|
|
||||||
{
|
|
||||||
// expected
|
|
||||||
}
|
|
||||||
|
|
||||||
assertTransfers( new String[] { "get " + PATH, "get " + PATH } );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testSnapshotUpdate()
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
Artifact a = createRemoteArtifact( "o", "0.0.1-SNAPSHOT" );
|
|
||||||
createArtifact( a, localRepository );
|
|
||||||
setLastModified( a, System.currentTimeMillis() - TWO_DAYS, localRepository );
|
|
||||||
|
|
||||||
artifactResolver.resolve( a, remoteRepositories, localRepository );
|
|
||||||
|
|
||||||
assertTransfers( new String[] { "getIfNewer " + PATH, "getTransfer " + PATH, "get " + PATH + ".sha1",
|
|
||||||
"get " + PATH + ".md5" } );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testSnapshotNoUpdates()
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
Artifact a = createRemoteArtifact( "o", "0.0.1-SNAPSHOT" );
|
|
||||||
createArtifact( a, localRepository );
|
|
||||||
long timestamp = System.currentTimeMillis() - TWO_DAYS;
|
|
||||||
setLastModified( a, timestamp, localRepository );
|
|
||||||
setLastModified( a, timestamp, remoteRepository );
|
|
||||||
|
|
||||||
artifactResolver.resolve( a, remoteRepositories, localRepository );
|
|
||||||
|
|
||||||
assertTransfers( new String[] { "getIfNewer " + PATH } );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testSnapshotPolicyCheck()
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
Artifact a = createRemoteArtifact( "o", "0.0.1-SNAPSHOT" );
|
|
||||||
createArtifact( a, localRepository );
|
|
||||||
long timestamp = System.currentTimeMillis() - TWO_SECONDS;
|
|
||||||
setLastModified( a, timestamp, localRepository );
|
|
||||||
setLastModified( a, timestamp, remoteRepository );
|
|
||||||
|
|
||||||
artifactResolver.resolve( a, remoteRepositories, localRepository );
|
|
||||||
|
|
||||||
assertTransfers( new String[] {} );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testLocalCopy()
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
Artifact a = createRemoteArtifact( "o", "0.0.1-SNAPSHOT" );
|
|
||||||
a = createLocalCopy( a.getArtifactId(), a.getVersion() );
|
|
||||||
long timestamp = System.currentTimeMillis() - TWO_DAYS;
|
|
||||||
setLastModified( a, timestamp, localRepository );
|
|
||||||
|
|
||||||
artifactResolver.resolve( a, remoteRepositories, localRepository );
|
|
||||||
|
|
||||||
assertTransfers( new String[] {} );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testForceUpdateLocalCopy()
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
Artifact a = createRemoteArtifact( "o", "0.0.1-SNAPSHOT" );
|
|
||||||
a = createLocalCopy( a.getArtifactId(), a.getVersion() );
|
|
||||||
long timestamp = System.currentTimeMillis() - TWO_SECONDS;
|
|
||||||
setLastModified( a, timestamp, localRepository );
|
|
||||||
|
|
||||||
artifactResolver.resolveAlways( a, remoteRepositories, localRepository );
|
|
||||||
|
|
||||||
assertTransfers( new String[] { "getIfNewer " + PATH, "getTransfer " + PATH, "get " + PATH + ".sha1",
|
|
||||||
"get " + PATH + ".md5" } );
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setLastModified( Artifact a, long timestamp, ArtifactRepository repository )
|
|
||||||
{
|
|
||||||
File file = new File( repository.getBasedir(), repository.pathOf( a ) );
|
|
||||||
file.setLastModified( timestamp );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testSnapshotUpdatePolicyForMissingArtifacts()
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
Artifact j = createArtifact( "o", "0.0.1-SNAPSHOT" );
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
artifactResolver.resolve( j, remoteRepositories, localRepository );
|
|
||||||
fail( "Expected missing artifact" );
|
|
||||||
}
|
|
||||||
catch ( ArtifactNotFoundException expected )
|
|
||||||
{
|
|
||||||
// expected
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
artifactResolver.resolve( j, remoteRepositories, localRepository );
|
|
||||||
fail( "Expected missing artifact" );
|
|
||||||
}
|
|
||||||
catch ( ArtifactNotFoundException expected )
|
|
||||||
{
|
|
||||||
// expected
|
|
||||||
}
|
|
||||||
|
|
||||||
assertTransfers( new String[] { "get org/apache/maven/o/0.0.1-SNAPSHOT/o-0.0.1-SNAPSHOT.jar" } );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testResolutionOfArtifactsDeletedFromLocalRepo()
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
Artifact j = createRemoteArtifact( "j", "0.0.1-SNAPSHOT" );
|
|
||||||
|
|
||||||
artifactResolver.resolve( j, remoteRepositories, localRepository() );
|
|
||||||
|
|
||||||
// sanity check
|
|
||||||
assertTrue( j.isResolved() );
|
|
||||||
assertTrue( j.getFile().canRead() );
|
|
||||||
|
|
||||||
j.getFile().delete();
|
|
||||||
|
|
||||||
j = createArtifact( j.getArtifactId(), j.getVersion() );
|
|
||||||
artifactResolver.resolve( j, remoteRepositories, localRepository() );
|
|
||||||
|
|
||||||
assertTrue( j.isResolved() );
|
|
||||||
assertTrue( j.getFile().canRead() );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testMultipleRemoteRepositories()
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
ArtifactRepository remoteRepository1 = remoteRepository( "remote-repository1" );
|
|
||||||
ArtifactRepository remoteRepository2 = remoteRepository( "remote-repository2" );
|
|
||||||
ArrayList<ArtifactRepository> remoteRepositories = new ArrayList<ArtifactRepository>();
|
|
||||||
remoteRepositories.add( remoteRepository1 );
|
|
||||||
remoteRepositories.add( remoteRepository2 );
|
|
||||||
|
|
||||||
Artifact a = createArtifact( "a", "0.0.0-SNAPSHOT" );
|
|
||||||
createArtifact( a, remoteRepository2 );
|
|
||||||
|
|
||||||
artifactResolver.resolve( a, remoteRepositories, localRepository );
|
|
||||||
assertTrue( a.isResolved() );
|
|
||||||
}
|
|
||||||
|
|
||||||
private ArtifactRepository remoteRepository( String name )
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
String path = "target/test-classes/repositories/" + component() + "/" + name;
|
|
||||||
|
|
||||||
File f = new File( getBasedir(), path );
|
|
||||||
|
|
||||||
FileUtils.deleteDirectory( f );
|
|
||||||
|
|
||||||
ArtifactRepositoryLayout repoLayout =
|
|
||||||
(ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "legacy" );
|
|
||||||
|
|
||||||
return new DefaultArtifactRepository( name, "file://" + f.getPath(), repoLayout,
|
|
||||||
new ArtifactRepositoryPolicy(), new ArtifactRepositoryPolicy() );
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -423,8 +423,6 @@ public class DefaultMavenExecutionRequestPopulator
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
repositorySystem.setDownloadMonitor( request.getTransferListener() );
|
|
||||||
|
|
||||||
repositorySystem.setOnline( true );
|
repositorySystem.setOnline( true );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -252,7 +252,9 @@ public class DefaultMavenProjectBuilder
|
||||||
pomArtifact.setFile( pomFile );
|
pomArtifact.setFile( pomFile );
|
||||||
|
|
||||||
ArtifactResolutionRequest request = new ArtifactResolutionRequest().setArtifact( pomArtifact ).setArtifactDependencies( project.getDependencyArtifacts() )
|
ArtifactResolutionRequest request = new ArtifactResolutionRequest().setArtifact( pomArtifact ).setArtifactDependencies( project.getDependencyArtifacts() )
|
||||||
.setLocalRepository( configuration.getLocalRepository() ).setRemoteRepostories( project.getRemoteArtifactRepositories() ).setManagedVersionMap( project.getManagedVersionMap() )
|
.setLocalRepository( configuration.getLocalRepository() )
|
||||||
|
.setRemoteRepostories( project.getRemoteArtifactRepositories() )
|
||||||
|
.setManagedVersionMap( project.getManagedVersionMap() )
|
||||||
.setMetadataSource( repositorySystem );
|
.setMetadataSource( repositorySystem );
|
||||||
|
|
||||||
ArtifactResolutionResult result = repositorySystem.resolve( request );
|
ArtifactResolutionResult result = repositorySystem.resolve( request );
|
||||||
|
|
|
@ -94,8 +94,6 @@ public class LegacyMavenRepositorySystem
|
||||||
@Requirement
|
@Requirement
|
||||||
private Logger logger;
|
private Logger logger;
|
||||||
|
|
||||||
private TransferListener downloadMonitor;
|
|
||||||
|
|
||||||
private Map<String, ProxyInfo> proxies = new HashMap<String, ProxyInfo>();
|
private Map<String, ProxyInfo> proxies = new HashMap<String, ProxyInfo>();
|
||||||
|
|
||||||
private Map<String, AuthenticationInfo> authenticationInfoMap = new HashMap<String, AuthenticationInfo>();
|
private Map<String, AuthenticationInfo> authenticationInfoMap = new HashMap<String, AuthenticationInfo>();
|
||||||
|
@ -386,7 +384,7 @@ public class LegacyMavenRepositorySystem
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArtifactRepository createRepository( String url, String repositoryId )
|
private ArtifactRepository createRepository( String url, String repositoryId )
|
||||||
{
|
{
|
||||||
// snapshots vs releases
|
// snapshots vs releases
|
||||||
// offline = to turning the update policy off
|
// offline = to turning the update policy off
|
||||||
|
@ -405,7 +403,7 @@ public class LegacyMavenRepositorySystem
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArtifactResolutionResult resolve( ArtifactResolutionRequest request )
|
public ArtifactResolutionResult resolve( ArtifactResolutionRequest request )
|
||||||
{
|
{
|
||||||
return artifactResolver.resolve( request );
|
return artifactResolver.resolve( request );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -419,11 +417,6 @@ public class LegacyMavenRepositorySystem
|
||||||
return artifactResolver.isOnline();
|
return artifactResolver.isOnline();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDownloadMonitor( TransferListener downloadMonitor )
|
|
||||||
{
|
|
||||||
this.downloadMonitor = downloadMonitor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addProxy( String protocol, String host, int port, String username, String password, String nonProxyHosts )
|
public void addProxy( String protocol, String host, int port, String username, String password, String nonProxyHosts )
|
||||||
{
|
{
|
||||||
ProxyInfo proxyInfo = new ProxyInfo();
|
ProxyInfo proxyInfo = new ProxyInfo();
|
||||||
|
|
|
@ -73,10 +73,6 @@ public interface MavenRepositorySystem
|
||||||
ArtifactRepository createLocalRepository( String url, String repositoryId )
|
ArtifactRepository createLocalRepository( String url, String repositoryId )
|
||||||
throws IOException;
|
throws IOException;
|
||||||
|
|
||||||
ArtifactRepository createRepository( String url, String repositoryId );
|
|
||||||
|
|
||||||
// Artifact resolution
|
|
||||||
|
|
||||||
//MetadataResolutionResult resolveMetadata( MetadataResolutionRequest request );
|
//MetadataResolutionResult resolveMetadata( MetadataResolutionRequest request );
|
||||||
|
|
||||||
ArtifactResolutionResult resolve( ArtifactResolutionRequest request );
|
ArtifactResolutionResult resolve( ArtifactResolutionRequest request );
|
||||||
|
@ -102,8 +98,6 @@ public interface MavenRepositorySystem
|
||||||
|
|
||||||
boolean isOnline();
|
boolean isOnline();
|
||||||
|
|
||||||
void setDownloadMonitor( TransferListener downloadMonitor );
|
|
||||||
|
|
||||||
void addProxy( String protocol, String host, int port, String username, String password, String nonProxyHosts );
|
void addProxy( String protocol, String host, int port, String username, String password, String nonProxyHosts );
|
||||||
|
|
||||||
void addAuthenticationInfo( String repositoryId, String username, String password, String privateKey, String passphrase );
|
void addAuthenticationInfo( String repositoryId, String username, String password, String privateKey, String passphrase );
|
||||||
|
|
Loading…
Reference in New Issue