[MNG-4361] [regression] command line option "-update-snapshots" does not work

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@816002 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2009-09-16 23:07:41 +00:00
parent b98795ecb9
commit 5d459b0c0e
12 changed files with 109 additions and 2 deletions

View File

@ -33,6 +33,8 @@ public class DefaultRepositoryRequest
private boolean offline; private boolean offline;
private boolean forceUpdate;
private ArtifactRepository localRepository; private ArtifactRepository localRepository;
private List<ArtifactRepository> remoteRepositories; private List<ArtifactRepository> remoteRepositories;
@ -58,6 +60,7 @@ public class DefaultRepositoryRequest
setRemoteRepositories( repositoryRequest.getRemoteRepositories() ); setRemoteRepositories( repositoryRequest.getRemoteRepositories() );
setOffline( repositoryRequest.isOffline() ); setOffline( repositoryRequest.isOffline() );
setCache( repositoryRequest.getCache() ); setCache( repositoryRequest.getCache() );
setForceUpdate( repositoryRequest.isForceUpdate() );
} }
public boolean isOffline() public boolean isOffline()
@ -72,6 +75,18 @@ public class DefaultRepositoryRequest
return this; return this;
} }
public boolean isForceUpdate()
{
return forceUpdate;
}
public DefaultRepositoryRequest setForceUpdate( boolean forceUpdate )
{
this.forceUpdate = forceUpdate;
return this;
}
public ArtifactRepository getLocalRepository() public ArtifactRepository getLocalRepository()
{ {
return localRepository; return localRepository;

View File

@ -44,6 +44,24 @@ public interface RepositoryRequest
*/ */
RepositoryRequest setOffline( boolean offline ); RepositoryRequest setOffline( boolean offline );
/**
* Indicates whether remote repositories should be re-checked for updated artifacts/metadata regardless of their
* configured update policy.
*
* @return {@code true} if remote repositories should be re-checked for updated artifacts/metadata, {@code false}
* otherwise.
*/
boolean isForceUpdate();
/**
* Enables/disabled forced checks for updated artifacts/metadata on remote repositories.
*
* @param forceUpdate {@code true} to forcibly check the remote repositories for updated artifacts/metadata, {@code
* false} to use the update policy configured on each repository.
* @return This request, never {@code null}.
*/
RepositoryRequest setForceUpdate( boolean forceUpdate );
/** /**
* Gets the local repository to use. * Gets the local repository to use.
* *

View File

@ -117,7 +117,8 @@ public class DefaultRepositoryMetadataManager
new File( localRepository.getBasedir(), localRepository.pathOfLocalRepositoryMetadata( metadata, new File( localRepository.getBasedir(), localRepository.pathOfLocalRepositoryMetadata( metadata,
repository ) ); repository ) );
if ( updateCheckManager.isUpdateRequired( metadata, repository, file ) ) if ( ( policy.isEnabled() && request.isForceUpdate() )
|| updateCheckManager.isUpdateRequired( metadata, repository, file ) )
{ {
getLogger().info( metadata.getKey() + ": checking for updates from " + repository.getId() ); getLogger().info( metadata.getKey() + ": checking for updates from " + repository.getId() );
try try

View File

@ -72,6 +72,8 @@ public class ArtifactResolutionRequest
private boolean offline; private boolean offline;
private boolean forceUpdate;
public ArtifactResolutionRequest() public ArtifactResolutionRequest()
{ {
// nothing here // nothing here
@ -83,6 +85,7 @@ public class ArtifactResolutionRequest
setRemoteRepositories( request.getRemoteRepositories() ); setRemoteRepositories( request.getRemoteRepositories() );
setCache( request.getCache() ); setCache( request.getCache() );
setOffline( request.isOffline() ); setOffline( request.isOffline() );
setForceUpdate( request.isForceUpdate() );
} }
public Artifact getArtifact() public Artifact getArtifact()
@ -272,4 +275,16 @@ public class ArtifactResolutionRequest
return this; return this;
} }
public boolean isForceUpdate()
{
return forceUpdate;
}
public ArtifactResolutionRequest setForceUpdate( boolean forceUpdate )
{
this.forceUpdate = forceUpdate;
return this;
}
} }

View File

@ -124,4 +124,16 @@ public class DefaultMetadataResolutionRequest
return this; return this;
} }
public boolean isForceUpdate()
{
return repositoryRequest.isForceUpdate();
}
public DefaultMetadataResolutionRequest setForceUpdate( boolean forceUpdate )
{
repositoryRequest.setForceUpdate( forceUpdate );
return this;
}
} }

View File

@ -133,6 +133,7 @@ public class DefaultProjectDependenciesResolver
.setResolutionFilter( resolutionScopeFilter ) .setResolutionFilter( resolutionScopeFilter )
.setLocalRepository( session.getLocalRepository() ) .setLocalRepository( session.getLocalRepository() )
.setOffline( session.isOffline() ) .setOffline( session.isOffline() )
.setForceUpdate( session.getRequest().isUpdateSnapshots() )
.setCache( session.getRepositoryCache() ); .setCache( session.getRepositoryCache() );
// FIXME setTransferListener // FIXME setTransferListener

View File

@ -164,4 +164,16 @@ public class DefaultPluginPrefixRequest
return this; return this;
} }
public boolean isForceUpdate()
{
return repositoryRequest.isForceUpdate();
}
public DefaultPluginPrefixRequest setForceUpdate( boolean forceUpdate )
{
repositoryRequest.setForceUpdate( forceUpdate );
return this;
}
} }

View File

@ -131,4 +131,16 @@ public class DefaultPluginVersionRequest
return this; return this;
} }
public boolean isForceUpdate()
{
return repositoryRequest.isForceUpdate();
}
public DefaultPluginVersionRequest setForceUpdate( boolean forceUpdate )
{
repositoryRequest.setForceUpdate( forceUpdate );
return this;
}
} }

View File

@ -133,6 +133,7 @@ public class DefaultProjectBuilder
.setLocalRepository( configuration.getLocalRepository() ) .setLocalRepository( configuration.getLocalRepository() )
.setRemoteRepositories( project.getRemoteArtifactRepositories() ) .setRemoteRepositories( project.getRemoteArtifactRepositories() )
.setOffline( configuration.isOffline() ) .setOffline( configuration.isOffline() )
.setForceUpdate( configuration.isForceUpdate() )
.setManagedVersionMap( project.getManagedVersionMap() ); .setManagedVersionMap( project.getManagedVersionMap() );
// FIXME setTransferListener // FIXME setTransferListener
@ -195,7 +196,8 @@ public class DefaultProjectBuilder
.setCache( configuration.getRepositoryCache() ) .setCache( configuration.getRepositoryCache() )
.setLocalRepository( configuration.getLocalRepository() ) .setLocalRepository( configuration.getLocalRepository() )
.setRemoteRepositories( configuration.getRemoteRepositories() ) .setRemoteRepositories( configuration.getRemoteRepositories() )
.setOffline( configuration.isOffline() ); .setOffline( configuration.isOffline() )
.setForceUpdate( configuration.isForceUpdate() );
// FIXME setTransferListener // FIXME setTransferListener
ArtifactResolutionResult result = repositorySystem.resolve( request ); ArtifactResolutionResult result = repositorySystem.resolve( request );

View File

@ -39,6 +39,8 @@ public class DefaultProjectBuildingRequest
private boolean offline; private boolean offline;
private boolean forceUpdate;
private RepositoryCache repositoryCache; private RepositoryCache repositoryCache;
private ArtifactRepository localRepository; private ArtifactRepository localRepository;
@ -112,6 +114,18 @@ public class DefaultProjectBuildingRequest
return offline; return offline;
} }
public boolean isForceUpdate()
{
return forceUpdate;
}
public ProjectBuildingRequest setForceUpdate( boolean forceUpdate )
{
this.forceUpdate = forceUpdate;
return this;
}
public ProjectBuildingRequest setRepositoryCache( RepositoryCache repositoryCache ) public ProjectBuildingRequest setRepositoryCache( RepositoryCache repositoryCache )
{ {
this.repositoryCache = repositoryCache; this.repositoryCache = repositoryCache;

View File

@ -38,6 +38,10 @@ public interface ProjectBuildingRequest
boolean isOffline(); boolean isOffline();
ProjectBuildingRequest setForceUpdate( boolean forceUpdate );
boolean isForceUpdate();
ProjectBuildingRequest setRepositoryCache( RepositoryCache repositoryCache ); ProjectBuildingRequest setRepositoryCache( RepositoryCache repositoryCache );
RepositoryCache getRepositoryCache(); RepositoryCache getRepositoryCache();

View File

@ -525,6 +525,7 @@ public class MavenMetadataSource
configuration.setLocalRepository( repositoryRequest.getLocalRepository() ); configuration.setLocalRepository( repositoryRequest.getLocalRepository() );
configuration.setRemoteRepositories( repositoryRequest.getRemoteRepositories() ); configuration.setRemoteRepositories( repositoryRequest.getRemoteRepositories() );
configuration.setOffline( repositoryRequest.isOffline() ); configuration.setOffline( repositoryRequest.isOffline() );
configuration.setForceUpdate( repositoryRequest.isForceUpdate() );
configuration.setValidationLevel( ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL ); configuration.setValidationLevel( ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL );
configuration.setProcessPlugins( false ); configuration.setProcessPlugins( false );
configuration.setSystemProperties( System.getProperties() ); configuration.setSystemProperties( System.getProperties() );