michal      2004/05/11 12:21:11

  Modified:    maven-project/src/test/java/org/apache/maven/artifact/downloader
                        DefaultArtifactDownloaderTest.java
               maven-project/src/main/resources/META-INF/plexus
                        components.xml
               maven-project/src/main/java/org/apache/maven/artifact/resolver
                        DefaultArtifactResolver.java
  Added:       maven-project/src/main/java/org/apache/maven/artifact/downloader
                        DefaultArtifactDownloader.java
                        ArtifactDownloader.java
  Removed:     maven-project/src/main/java/org/apache/maven/artifact/download
                        ArtifactDownloader.java
                        DefaultArtifactDownloader.java
  Log:
  I want to try ci to check if all tests are working (there might be differences for 
linux/window).  Note that wagon has changes in CVS!! I think I will ask for account on 
beaver so I can myself publish new jars (days when m2 will do this  are close :) )
  
  Revision  Changes    Path
  1.2       +15 -14    
maven-components/maven-project/src/test/java/org/apache/maven/artifact/downloader/DefaultArtifactDownloaderTest.java
  
  Index: DefaultArtifactDownloaderTest.java
  ===================================================================
  RCS file: 
/home/cvs/maven-components/maven-project/src/test/java/org/apache/maven/artifact/downloader/DefaultArtifactDownloaderTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultArtifactDownloaderTest.java        10 May 2004 19:06:30 -0000      1.1
  +++ DefaultArtifactDownloaderTest.java        11 May 2004 19:21:10 -0000      1.2
  @@ -18,7 +18,7 @@
   
   
   import org.apache.maven.artifact.MavenArtifact;
  -import org.apache.maven.artifact.download.ArtifactDownloader;
  +import org.apache.maven.artifact.downloader.ArtifactDownloader;
   import org.apache.maven.artifact.factory.MavenArtifactFactory;
   import org.apache.maven.project.AbstractProjectTestCase;
   import org.apache.maven.project.MavenProject;
  @@ -64,12 +64,13 @@
       
       public void testArtifactDownloading( )       
       {
  -                
  -        File f = new File( getLocalRepository(),  
"/maven-test/poms/maven-test-a-1.0.pom" );
  +                        
  +        
  +        File f = new File( getLocalRepository(), 
"/maven-test/poms/maven-test-a-1.0.pom" );
   
           assertTrue( "Test file: '" + f.getAbsolutePath() + "' doesn't exist!", 
f.exists() );
   
  -        File tempLocalRepository = new File( basedir, "target/repo-local" );
  +        File tempLocalRepository = new File( basedir, "target/test-repo-local" );
           
           tempLocalRepository.mkdirs();
           
  @@ -81,7 +82,13 @@
               // that's the only was I can influence MavenProjectBuilder
               System.setProperty( "maven.repo.local", tempLocalRepository.getPath()  
);
               
  -            FileUtils.deleteDirectory( tempLocalRepository  );
  +            try
  +            {
  +               FileUtils.deleteDirectory( tempLocalRepository  );
  +            }
  +            catch( Exception e)
  +            {
  +            }
               
               MavenProject project = projectBuilder.build( f );
                                                 
  @@ -137,15 +144,9 @@
               
               // A has accompanying   md5 file
               assertTrue( "MD5 file for B should have been downloaded",  
artifactB.getChecksumFile().exists() );
  -            
  -            
  -            // @todo: this is failing for me. there should be assertFalse in place 
of assertTrue.
  -            // there are two bugs here:
  -            // a) file should not be created - and this is a problem of wagon
  -            // b) I call file.delete() which is failing. is it a bug of jvm for ms 
windows or output stream is not closed?
  -                        
  +                       
               //Z does not have md5 file
  -            assertTrue( "MD5 file for Z does not exist in any repo and should not 
be downloaded: " + artifactZ.getChecksumFile() , artifactZ.getChecksumFile().exists() 
);
  +            assertFalse( "MD5 file for Z does not exist in any repo and should not 
be downloaded. File : " + artifactZ.getChecksumFile() + " exists.", 
artifactZ.getChecksumFile().exists() );
               
               // try to crate bizzare artifact and download it. this should fail.
               
  
  
  
  1.10      +3 -3      
maven-components/maven-project/src/main/resources/META-INF/plexus/components.xml
  
  Index: components.xml
  ===================================================================
  RCS file: 
/home/cvs/maven-components/maven-project/src/main/resources/META-INF/plexus/components.xml,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- components.xml    10 May 2004 19:26:22 -0000      1.9
  +++ components.xml    11 May 2004 19:21:10 -0000      1.10
  @@ -45,13 +45,13 @@
             <role>org.apache.maven.artifact.factory.MavenArtifactFactory</role>
           </requirement>
           <requirement>
  -          <role>org.apache.maven.artifact.download.ArtifactDownloader</role>
  +          <role>org.apache.maven.artifact.downloader.ArtifactDownloader</role>
           </requirement>
         </requirements>
       </component>    
       <component>
  -      <role>org.apache.maven.artifact.download.ArtifactDownloader</role>
  -      
<implementation>org.apache.maven.artifact.download.DefaultArtifactDownloader</implementation>
  +      <role>org.apache.maven.artifact.downloader.ArtifactDownloader</role>
  +      
<implementation>org.apache.maven.artifact.downloader.DefaultArtifactDownloader</implementation>
         <requirements>
           <requirement>
             <role>org.apache.maven.wagon.manager.WagonManager</role>
  
  
  
  1.1                  
maven-components/maven-project/src/main/java/org/apache/maven/artifact/downloader/DefaultArtifactDownloader.java
  
  Index: DefaultArtifactDownloader.java
  ===================================================================
  package org.apache.maven.artifact.downloader;
  
  import java.io.File;
  import java.util.Iterator;
  import java.util.List;
  
  import org.apache.maven.artifact.MavenArtifact;
  import org.apache.maven.artifact.factory.MavenArtifactFactory;
  import org.apache.maven.wagon.Wagon;
  import org.apache.maven.wagon.manager.WagonManager;
  import org.apache.maven.wagon.repository.Repository;
  import org.codehaus.plexus.logging.AbstractLogEnabled;
  
  
  
  
  /**
   * Class resposible to download [EMAIL PROTECTED] 
org.apache.maven.artifact.Artifact} from
   * remote repository (repositories) to local repository
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Michal Maczka</a>
   * @version $Id: DefaultArtifactDownloader.java,v 1.1 2004/05/11 19:21:10 michal Exp 
$
   */
  public class DefaultArtifactDownloader extends AbstractLogEnabled implements 
ArtifactDownloader
  {
  
          
      private WagonManager wagonManager;
      
      /**
       * 
       */
      private MavenArtifactFactory artifactFactory;
  
      
      /**     
       * @see 
org.apache.maven.artifact.downloader.ArtifactDownloader#getRemoteArtifact(org.apache.maven.artifact.Artifact,
 org.apache.maven.project.Project)
       */
     public boolean getRemoteArtifact( MavenArtifact artifact, List repositories )
     {
         boolean downloaded = false;
  
         for ( Iterator iter = repositories.iterator(); iter.hasNext(); )
         {           
             try
             {
                 Repository repository = ( Repository ) iter.next(  );
  
                 downloaded = getRemoteArtifact( artifact,  repository );
  
                 if ( downloaded )
                 {
                    break;
                 }  
             }
             catch ( Exception e )
             {
                 continue;
             }
         }
  
         return downloaded;
     }
      
      
      /**
       * 
       * @see 
org.apache.maven.artifact.downloader.ArtifactDownloader#getRemoteArtifact(org.apache.maven.artifact.Artifact,
 org.apache.maven.project.Project)
       */
      public boolean getRemoteArtifact( MavenArtifact artifact, Repository repository  
)
      {
          Wagon wagon = null;
          
          try
          {
              wagon = wagonManager.getWagon( repository.getProtocol() );
              
              System.out.println( "Wagon: " + wagon );
              
              wagon.connect(  repository  );
              
              return get( wagon, artifact );
              
          }
          catch ( Exception e )
          {
              
              //@todo improve error handling and reporting
              getLogger().info( "Failed to download: " + artifact.getUrlPath() + " 
from " + repository.getUrl(), e );
              
              return false;
          }
          finally
          {
              if ( wagon != null )
              {
                  try
                  {
                     wagonManager.releaseWagon( wagon );
                  }
                  catch( Exception e )
                  {
                     getLogger().error( "Failed to release wagon", e  );    
                  }
              }
          }
      }
  
      /**
       * @param wagon
       * @param artifact
       */
      private boolean get( Wagon wagon, MavenArtifact artifact ) 
      {
          
          getLogger().info( "Trying to download: " + artifact.getUrlPath() + "  from " 
+ wagon.getRepository().getUrl() );
          
          String source = artifact.getUrlPath();
          
          File file = artifact.getFile( );
          
          try
          {
              wagon.get( source, file );
          }
          catch( Exception e)
          {
              getLogger().info( artifact.getUrlPath() + " was not found in " + 
wagon.getRepository().getUrl() );
                          
              
              return false;    
          }
          
          getLogger().info( artifact.getUrlPath() + " was found in " + 
wagon.getRepository().getUrl() );
          
          String checksum = artifact.getChecksumUrlPath(); 
          
          File checksumFile = artifact.getChecksumFile( );
          
          try
          {
              getLogger().info( "Trying to download md5 cheksum: " + 
artifact.getChecksumUrlPath() + "  from " + wagon.getRepository().getUrl() );
              
              wagon.get( checksum, checksumFile );
              
          }
          catch ( Exception e )
          {
              
              //we can live without md5 checksum file
                            
          }
          
          
          
          return true;
                  
      }
  
      
  
     
  }
  
  
  
  1.1                  
maven-components/maven-project/src/main/java/org/apache/maven/artifact/downloader/ArtifactDownloader.java
  
  Index: ArtifactDownloader.java
  ===================================================================
  package org.apache.maven.artifact.downloader;
  
  import java.util.List;
  
  import org.apache.maven.artifact.MavenArtifact;
  import org.apache.maven.wagon.repository.Repository;
  
  
  
  
  /**
   * Component which downloads artifacts ([EMAIL PROTECTED] 
org.apache.maven.artifact.MavenArtifact}) from
   * remote repository (repositories) to the local repository
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Michal Maczka</a>
   * @version $Id: ArtifactDownloader.java,v 1.1 2004/05/11 19:21:10 michal Exp $
   */
  public interface ArtifactDownloader
  {
      /** Component role name*/
      public static final String ROLE = ArtifactDownloader.class.getName(  );
  
      /**
       * Downloads given <code>artifact</code> from the maven remote repositories
       *
       *
       * @param artifact the artifact to retrieve from the repositories.
       * @return true if the download is successful, <code>false</code> otherwise.
       */
      public boolean getRemoteArtifact( MavenArtifact artifact, Repository 
remoteRepository );
  
      /**
       *
       * @param artifact 
       * @param repositories (List<Repository>)
  
       * @return <code>true</code> if the from any of the repositories were succesful, 
<code>false</code> otherwise
       */
      public boolean getRemoteArtifact( MavenArtifact artifact, List repositories );
  
  
  }
  
  
  
  1.4       +2 -2      
maven-components/maven-project/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java
  
  Index: DefaultArtifactResolver.java
  ===================================================================
  RCS file: 
/home/cvs/maven-components/maven-project/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultArtifactResolver.java      10 May 2004 19:26:22 -0000      1.3
  +++ DefaultArtifactResolver.java      11 May 2004 19:21:10 -0000      1.4
  @@ -1,7 +1,7 @@
   package org.apache.maven.artifact.resolver;
   
   import org.apache.maven.artifact.MavenArtifact;
  -import org.apache.maven.artifact.download.ArtifactDownloader;
  +import org.apache.maven.artifact.downloader.ArtifactDownloader;
   import org.apache.maven.artifact.factory.MavenArtifactFactory;
   import org.apache.maven.model.Dependency;
   import org.apache.maven.project.MavenProject;
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to