brett       2005/03/24 08:03:51

  Modified:    maven-artifact/src/main/java/org/apache/maven/artifact/metadata
                        SnapshotArtifactMetadata.java
               maven-artifact/src/main/java/org/apache/maven/artifact/resolver
                        DefaultArtifactResolver.java
               maven-artifact/src/main/java/org/apache/maven/artifact/transform
                        SnapshotTransformation.java
  Log:
  bug fixes, but still not completely fixed
  
  Revision  Changes    Path
  1.6       +11 -8     
maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/metadata/SnapshotArtifactMetadata.java
  
  Index: SnapshotArtifactMetadata.java
  ===================================================================
  RCS file: 
/home/cvs/maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/metadata/SnapshotArtifactMetadata.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- SnapshotArtifactMetadata.java     24 Mar 2005 14:52:25 -0000      1.5
  +++ SnapshotArtifactMetadata.java     24 Mar 2005 16:03:51 -0000      1.6
  @@ -113,15 +113,18 @@
       public String getVersion()
       {
           String version = artifact.getVersion();
  -        if ( version != null )
  +        if ( timestamp != null )
           {
  -            version = StringUtils.replace( version, "SNAPSHOT", timestamp );
  -        }
  -        else
  -        {
  -            version = timestamp;
  +            if ( version != null )
  +            {
  +                version = StringUtils.replace( version, "SNAPSHOT", 
timestamp ) + "-" + buildNumber;
  +            }
  +            else
  +            {
  +                version = timestamp + "-" + buildNumber;
  +            }
           }
  -        return version + "-" + buildNumber;
  +        return version;
       }
   
       public void retrieveFromRemoteRepository( ArtifactRepository 
remoteRepository, WagonManager wagonManager )
  
  
  
  1.31      +10 -3     
maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java
  
  Index: DefaultArtifactResolver.java
  ===================================================================
  RCS file: 
/home/cvs/maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- DefaultArtifactResolver.java      24 Mar 2005 14:52:25 -0000      1.30
  +++ DefaultArtifactResolver.java      24 Mar 2005 16:03:51 -0000      1.31
  @@ -214,12 +214,19 @@
               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?
  -            resolve( (Artifact) i.next(), remoteRepositories, 
localRepository );
  +            Object key = i.next();
  +            resolvedArtifacts.put( key, resolve( (Artifact) 
collectedArtifacts.get( key ), remoteRepositories,
  +                                                 localRepository ) );
           }
   
  +        collectedArtifacts.clear();
  +        collectedArtifacts.putAll( resolvedArtifacts );
  +
           return artifactResolutionResult;
       }
   
  
  
  
  1.9       +35 -19    
maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/transform/SnapshotTransformation.java
  
  Index: SnapshotTransformation.java
  ===================================================================
  RCS file: 
/home/cvs/maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/transform/SnapshotTransformation.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- SnapshotTransformation.java       24 Mar 2005 14:52:25 -0000      1.8
  +++ SnapshotTransformation.java       24 Mar 2005 16:03:51 -0000      1.9
  @@ -49,12 +49,17 @@
                                            ArtifactRepository localRepository )
           throws ArtifactMetadataRetrievalException
       {
  -        if ( isSnapshot( artifact ) && !alreadyResolved( artifact ) )
  +        if ( isSnapshot( artifact ) )
           {
               // TODO: this mostly works, however...
               //  - 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
               //  - 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;
               try
  @@ -70,32 +75,37 @@
                   throw new ArtifactMetadataRetrievalException( "Error reading 
local metadata", e );
               }
   
  -            boolean foundRemote = false;
  -            for ( Iterator i = remoteRepositories.iterator(); i.hasNext(); )
  +            if ( !alreadyResolved( artifact ) )
               {
  -                ArtifactRepository remoteRepository = (ArtifactRepository) 
i.next();
  +                boolean foundRemote = false;
  +                for ( Iterator i = remoteRepositories.iterator(); 
i.hasNext(); )
  +                {
  +                    ArtifactRepository remoteRepository = 
(ArtifactRepository) i.next();
   
  -                SnapshotArtifactMetadata remoteMetadata = 
SnapshotArtifactMetadata.createRemoteSnapshotMetadata(
  -                    artifact );
  -                remoteMetadata.retrieveFromRemoteRepository( 
remoteRepository, wagonManager );
  +                    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
  +                        artifact.setRepository( remoteRepository );
  +
  +                        localMetadata = remoteMetadata;
  +                        foundRemote = true;
  +                    }
  +                }
   
  -                if ( remoteMetadata.compareTo( localMetadata ) > 0 )
  +                if ( foundRemote )
                   {
  -                    // TODO: investigate transforming this in place, in 
which case resolve can return void
  -                    artifact = createArtifactCopy( artifact, remoteMetadata 
);
  -                    artifact.setRepository( remoteRepository );
  -
  -                    localMetadata = remoteMetadata;
  -                    foundRemote = true;
  +                    artifact.addMetadata( localMetadata );
                   }
               }
   
  -            if ( foundRemote )
  -            {
  -                artifact.addMetadata( localMetadata );
  -            }
  -*/
  +            artifact = createArtifactCopy( artifact, localMetadata );
  +
               resolvedArtifactCache.add( getCacheKey( artifact ) );
  +*/
           }
           return artifact;
       }
  @@ -140,15 +150,21 @@
   
       private Artifact createArtifactCopy( Artifact artifact, 
SnapshotArtifactMetadata metadata )
       {
  +        ArtifactRepository oldRepository = artifact.getRepository();
           List list = artifact.getMetadataList();
  +
           artifact = new DefaultArtifact( artifact.getGroupId(), 
artifact.getArtifactId(), metadata.getVersion(),
                                           artifact.getScope(), 
artifact.getType(), artifact.getClassifier() );
  +
           for ( Iterator i = list.iterator(); i.hasNext(); )
           {
               ArtifactMetadata m = (ArtifactMetadata) i.next();
               m.setArtifact( artifact );
               artifact.addMetadata( m );
           }
  +
  +        artifact.setRepository( oldRepository );
  +
           return artifact;
       }
   
  
  
  

Reply via email to