You are viewing a plain text version of this content. The canonical link for it is here.
Posted to m2-dev@maven.apache.org by jv...@apache.org on 2004/07/27 00:45:09 UTC
cvs commit: maven-components/maven-mboot2/src/main/java ArtifactDownloader.java MBoot.java
jvanzyl 2004/07/26 15:45:09
Modified: maven-mboot2 mboot.jar
maven-mboot2/src/main/java ArtifactDownloader.java
MBoot.java
Log:
o installing the parent pom
o don't download things more than once during the bootstrap
Revision Changes Path
1.3 +116 -117 maven-components/maven-mboot2/mboot.jar
<<Binary file>>
1.2 +27 -21 maven-components/maven-mboot2/src/main/java/ArtifactDownloader.java
Index: ArtifactDownloader.java
===================================================================
RCS file: /home/cvs/maven-components/maven-mboot2/src/main/java/ArtifactDownloader.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ArtifactDownloader.java 26 Jul 2004 03:53:15 -0000 1.1
+++ ArtifactDownloader.java 26 Jul 2004 22:45:09 -0000 1.2
@@ -8,6 +8,8 @@
import java.util.List;
import java.util.Properties;
import java.util.StringTokenizer;
+import java.util.Set;
+import java.util.HashSet;
public class ArtifactDownloader
{
@@ -79,6 +81,8 @@
return mavenRepoLocal;
}
+ private Set downloadedArtifacts = new HashSet();
+
public void downloadDependencies( List files )
throws Exception
{
@@ -88,29 +92,31 @@
{
String file = (String) j.next();
- File destinationFile = new File( mavenRepoLocal, file );
-
- // The directory structure for this project may
- // not exists so create it if missing.
- File directory = destinationFile.getParentFile();
-
- if ( directory.exists() == false )
- {
- directory.mkdirs();
- }
-
- if ( destinationFile.exists() && file.indexOf( SNAPSHOT_SIGNATURE ) < 0 )
+ if ( !downloadedArtifacts.contains( file ) )
{
- continue;
- }
-
- //log( "Downloading dependency: " + file );
+ File destinationFile = new File( mavenRepoLocal, file );
+ // The directory structure for this project may
+ // not exists so create it if missing.
+ File directory = destinationFile.getParentFile();
+
+ if ( directory.exists() == false )
+ {
+ directory.mkdirs();
+ }
+
+ if ( destinationFile.exists() && file.indexOf( SNAPSHOT_SIGNATURE ) < 0 )
+ {
+ continue;
+ }
+
+ getRemoteArtifact( file, destinationFile );
+
+ if ( !destinationFile.exists() )
+ {
+ throw new Exception( "Failed to download " + file );
+ }
- getRemoteArtifact( file, destinationFile );
-
- if ( !destinationFile.exists() )
- {
- throw new Exception( "Failed to download " + file );
+ downloadedArtifacts.add( file );
}
}
catch ( Exception e )
1.3 +51 -2 maven-components/maven-mboot2/src/main/java/MBoot.java
Index: MBoot.java
===================================================================
RCS file: /home/cvs/maven-components/maven-mboot2/src/main/java/MBoot.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- MBoot.java 26 Jul 2004 22:02:58 -0000 1.2
+++ MBoot.java 26 Jul 2004 22:45:09 -0000 1.3
@@ -18,6 +18,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Properties;
+import java.util.Date;
public class MBoot
{
@@ -119,6 +120,10 @@
public void run( String[] args )
throws Exception
{
+ Date fullStop;
+
+ Date fullStart = new Date();
+
properties = loadProperties( new File( System.getProperty( "user.home" ), "build.properties" ) );
downloader = new ArtifactDownloader( properties );
@@ -131,6 +136,17 @@
checkMBootDeps();
+ if ( !reader.parse( new File( basedir, "pom.xml" ) ) )
+ {
+ System.err.println( "Could not parse pom.xml" );
+
+ System.exit( 1 );
+ }
+
+ installPom( basedir, repoLocal );
+
+ reader.reset();
+
for ( int i = 0; i < builds.length; i++ )
{
String directory = new File( basedir, builds[i] ).getAbsolutePath();
@@ -263,6 +279,36 @@
FileUtils.copyFileToDirectory( f.getAbsolutePath(), plugins );
}
+
+ fullStop = new Date();
+
+ stats( fullStart, fullStop );
+ }
+
+ protected static String formatTime( long ms )
+ {
+ long secs = ms / 1000;
+
+ long min = secs / 60;
+ secs = secs % 60;
+
+ if ( min > 0 )
+ {
+ return min + " minutes " + secs + " seconds";
+ }
+ else
+ {
+ return secs + " seconds";
+ }
+ }
+
+ private void stats( Date fullStart, Date fullStop )
+ {
+ long fullDiff = fullStop.getTime() - fullStart.getTime();
+
+ System.out.println( "Total time: " + formatTime( fullDiff ) );
+
+ System.out.println( "Finished at: " + fullStop );
}
public void buildProject( String basedir )
@@ -481,8 +527,11 @@
String groupId = reader.groupId;
- FileUtils.copyFile( new File( basedir, "pom.xml" ),
- new File( repoLocal, "/" + groupId + "/poms/" + artifactId + "-" + version + ".pom" ) );
+ File pom = new File( repoLocal, "/" + groupId + "/poms/" + artifactId + "-" + version + ".pom" );
+
+ System.out.println( "Installing POM: " + pom );
+
+ FileUtils.copyFile( new File( basedir, "pom.xml" ), pom );
}
private void installJar( String basedir, String repoLocal )