brett       2005/04/13 00:03:18

  Modified:    maven-mboot2/src/main/java/download ArtifactDownloader.java
  Log:
  PR: MNG-232

  resolve snapshots in bootstrap
  
  Revision  Changes    Path
  1.15      +35 -1     
maven-components/maven-mboot2/src/main/java/download/ArtifactDownloader.java
  
  Index: ArtifactDownloader.java
  ===================================================================
  RCS file: 
/home/cvs/maven-components/maven-mboot2/src/main/java/download/ArtifactDownloader.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- ArtifactDownloader.java   7 Apr 2005 04:59:12 -0000       1.14
  +++ ArtifactDownloader.java   13 Apr 2005 07:03:18 -0000      1.15
  @@ -2,9 +2,11 @@
   
   import model.Dependency;
   import model.Repository;
  +import util.FileUtils;
   
   import java.io.File;
   import java.io.FileNotFoundException;
  +import java.io.IOException;
   import java.util.ArrayList;
   import java.util.Collection;
   import java.util.HashSet;
  @@ -82,7 +84,7 @@
                       directory.mkdirs();
                   }
   
  -                boolean snapshot = dep.getVersion().indexOf( 
SNAPSHOT_SIGNATURE ) >= 0;
  +                boolean snapshot = isSnapshot( dep );
   
                   if ( dep.getGroupId().equals( "org.apache.maven" ) && 
snapshot )
                   {
  @@ -107,6 +109,11 @@
           }
       }
   
  +    private static boolean isSnapshot( Dependency dep )
  +    {
  +        return dep.getVersion().indexOf( SNAPSHOT_SIGNATURE ) >= 0;
  +    }
  +
       private void setRemoteRepos( List repositories )
       {
           remoteRepos = new ArrayList();
  @@ -158,6 +165,27 @@
               // of the checksum file was successful.
               try
               {
  +                if ( isSnapshot( dep ) )
  +                {
  +                    String filename = getSnapshotMetadataFile( 
destinationFile.getPath(), "SNAPSHOT.version.txt" );
  +                    String metaUrl = getSnapshotMetadataFile( url, 
"SNAPSHOT.version.txt" );
  +                    log( "Downloading " + metaUrl );
  +                    try
  +                    {
  +                        HttpUtils.getFile( metaUrl, new File( filename ), 
ignoreErrors, useTimestamp, proxyHost,
  +                                           proxyPort, proxyUserName, 
proxyPassword, true );
  +                        String version = FileUtils.fileRead( filename );
  +                        log( "Resolved version: " + version );
  +                        version = version.substring( version.lastIndexOf( 
"-", version.lastIndexOf( "-" ) - 1 ) + 1 );
  +                        String extension = url.substring( url.length() - 4 );
  +                        url = getSnapshotMetadataFile( url, version + 
extension );
  +                    }
  +                    catch ( IOException e )
  +                    {
  +                        log( "WARNING: SNAPSHOT version not found, using 
default" );
  +                    }
  +                }
  +
                   log( "Downloading " + url );
                   HttpUtils.getFile( url, destinationFile, ignoreErrors, 
useTimestamp, proxyHost, proxyPort,
                                      proxyUserName, proxyPassword, true );
  @@ -197,6 +225,12 @@
           return fileFound;
       }
   
  +    private static String getSnapshotMetadataFile( String filename, String s 
)
  +    {
  +        int index = filename.lastIndexOf( "SNAPSHOT" );
  +        return filename.substring( 0, index ) + s;
  +    }
  +
       private String replace( String text, String repl, String with )
       {
           StringBuffer buf = new StringBuffer( text.length() );
  
  
  

Reply via email to