o installing the parent pom

o don't download things more than once during the bootstrap


git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@162876 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jason van Zyl 2004-07-26 22:45:09 +00:00
parent ef654ba623
commit 4381911ab4
3 changed files with 75 additions and 20 deletions

Binary file not shown.

View File

@ -8,6 +8,8 @@ import java.util.Iterator;
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 @@ public class ArtifactDownloader
return mavenRepoLocal;
}
private Set downloadedArtifacts = new HashSet();
public void downloadDependencies( List files )
throws Exception
{
@ -88,29 +92,31 @@ public class ArtifactDownloader
{
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 )
if ( !downloadedArtifacts.contains( file ) )
{
directory.mkdirs();
}
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 ( destinationFile.exists() && file.indexOf( SNAPSHOT_SIGNATURE ) < 0 )
{
continue;
}
if ( directory.exists() == false )
{
directory.mkdirs();
}
//log( "Downloading dependency: " + file );
if ( destinationFile.exists() && file.indexOf( SNAPSHOT_SIGNATURE ) < 0 )
{
continue;
}
getRemoteArtifact( file, destinationFile );
getRemoteArtifact( file, destinationFile );
if ( !destinationFile.exists() )
{
throw new Exception( "Failed to download " + file );
if ( !destinationFile.exists() )
{
throw new Exception( "Failed to download " + file );
}
downloadedArtifacts.add( file );
}
}
catch ( Exception e )

View File

@ -18,6 +18,7 @@ import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;
import java.util.Date;
public class MBoot
{
@ -119,6 +120,10 @@ public class MBoot
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 @@ public class MBoot
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 @@ public class MBoot
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 @@ public class MBoot
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 )