From 85700523e59a352f069a70e8cebb3e51f8279225 Mon Sep 17 00:00:00 2001 From: Jason van Zyl Date: Sat, 7 Feb 2004 16:17:49 +0000 Subject: [PATCH] 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 --- maven-mboot/src/main/ArtifactDownloader.java | 62 +------------------- maven-mboot/src/main/Bootstrapper.java | 57 +++++++++++++++++- 2 files changed, 57 insertions(+), 62 deletions(-) diff --git a/maven-mboot/src/main/ArtifactDownloader.java b/maven-mboot/src/main/ArtifactDownloader.java index e83bc46a95..e2e495b281 100644 --- a/maven-mboot/src/main/ArtifactDownloader.java +++ b/maven-mboot/src/main/ArtifactDownloader.java @@ -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 @@ public class ArtifactDownloader 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 @@ public class ArtifactDownloader 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 { @@ -268,51 +255,4 @@ public class ArtifactDownloader { 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; - } } \ No newline at end of file diff --git a/maven-mboot/src/main/Bootstrapper.java b/maven-mboot/src/main/Bootstrapper.java index f311df5eec..6b80009a50 100644 --- a/maven-mboot/src/main/Bootstrapper.java +++ b/maven-mboot/src/main/Bootstrapper.java @@ -8,11 +8,14 @@ import javax.xml.parsers.SAXParserFactory; 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 @@ public class Bootstrapper private List resources; + private Properties properties; + public static void main( String[] args ) throws Exception { @@ -37,7 +42,9 @@ public class Bootstrapper 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(); @@ -231,6 +238,54 @@ public class Bootstrapper 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 {