bug fixes, but still not completely fixed

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163693 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-03-24 16:03:51 +00:00
parent 004c6cbdf3
commit b529deb2df
3 changed files with 56 additions and 30 deletions

View File

@ -113,15 +113,18 @@ private File getLocalRepositoryLocation( ArtifactRepository localRepository )
public String getVersion() public String getVersion()
{ {
String version = artifact.getVersion(); String version = artifact.getVersion();
if ( version != null ) if ( timestamp != null )
{ {
version = StringUtils.replace( version, "SNAPSHOT", timestamp ); if ( version != null )
{
version = StringUtils.replace( version, "SNAPSHOT", timestamp ) + "-" + buildNumber;
}
else
{
version = timestamp + "-" + buildNumber;
}
} }
else return version;
{
version = timestamp;
}
return version + "-" + buildNumber;
} }
public void retrieveFromRemoteRepository( ArtifactRepository remoteRepository, WagonManager wagonManager ) public void retrieveFromRemoteRepository( ArtifactRepository remoteRepository, WagonManager wagonManager )

View File

@ -214,12 +214,19 @@ public ArtifactResolutionResult resolveTransitively( Set artifacts, List remoteR
throw new ArtifactResolutionException( "Error transitively resolving artifacts: ", e ); throw new ArtifactResolutionException( "Error transitively resolving artifacts: ", e );
} }
for ( Iterator i = artifactResolutionResult.getArtifacts().values().iterator(); i.hasNext(); ) // TODO: this is unclean, but necessary as long as resolve may return a different artifact
Map collectedArtifacts = artifactResolutionResult.getArtifacts();
Map resolvedArtifacts = new HashMap( collectedArtifacts.size() );
for ( Iterator i = collectedArtifacts.keySet().iterator(); i.hasNext(); )
{ {
// TODO: resolve may modify artifacts, do we need to get the new list? Object key = i.next();
resolve( (Artifact) i.next(), remoteRepositories, localRepository ); resolvedArtifacts.put( key, resolve( (Artifact) collectedArtifacts.get( key ), remoteRepositories,
localRepository ) );
} }
collectedArtifacts.clear();
collectedArtifacts.putAll( resolvedArtifacts );
return artifactResolutionResult; return artifactResolutionResult;
} }

View File

@ -49,12 +49,17 @@ public Artifact transformForResolve( Artifact artifact, List remoteRepositories,
ArtifactRepository localRepository ) ArtifactRepository localRepository )
throws ArtifactMetadataRetrievalException throws ArtifactMetadataRetrievalException
{ {
if ( isSnapshot( artifact ) && !alreadyResolved( artifact ) ) if ( isSnapshot( artifact ) )
{ {
// TODO: this mostly works, however... // TODO: this mostly works, however...
// - poms and jars are different, so both are checked individually // - poms and jars are different, so both are checked individually
// - when a pom is downloaded, it prevents the JAR getting downloaded because of the timestamp // - when a pom is downloaded, it prevents the JAR getting downloaded because of the timestamp
// - need to gather first, group them all up by groupId/artifactId, then go after them // - need to gather first, group them all up by groupId/artifactId, then go after them
// - alternatively, keep the timestamp when downloading (as is done here), and use the SNAPSHOT file for install
// - however, there is no mechanism to flip back and forward, and presently it keeps looking for 2.0-TIMESTAMP-0 instead as that is in the build file
// - we definitely need the manual/daily check as this is quite slow given the large number of snapshots inside m2 presently
/* /*
SnapshotArtifactMetadata localMetadata; SnapshotArtifactMetadata localMetadata;
try try
@ -70,32 +75,37 @@ public Artifact transformForResolve( Artifact artifact, List remoteRepositories,
throw new ArtifactMetadataRetrievalException( "Error reading local metadata", e ); throw new ArtifactMetadataRetrievalException( "Error reading local metadata", e );
} }
boolean foundRemote = false; if ( !alreadyResolved( artifact ) )
for ( Iterator i = remoteRepositories.iterator(); i.hasNext(); )
{ {
ArtifactRepository remoteRepository = (ArtifactRepository) i.next(); boolean foundRemote = false;
for ( Iterator i = remoteRepositories.iterator(); i.hasNext(); )
SnapshotArtifactMetadata remoteMetadata = SnapshotArtifactMetadata.createRemoteSnapshotMetadata(
artifact );
remoteMetadata.retrieveFromRemoteRepository( remoteRepository, wagonManager );
if ( remoteMetadata.compareTo( localMetadata ) > 0 )
{ {
// TODO: investigate transforming this in place, in which case resolve can return void ArtifactRepository remoteRepository = (ArtifactRepository) i.next();
artifact = createArtifactCopy( artifact, remoteMetadata );
artifact.setRepository( remoteRepository );
localMetadata = remoteMetadata; SnapshotArtifactMetadata remoteMetadata = SnapshotArtifactMetadata.createRemoteSnapshotMetadata(
foundRemote = true; artifact );
remoteMetadata.retrieveFromRemoteRepository( remoteRepository, wagonManager );
if ( remoteMetadata.compareTo( localMetadata ) > 0 )
{
// TODO: investigate transforming this in place, in which case resolve can return void
artifact.setRepository( remoteRepository );
localMetadata = remoteMetadata;
foundRemote = true;
}
}
if ( foundRemote )
{
artifact.addMetadata( localMetadata );
} }
} }
if ( foundRemote ) artifact = createArtifactCopy( artifact, localMetadata );
{
artifact.addMetadata( localMetadata );
}
*/
resolvedArtifactCache.add( getCacheKey( artifact ) ); resolvedArtifactCache.add( getCacheKey( artifact ) );
*/
} }
return artifact; return artifact;
} }
@ -140,15 +150,21 @@ public Artifact transformForDeployment( Artifact artifact, ArtifactRepository re
private Artifact createArtifactCopy( Artifact artifact, SnapshotArtifactMetadata metadata ) private Artifact createArtifactCopy( Artifact artifact, SnapshotArtifactMetadata metadata )
{ {
ArtifactRepository oldRepository = artifact.getRepository();
List list = artifact.getMetadataList(); List list = artifact.getMetadataList();
artifact = new DefaultArtifact( artifact.getGroupId(), artifact.getArtifactId(), metadata.getVersion(), artifact = new DefaultArtifact( artifact.getGroupId(), artifact.getArtifactId(), metadata.getVersion(),
artifact.getScope(), artifact.getType(), artifact.getClassifier() ); artifact.getScope(), artifact.getType(), artifact.getClassifier() );
for ( Iterator i = list.iterator(); i.hasNext(); ) for ( Iterator i = list.iterator(); i.hasNext(); )
{ {
ArtifactMetadata m = (ArtifactMetadata) i.next(); ArtifactMetadata m = (ArtifactMetadata) i.next();
m.setArtifact( artifact ); m.setArtifact( artifact );
artifact.addMetadata( m ); artifact.addMetadata( m );
} }
artifact.setRepository( oldRepository );
return artifact; return artifact;
} }