maven-m2-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject cvs commit: maven-components/maven-artifact/src/test/java/org/apache/maven/artifact/resolver ArtifactResolverTest.java NewLayoutArtifactResolverTest.java
Date Tue, 29 Mar 2005 16:41:13 GMT
brett       2005/03/29 08:41:13

  Modified:    maven-core/src/main/java/org/apache/maven/artifact/metadata
                        MavenMetadata.java
               maven-core/src/main/java/org/apache/maven/artifact
                        MavenMetadataSource.java
               maven-core/src/main/java/org/apache/maven/project
                        DefaultMavenProjectBuilder.java MavenProject.java
               maven-core/src/test/java/org/apache/maven/project
                        ProjectClasspathArtifactResolver.java
               maven-artifact/src/main/java/org/apache/maven/artifact/deployer
                        DefaultArtifactDeployer.java
               maven-artifact/src/main/java/org/apache/maven/artifact/installer
                        DefaultArtifactInstaller.java
               maven-artifact/src/main/java/org/apache/maven/artifact/metadata
                        SnapshotArtifactMetadata.java
               maven-artifact/src/main/java/org/apache/maven/artifact/resolver
                        ArtifactResolver.java DefaultArtifactResolver.java
               maven-artifact/src/main/java/org/apache/maven/artifact/transform
                        ArtifactTransformation.java
                        SnapshotTransformation.java
               maven-artifact/src/main/java/org/apache/maven/artifact
                        Artifact.java DefaultArtifact.java
               maven-artifact/src/test/java/org/apache/maven/artifact/resolver
                        ArtifactResolverTest.java
  Removed:     maven-artifact/src/test/java/org/apache/maven/artifact/resolver
                        NewLayoutArtifactResolverTest.java
  Log:
  change resolve() methods to not return Artifact - but instead modify the original. Artifact
is immutable except for version so it is safe - but will it cost flexibility later. Currently,
this makes it much simpler as less copying vigilance is required.
  This has ironed out most wrinkles. Still need to implement the snapshot checking cache,
and special case the use of installed snapshots over deployed ones.
  
  Revision  Changes    Path
  1.4       +7 -2      maven-components/maven-core/src/main/java/org/apache/maven/artifact/metadata/MavenMetadata.java
  
  Index: MavenMetadata.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/artifact/metadata/MavenMetadata.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- MavenMetadata.java	29 Mar 2005 15:44:27 -0000	1.3
  +++ MavenMetadata.java	29 Mar 2005 16:41:13 -0000	1.4
  @@ -42,10 +42,15 @@
   
       public MavenMetadata( Artifact artifact, File file )
       {
  -        super( artifact, artifact.getArtifactId() + "-" + artifact.getVersion() + ".pom"
);
  +        super( artifact, null );
           this.file = file;
       }
   
  +    public String getFilename()
  +    {
  +        return getArtifact().getArtifactId() + "-" + getArtifact().getVersion() + ".pom";
  +    }
  +
       public void storeInLocalRepository( ArtifactRepository localRepository )
           throws ArtifactMetadataRetrievalException
       {
  
  
  
  1.25      +2 -2      maven-components/maven-core/src/main/java/org/apache/maven/artifact/MavenMetadataSource.java
  
  Index: MavenMetadataSource.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/artifact/MavenMetadataSource.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- MavenMetadataSource.java	24 Mar 2005 05:01:05 -0000	1.24
  +++ MavenMetadataSource.java	29 Mar 2005 16:41:13 -0000	1.25
  @@ -92,7 +92,7 @@
   
               try
               {
  -                metadataArtifact = artifactResolver.resolve( metadataArtifact, remoteRepositories,
localRepository );
  +                artifactResolver.resolve( metadataArtifact, remoteRepositories, localRepository
);
               }
               catch ( ArtifactResolutionException e )
               {
  
  
  
  1.60      +1 -1      maven-components/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
  
  Index: DefaultMavenProjectBuilder.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java,v
  retrieving revision 1.59
  retrieving revision 1.60
  diff -u -r1.59 -r1.60
  --- DefaultMavenProjectBuilder.java	29 Mar 2005 07:02:29 -0000	1.59
  +++ DefaultMavenProjectBuilder.java	29 Mar 2005 16:41:13 -0000	1.60
  @@ -458,7 +458,7 @@
   
           try
           {
  -            artifact = artifactResolver.resolve( artifact, remoteArtifactRepositories,
localRepository );
  +            artifactResolver.resolve( artifact, remoteArtifactRepositories, localRepository
);
           }
           catch ( ArtifactResolutionException e )
           {
  
  
  
  1.38      +2 -2      maven-components/maven-core/src/main/java/org/apache/maven/project/MavenProject.java
  
  Index: MavenProject.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/project/MavenProject.java,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- MavenProject.java	29 Mar 2005 15:44:27 -0000	1.37
  +++ MavenProject.java	29 Mar 2005 16:41:13 -0000	1.38
  @@ -710,8 +710,8 @@
                                                                                       existing.getVersion(),
                                                                                       a.getScope(),
existing.getType() );
   
  -                    artifact.setFile( artifact.getFile() );
  -                    artifact.setBaseVersion( artifact.getBaseVersion() );
  +                    artifact.setFile( existing.getFile() );
  +                    artifact.setBaseVersion( existing.getBaseVersion() );
   
                       artifacts.put( id, artifact );
                   }
  
  
  
  1.7       +1 -2      maven-components/maven-core/src/test/java/org/apache/maven/project/ProjectClasspathArtifactResolver.java
  
  Index: ProjectClasspathArtifactResolver.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/test/java/org/apache/maven/project/ProjectClasspathArtifactResolver.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ProjectClasspathArtifactResolver.java	24 Mar 2005 16:16:49 -0000	1.6
  +++ ProjectClasspathArtifactResolver.java	29 Mar 2005 16:41:13 -0000	1.7
  @@ -68,11 +68,10 @@
           }
       }
   
  -    public Artifact resolve( Artifact artifact, List remoteRepositories, ArtifactRepository
localRepository )
  +    public void resolve( Artifact artifact, List remoteRepositories, ArtifactRepository
localRepository )
           throws ArtifactResolutionException
       {
           artifact.setFile( new File( "dummy" ) );
  -        return artifact;
       }
   
       public ArtifactResolutionResult resolveTransitively( Set artifacts, List remoteRepositories,
  
  
  
  1.7       +1 -1      maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/deployer/DefaultArtifactDeployer.java
  
  Index: DefaultArtifactDeployer.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/deployer/DefaultArtifactDeployer.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DefaultArtifactDeployer.java	24 Mar 2005 08:45:36 -0000	1.6
  +++ DefaultArtifactDeployer.java	29 Mar 2005 16:41:13 -0000	1.7
  @@ -68,7 +68,7 @@
               for ( Iterator i = artifactTransformations.iterator(); i.hasNext(); )
               {
                   ArtifactTransformation transform = (ArtifactTransformation) i.next();
  -                artifact = transform.transformForDeployment( artifact, deploymentRepository
);
  +                transform.transformForDeployment( artifact, deploymentRepository );
               }
   
               wagonManager.putArtifact( source, artifact, deploymentRepository );
  
  
  
  1.14      +1 -1      maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/installer/DefaultArtifactInstaller.java
  
  Index: DefaultArtifactInstaller.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/installer/DefaultArtifactInstaller.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- DefaultArtifactInstaller.java	24 Mar 2005 11:57:47 -0000	1.13
  +++ DefaultArtifactInstaller.java	29 Mar 2005 16:41:13 -0000	1.14
  @@ -66,7 +66,7 @@
               for ( Iterator i = artifactTransformations.iterator(); i.hasNext(); )
               {
                   ArtifactTransformation transform = (ArtifactTransformation) i.next();
  -                artifact = transform.transformForInstall( artifact, localRepository );
  +                transform.transformForInstall( artifact, localRepository );
               }
   
               String localPath = localRepository.pathOf( artifact );
  
  
  
  1.8       +1 -1      maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/metadata/SnapshotArtifactMetadata.java
  
  
  
  
  1.7       +2 -5      maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolver.java
  
  Index: ArtifactResolver.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolver.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ArtifactResolver.java	23 Mar 2005 07:23:23 -0000	1.6
  +++ ArtifactResolver.java	29 Mar 2005 16:41:13 -0000	1.7
  @@ -36,16 +36,13 @@
   {
       static String ROLE = ArtifactResolver.class.getName();
   
  -    Artifact resolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository
)
  +    void resolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository
)
           throws ArtifactResolutionException;
   
       ArtifactResolutionResult resolveTransitively( Artifact artifact, List remoteRepositories,
                                                     ArtifactRepository localRepository, ArtifactMetadataSource
source )
           throws ArtifactResolutionException;
   
  -    Set resolve( Set artifacts, List remoteRepositories, ArtifactRepository localRepository
)
  -        throws ArtifactResolutionException;
  -
       ArtifactResolutionResult resolveTransitively( Set artifacts, List remoteRepositories,
                                                     ArtifactRepository localRepository, ArtifactMetadataSource
source )
           throws ArtifactResolutionException;
  
  
  
  1.33      +31 -61    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.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- DefaultArtifactResolver.java	24 Mar 2005 16:08:48 -0000	1.32
  +++ DefaultArtifactResolver.java	29 Mar 2005 16:41:13 -0000	1.33
  @@ -35,7 +35,6 @@
   import java.io.File;
   import java.util.Collections;
   import java.util.HashMap;
  -import java.util.HashSet;
   import java.util.Iterator;
   import java.util.LinkedList;
   import java.util.List;
  @@ -65,8 +64,7 @@
       // Implementation
       // ----------------------------------------------------------------------
   
  -    // TODO: would like to avoid the returning of a new artifact - is it ok to modify the
original though?
  -    public Artifact resolve( Artifact artifact, List remoteRepositories, ArtifactRepository
localRepository )
  +    public void resolve( Artifact artifact, List remoteRepositories, ArtifactRepository
localRepository )
           throws ArtifactResolutionException
       {
           // ----------------------------------------------------------------------
  @@ -85,7 +83,7 @@
               ArtifactTransformation transform = (ArtifactTransformation) i.next();
               try
               {
  -                artifact = transform.transformForResolve( artifact, remoteRepositories,
localRepository );
  +                transform.transformForResolve( artifact, remoteRepositories, localRepository
);
               }
               catch ( ArtifactMetadataRetrievalException e )
               {
  @@ -107,44 +105,40 @@
           File destination = new File( localRepository.getBasedir(), localPath );
           artifact.setFile( destination );
   
  -        if ( destination.exists() )
  +        if ( !destination.exists() )
           {
  -            return artifact;
  -        }
  +            try
  +            {
  +                if ( artifact.getRepository() != null )
  +                {
  +                    // the transformations discovered the artifact - so use it exclusively
  +                    wagonManager.getArtifact( artifact, artifact.getRepository(), destination
);
  +                }
  +                else
  +                {
  +                    wagonManager.getArtifact( artifact, remoteRepositories, destination
);
  +                }
   
  -        try
  -        {
  -            if ( artifact.getRepository() != null )
  +                // must be after the artifact is downloaded
  +                for ( Iterator i = artifact.getMetadataList().iterator(); i.hasNext();
)
  +                {
  +                    ArtifactMetadata metadata = (ArtifactMetadata) i.next();
  +                    metadata.storeInLocalRepository( localRepository );
  +                }
  +            }
  +            catch ( ResourceDoesNotExistException e )
               {
  -                // the transformations discovered the artifact - so use it exclusively
  -                wagonManager.getArtifact( artifact, artifact.getRepository(), destination
);
  +                throw new ArtifactResolutionException( artifactNotFound( localPath, remoteRepositories
), e );
               }
  -            else
  +            catch ( TransferFailedException e )
               {
  -                wagonManager.getArtifact( artifact, remoteRepositories, destination );
  +                throw new ArtifactResolutionException( "Error downloading artifact " +
artifact, e );
               }
  -
  -            // must be after the artifact is downloaded
  -            for ( Iterator i = artifact.getMetadataList().iterator(); i.hasNext(); )
  +            catch ( ArtifactMetadataRetrievalException e )
               {
  -                ArtifactMetadata metadata = (ArtifactMetadata) i.next();
  -                metadata.storeInLocalRepository( localRepository );
  +                throw new ArtifactResolutionException( "Error downloading artifact " +
artifact, e );
               }
           }
  -        catch ( ResourceDoesNotExistException e )
  -        {
  -            throw new ArtifactResolutionException( artifactNotFound( localPath, remoteRepositories
), e );
  -        }
  -        catch ( TransferFailedException e )
  -        {
  -            throw new ArtifactResolutionException( "Error downloading artifact " + artifact,
e );
  -        }
  -        catch ( ArtifactMetadataRetrievalException e )
  -        {
  -            throw new ArtifactResolutionException( "Error downloading artifact " + artifact,
e );
  -        }
  -
  -        return artifact;
       }
   
       private static final String LS = System.getProperty( "line.separator" );
  @@ -177,23 +171,6 @@
           return sb.toString();
       }
   
  -    public Set resolve( Set artifacts, List remoteRepositories, ArtifactRepository localRepository
)
  -        throws ArtifactResolutionException
  -    {
  -        Set resolvedArtifacts = new HashSet();
  -
  -        for ( Iterator i = artifacts.iterator(); i.hasNext(); )
  -        {
  -            Artifact artifact = (Artifact) i.next();
  -
  -            Artifact resolvedArtifact = resolve( artifact, remoteRepositories, localRepository
);
  -
  -            resolvedArtifacts.add( resolvedArtifact );
  -        }
  -
  -        return resolvedArtifacts;
  -    }
  -
       // ----------------------------------------------------------------------
       // Transitive modes
       // ----------------------------------------------------------------------
  @@ -214,19 +191,12 @@
               throw new ArtifactResolutionException( "Error transitively resolving artifacts:
", e );
           }
   
  -        // 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(); )
  -        {
  -            Object key = i.next();
  -            resolvedArtifacts.put( key, resolve( (Artifact) collectedArtifacts.get( key
), remoteRepositories,
  -                                                 localRepository ) );
  +        for ( Iterator i = artifactResolutionResult.getArtifacts().values().iterator();
i.hasNext(); )
  +        {
  +            Artifact artifact = (Artifact) i.next();
  +            resolve( artifact, remoteRepositories, localRepository );
           }
   
  -        collectedArtifacts.clear();
  -        collectedArtifacts.putAll( resolvedArtifacts );
  -
           return artifactResolutionResult;
       }
   
  
  
  
  1.7       +3 -7      maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/transform/ArtifactTransformation.java
  
  Index: ArtifactTransformation.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/transform/ArtifactTransformation.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ArtifactTransformation.java	24 Mar 2005 14:52:25 -0000	1.6
  +++ ArtifactTransformation.java	29 Mar 2005 16:41:13 -0000	1.7
  @@ -38,10 +38,8 @@
        * @param artifact           Artifact to be transformed.
        * @param remoteRepositories the repositories to check
        * @param localRepository    the local repository
  -     * @return The transformed Artifact
        */
  -    public Artifact transformForResolve( Artifact artifact, List remoteRepositories,
  -                                         ArtifactRepository localRepository )
  +    public void transformForResolve( Artifact artifact, List remoteRepositories, ArtifactRepository
localRepository )
           throws ArtifactMetadataRetrievalException;
   
       /**
  @@ -50,9 +48,8 @@
        *
        * @param artifact        Artifact to be transformed.
        * @param localRepository the local repository it will be stored in
  -     * @return The transformed Artifact
        */
  -    Artifact transformForInstall( Artifact artifact, ArtifactRepository localRepository
);
  +    void transformForInstall( Artifact artifact, ArtifactRepository localRepository );
   
       /**
        * Take in a artifact and return the transformed artifact for distributing toa remote
repository. If no
  @@ -60,8 +57,7 @@
        *
        * @param artifact         Artifact to be transformed.
        * @param remoteRepository the repository to deploy to
  -     * @return The transformed Artifact
        */
  -    Artifact transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository
)
  +    void transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository
)
           throws ArtifactMetadataRetrievalException;
   }
  \ No newline at end of file
  
  
  
  1.11      +8 -40     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.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- SnapshotTransformation.java	29 Mar 2005 15:44:28 -0000	1.10
  +++ SnapshotTransformation.java	29 Mar 2005 16:41:13 -0000	1.11
  @@ -17,9 +17,7 @@
    */
   
   import org.apache.maven.artifact.Artifact;
  -import org.apache.maven.artifact.DefaultArtifact;
   import org.apache.maven.artifact.manager.WagonManager;
  -import org.apache.maven.artifact.metadata.ArtifactMetadata;
   import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
   import org.apache.maven.artifact.metadata.SnapshotArtifactMetadata;
   import org.apache.maven.artifact.repository.ArtifactRepository;
  @@ -47,8 +45,7 @@
        */
       private static Set resolvedArtifactCache = new HashSet();
   
  -    public Artifact transformForResolve( Artifact artifact, List remoteRepositories,
  -                                         ArtifactRepository localRepository )
  +    public void transformForResolve( Artifact artifact, List remoteRepositories, ArtifactRepository
localRepository )
           throws ArtifactMetadataRetrievalException
       {
           // TODO: remove hack
  @@ -56,11 +53,6 @@
               !Boolean.valueOf( System.getProperty( "maven.debug.snapshot.disabled", "true"
) ).booleanValue() )
           {
               // 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;
  @@ -101,13 +93,11 @@
                   {
                       artifact.addMetadata( localMetadata );
                   }
  -            }
  -
  -            artifact = createArtifactCopy( artifact, localMetadata );
   
  -            resolvedArtifactCache.add( getCacheKey( artifact ) );
  +                resolvedArtifactCache.add( getCacheKey( artifact ) );
  +            }
  +            artifact.setVersion( localMetadata.constructVersion() );
           }
  -        return artifact;
       }
   
       private boolean alreadyResolved( Artifact artifact )
  @@ -121,7 +111,7 @@
           return artifact.getGroupId() + ":" + artifact.getArtifactId();
       }
   
  -    public Artifact transformForInstall( Artifact artifact, ArtifactRepository localRepository
)
  +    public void transformForInstall( Artifact artifact, ArtifactRepository localRepository
)
       {
           // Nothing to do
   /* TODO: remove
  @@ -132,10 +122,9 @@
               artifact.addMetadata( metadata );
           }
   */
  -        return artifact;
       }
   
  -    public Artifact transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository
)
  +    public void transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository
)
           throws ArtifactMetadataRetrievalException
       {
           if ( isSnapshot( artifact ) )
  @@ -145,31 +134,10 @@
                                                                                         
                wagonManager );
               metadata.update();
   
  -            // TODO: note, we could currently transform this in place, as it is only used
through the deploy mojo,
  -            //   which creates the artifact and then disposes of it
  -            artifact = createArtifactCopy( artifact, metadata );
  -            artifact.addMetadata( metadata );
  -        }
  -        return artifact;
  -    }
  -
  -    private Artifact createArtifactCopy( Artifact artifact, SnapshotArtifactMetadata metadata
)
  -    {
  -        Artifact newArtifact = new DefaultArtifact( artifact.getGroupId(), artifact.getArtifactId(),
  -                                                    metadata.constructVersion(), artifact.getScope(),
  -                                                    artifact.getType(), artifact.getClassifier()
);
  -        newArtifact.setBaseVersion( artifact.getBaseVersion() );
  +            artifact.setVersion( metadata.constructVersion() );
   
  -        for ( Iterator i = artifact.getMetadataList().iterator(); i.hasNext(); )
  -        {
  -            ArtifactMetadata m = (ArtifactMetadata) i.next();
  -            m.setArtifact( newArtifact );
  -            newArtifact.addMetadata( m );
  +            artifact.addMetadata( metadata );
           }
  -
  -        newArtifact.setRepository( artifact.getRepository() );
  -
  -        return newArtifact;
       }
   
       private static boolean isSnapshot( Artifact artifact )
  
  
  
  1.11      +5 -0      maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/Artifact.java
  
  Index: Artifact.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/Artifact.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- Artifact.java	29 Mar 2005 15:44:28 -0000	1.10
  +++ Artifact.java	29 Mar 2005 16:41:13 -0000	1.11
  @@ -42,6 +42,8 @@
   
       String getVersion();
   
  +    void setVersion( String version );
  +
       /**
        * Get the scope of the artifact. If the artifact is a standalone rather than a dependency,
it's scope will be
        * <code>null</code>. The scope may not be the same as it was declared
on the original dependency, as this is the
  @@ -64,6 +66,9 @@
   
       String getBaseVersion();
   
  +    /**
  +     * @todo would like to get rid of this - or at least only have one. Base version should
be immutable.
  +     */
       void setBaseVersion( String baseVersion );
   
       // ----------------------------------------------------------------------
  
  
  
  1.21      +8 -2      maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/DefaultArtifact.java
  
  Index: DefaultArtifact.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/DefaultArtifact.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- DefaultArtifact.java	29 Mar 2005 15:44:28 -0000	1.20
  +++ DefaultArtifact.java	29 Mar 2005 16:41:13 -0000	1.21
  @@ -37,8 +37,9 @@
   
       private final String artifactId;
   
  -    private final String version;
  +    private String version;
   
  +    // TODO: should be final
       private String baseVersion;
   
       private final String type;
  @@ -119,6 +120,11 @@
           return version;
       }
   
  +    public void setVersion( String version )
  +    {
  +        this.version = version;
  +    }
  +
       public String getType()
       {
           return type;
  
  
  
  1.13      +16 -64    maven-components/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolverTest.java
  
  Index: ArtifactResolverTest.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolverTest.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- ArtifactResolverTest.java	23 Mar 2005 06:52:52 -0000	1.12
  +++ ArtifactResolverTest.java	29 Mar 2005 16:41:13 -0000	1.13
  @@ -26,16 +26,12 @@
   import java.util.List;
   import java.util.Set;
   
  -/**
  - * @author <a href="mailto:jason@maven.org">Jason van Zyl </a>
  - * @version $Id$
  - */
  -
   // It would be cool if there was a hook that i could use to setup a test environment.
   // I want to setup a local/remote repositories for testing but i don't want to have
   // to change them when i change the layout of the repositories. So i want to generate
   // the structure i want to test by using the artifact handler manager which dictates
   // the layout used for a particular artifact type.
  +
   /**
    * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
    * @version $Id$
  @@ -45,7 +41,8 @@
   {
       private ArtifactResolver artifactResolver;
   
  -    protected void setUp() throws Exception
  +    protected void setUp()
  +        throws Exception
       {
           super.setUp();
   
  @@ -57,7 +54,8 @@
           return "resolver";
       }
   
  -    public void testResolutionOfASingleArtifactWhereTheArtifactIsPresentInTheLocalRepository()
throws Exception
  +    public void testResolutionOfASingleArtifactWhereTheArtifactIsPresentInTheLocalRepository()
  +        throws Exception
       {
           Artifact a = createLocalArtifact( "a", "1.0" );
   
  @@ -77,70 +75,21 @@
           assertLocalArtifactPresent( b );
       }
   
  -    public void testResolutionOfASetOfArtifactsWhereTheArtifactsArePresentInTheLocalRepository()
throws Exception
  -    {
  -        Set artifacts = new HashSet();
  -
  -        Artifact c = createLocalArtifact( "c", "1.0" );
  -
  -        Artifact d = createLocalArtifact( "d", "1.0" );
  -
  -        artifacts.add( c );
  -
  -        artifacts.add( d );
  -
  -        Set resolvedArtifacts = artifactResolver.resolve( artifacts, remoteRepositories(),
localRepository() );
  -
  -        assertEquals( 2, resolvedArtifacts.size() );
  -
  -        // The artifacts have undergone no transformations and they are present so the
original
  -        // artifacts sent into the resolver should be returned as they were sent in.
  -
  -        assertTrue( resolvedArtifacts.contains( c ) );
  -
  -        assertTrue( resolvedArtifacts.contains( d ) );
  -    }
  -
  -    public void testResolutionOfASetOfArtifactsWhereTheArtifactsAreNotPresentInTheLocalRepositoryAndMustBeRetrievedFromTheRemoteRepository()
  -        throws Exception
  -    {
  -        Set artifacts = new HashSet();
  -
  -        Artifact e = createRemoteArtifact( "e", "1.0" );
  -        deleteLocalArtifact( e );
  -
  -        Artifact f = createRemoteArtifact( "f", "1.0" );
  -        deleteLocalArtifact( f );
  -
  -        artifacts.add( e );
  -
  -        artifacts.add( f );
  -
  -        Set resolvedArtifacts = artifactResolver.resolve( artifacts, remoteRepositories(),
localRepository() );
  -
  -        assertEquals( 2, resolvedArtifacts.size() );
  -
  -        // The artifacts have undergone no transformations and they are present so the
original
  -        // artifacts sent into the resolver should be returned as they were sent in.
  -
  -        assertTrue( resolvedArtifacts.contains( e ) );
  -
  -        assertTrue( resolvedArtifacts.contains( f ) );
  -    }
  -
       protected Artifact createArtifact( String groupId, String artifactId, String version,
String type )
       {
           // for the anonymous classes
           return super.createArtifact( groupId, artifactId, version, type );
       }
   
  -    public void testTransitiveResolutionWhereAllArtifactsArePresentInTheLocalRepository()
throws Exception
  +    public void testTransitiveResolutionWhereAllArtifactsArePresentInTheLocalRepository()
  +        throws Exception
       {
           Artifact g = createLocalArtifact( "g", "1.0" );
   
           Artifact h = createLocalArtifact( "h", "1.0" );
   
  -        ArtifactMetadataSource mds = new ArtifactMetadataSource() {
  +        ArtifactMetadataSource mds = new ArtifactMetadataSource()
  +        {
               public Set retrieve( Artifact artifact, ArtifactRepository localRepository,
List remoteRepositories )
               {
                   Set dependencies = new HashSet();
  @@ -177,7 +126,8 @@
           Artifact j = createRemoteArtifact( "j", "1.0" );
           deleteLocalArtifact( j );
   
  -        ArtifactMetadataSource mds = new ArtifactMetadataSource() {
  +        ArtifactMetadataSource mds = new ArtifactMetadataSource()
  +        {
               public Set retrieve( Artifact artifact, ArtifactRepository localRepository,
List remoteRepositories )
               {
                   Set dependencies = new HashSet();
  @@ -205,7 +155,8 @@
           assertLocalArtifactPresent( j );
       }
   
  -    public void testResolutionFailureWhenArtifactNotPresentInRemoteRepository() throws
Exception
  +    public void testResolutionFailureWhenArtifactNotPresentInRemoteRepository()
  +        throws Exception
       {
           Artifact k = createArtifact( "k", "1.0" );
   
  @@ -220,7 +171,8 @@
           }
       }
   
  -    public void testResolutionOfAnArtifactWhereOneRemoteRepositoryIsBadButOneIsGood() throws
Exception
  +    public void testResolutionOfAnArtifactWhereOneRemoteRepositoryIsBadButOneIsGood()
  +        throws Exception
       {
           Artifact l = createRemoteArtifact( "l", "1.0" );
           deleteLocalArtifact( l );
  
  
  

Mime
View raw message