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 {