jvanzyl     2004/02/07 08:17:49

  Modified:    maven-mboot/src/main ArtifactDownloader.java
                        Bootstrapper.java
  Log:
  o making the build.properties generally available to the bootstrapper and
    just passing in those properties to the artifact downloader.
  
  Revision  Changes    Path
  1.2       +1 -61     maven-components/maven-mboot/src/main/ArtifactDownloader.java
  
  Index: ArtifactDownloader.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-mboot/src/main/ArtifactDownloader.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ArtifactDownloader.java   13 Jan 2004 17:38:30 -0000      1.1
  +++ ArtifactDownloader.java   7 Feb 2004 16:17:49 -0000       1.2
  @@ -1,9 +1,6 @@
   import java.io.File;
  -import java.io.FileInputStream;
   import java.io.FileNotFoundException;
   import java.io.FileWriter;
  -import java.io.InputStream;
  -import java.io.IOException;
   import java.io.Writer;
   import java.util.ArrayList;
   import java.util.Iterator;
  @@ -31,10 +28,8 @@
   
       private String proxyPassword;
       
  -    public ArtifactDownloader() throws Exception
  +    public ArtifactDownloader( Properties properties ) throws Exception
       {
  -        Properties properties = loadProperties( new File( System.getProperty( 
"user.home" ), "build.properties" ) );
  -
           setRemoteRepo( properties.getProperty( "maven.repo.remote" ) );
   
           String mavenRepoLocalProperty = properties.getProperty( "maven.repo.local" 
);
  @@ -68,14 +63,6 @@
           System.out.println( "Using the following for your maven.repo.local: " + 
mavenRepoLocal );
       }
       
  -    public static void main(String[] args) throws Exception
  -    {
  -        ArtifactDownloader dl =new ArtifactDownloader();
  -        List tmp = new ArrayList();
  -        tmp.add(args[0]);
  -        dl.downloadDependencies(tmp);
  -    }
  -    
       private void writeFile( String name, String contents )
           throws Exception
       {
  @@ -267,52 +254,5 @@
       private void log( String message )
       {
           System.out.println( message );
  -    }
  -    
  -    private Properties loadProperties( File file )
  -    {
  -        try
  -        {
  -            return loadProperties( new FileInputStream( file ) );
  -        }
  -        catch ( Exception e )
  -        {
  -            // ignore
  -        }
  -
  -        return new Properties();
  -    }
  -
  -    private static Properties loadProperties( InputStream is )
  -    {
  -        Properties properties = new Properties();
  -
  -        try
  -        {
  -            if ( is != null )
  -            {
  -                properties.load( is );
  -            }
  -        }
  -        catch ( IOException e )
  -        {
  -            // ignore
  -        }
  -        finally
  -        {
  -            try
  -            {
  -                if ( is != null )
  -                {
  -                    is.close();
  -                }
  -            }
  -            catch ( IOException e )
  -            {
  -                // ignore
  -            }
  -        }
  -
  -        return properties;
       }
   }
  
  
  
  1.14      +56 -1     maven-components/maven-mboot/src/main/Bootstrapper.java
  
  Index: Bootstrapper.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-mboot/src/main/Bootstrapper.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- Bootstrapper.java 31 Jan 2004 03:13:03 -0000      1.13
  +++ Bootstrapper.java 7 Feb 2004 16:17:49 -0000       1.14
  @@ -8,11 +8,14 @@
   import java.io.File;
   import java.io.FileInputStream;
   import java.io.FileWriter;
  +import java.io.IOException;
  +import java.io.InputStream;
   import java.io.Serializable;
   import java.io.Writer;
   import java.util.ArrayList;
   import java.util.Iterator;
   import java.util.List;
  +import java.util.Properties;
   
   public class Bootstrapper
   {
  @@ -26,6 +29,8 @@
   
       private List resources;
   
  +    private Properties properties;
  +
       public static void main( String[] args )
           throws Exception
       {
  @@ -37,7 +42,9 @@
       public void execute( String[] args )
           throws Exception
       {
  -        downloader = new ArtifactDownloader();
  +        properties = loadProperties( new File( System.getProperty( "user.home" ), 
"build.properties" ) );
  +
  +        downloader = new ArtifactDownloader( properties );
   
           bootstrapPomParser = new BootstrapPomParser();
   
  @@ -230,6 +237,54 @@
       {
           return d.getArtifactDirectory() + pathSeparator + "jars" + pathSeparator + 
d.getArtifact();
       }
  +
  +    private Properties loadProperties( File file )
  +    {
  +        try
  +        {
  +            return loadProperties( new FileInputStream( file ) );
  +        }
  +        catch ( Exception e )
  +        {
  +            // ignore
  +        }
  +
  +        return new Properties();
  +    }
  +
  +    private static Properties loadProperties( InputStream is )
  +    {
  +        Properties properties = new Properties();
  +
  +        try
  +        {
  +            if ( is != null )
  +            {
  +                properties.load( is );
  +            }
  +        }
  +        catch ( IOException e )
  +        {
  +            // ignore
  +        }
  +        finally
  +        {
  +            try
  +            {
  +                if ( is != null )
  +                {
  +                    is.close();
  +                }
  +            }
  +            catch ( IOException e )
  +            {
  +                // ignore
  +            }
  +        }
  +
  +        return properties;
  +    }
  +
   
       static class BootstrapPomParser
           extends DefaultHandler
  
  
  

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

Reply via email to