artifact.setResolved( true );
return;
}
ArtifactRepository localRepository = request.getLocalRepository();
List<ArtifactRepository> remoteRepositories = request.getRemoteRepositories();
if ( !artifact.isResolved() )
{
// ----------------------------------------------------------------------
// Check for the existence of the artifact in the specified local
// ArtifactRepository. If it is present then simply return as the
// request for resolution has been satisfied.
// ----------------------------------------------------------------------
artifact = localRepository.find( artifact );
if ( artifact.isResolved() )
{
return;
}
transformationManager.transformForResolve( artifact, request );
destination = artifact.getFile();
if ( !request.isOffline() && ( force || !destination.exists() || isMutable( artifact ) ) )
{
try
{
if ( artifact.getRepository() != null )
{
// the transformations discovered the artifact - so use it exclusively
wagonManager.getArtifact( artifact, artifact.getRepository(), downloadMonitor,
request.isForceUpdate() );
}
else
{
wagonManager.getArtifact( artifact, remoteRepositories, downloadMonitor,
request.isForceUpdate() );
}
if ( localRepositoryMaintainer != null )
{
LocalRepositoryMaintainerEvent event =
new DefaultLocalRepositoryMaintainerEvent( localRepository, artifact, null );
localRepositoryMaintainer.artifactDownloaded( event );
}
}
catch ( ResourceDoesNotExistException e )
{
throw new ArtifactNotFoundException( e.getMessage(), artifact, remoteRepositories, e );
}
catch ( TransferFailedException e )
{
throw new ArtifactResolutionException( e.getMessage(), artifact, remoteRepositories, e );
}
}
if ( destination.exists() )
{
artifact.setResolved( true );
}
else
{
if ( request.isOffline() )
{
throw new ArtifactResolutionException( "The repository system is offline"
+ " and the requested artifact is not locally available at " + destination, artifact,
remoteRepositories );
}
else
{
throw new ArtifactResolutionException( "Failed to resolve artifact, possibly due to a "
+ "repository list that is not appropriately equipped for this artifact's metadata.", artifact,
remoteRepositories );
}
}
// 1.0-SNAPSHOT
//
// 1) pom = 1.0-SNAPSHOT
// 2) pom = 1.0-yyyymmdd.hhmmss
// 3) baseVersion = 1.0-SNAPSHOT
if ( artifact.isSnapshot() && isTimestamped( artifact ) )
{
String version = artifact.getVersion();
// 1.0-SNAPSHOT
artifact.selectVersion( artifact.getBaseVersion() );
// Make a file with a 1.0-SNAPSHOT format
File copy = new File( localRepository.getBasedir(), localRepository.pathOf( artifact ) );
// if the timestamped version was resolved or the copy doesn't exist then copy a version
// of the file like 1.0-SNAPSHOT. Even if there is a timestamped version the non-timestamped
// version will be created.
if ( !copy.exists() || copy.lastModified() != destination.lastModified()