o making the build.properties generally available to the bootstrapper and

just passing in those properties to the artifact downloader.


git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@162561 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jason van Zyl 2004-02-07 16:17:49 +00:00
parent ec59035a90
commit 85700523e5
2 changed files with 57 additions and 62 deletions

View File

@ -1,9 +1,6 @@
import java.io.File; import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.InputStream;
import java.io.IOException;
import java.io.Writer; import java.io.Writer;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
@ -31,10 +28,8 @@ public class ArtifactDownloader
private String proxyPassword; 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" ) ); setRemoteRepo( properties.getProperty( "maven.repo.remote" ) );
String mavenRepoLocalProperty = properties.getProperty( "maven.repo.local" ); String mavenRepoLocalProperty = properties.getProperty( "maven.repo.local" );
@ -68,14 +63,6 @@ public class ArtifactDownloader
System.out.println( "Using the following for your maven.repo.local: " + mavenRepoLocal ); 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 ) private void writeFile( String name, String contents )
throws Exception throws Exception
{ {
@ -268,51 +255,4 @@ public class ArtifactDownloader
{ {
System.out.println( 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;
}
} }

View File

@ -8,11 +8,14 @@ import javax.xml.parsers.SAXParserFactory;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.Serializable; import java.io.Serializable;
import java.io.Writer; import java.io.Writer;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Properties;
public class Bootstrapper public class Bootstrapper
{ {
@ -26,6 +29,8 @@ public class Bootstrapper
private List resources; private List resources;
private Properties properties;
public static void main( String[] args ) public static void main( String[] args )
throws Exception throws Exception
{ {
@ -37,7 +42,9 @@ public class Bootstrapper
public void execute( String[] args ) public void execute( String[] args )
throws Exception throws Exception
{ {
downloader = new ArtifactDownloader(); properties = loadProperties( new File( System.getProperty( "user.home" ), "build.properties" ) );
downloader = new ArtifactDownloader( properties );
bootstrapPomParser = new BootstrapPomParser(); bootstrapPomParser = new BootstrapPomParser();
@ -231,6 +238,54 @@ public class Bootstrapper
return d.getArtifactDirectory() + pathSeparator + "jars" + pathSeparator + d.getArtifact(); 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 static class BootstrapPomParser
extends DefaultHandler extends DefaultHandler
{ {