maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r332580 [1/2] - in /maven/components/trunk/bootstrap: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/maven/ src/main/java/org/apache/maven/bootstrap/ src/main/java/org/apache/maven/boo...
Date Fri, 11 Nov 2005 15:06:35 GMT
Author: brett
Date: Fri Nov 11 07:05:53 2005
New Revision: 332580

URL: http://svn.apache.org/viewcvs?rev=332580&view=rev
Log:
add slimmed down bootstrap

Added:
    maven/components/trunk/bootstrap/   (with props)
    maven/components/trunk/bootstrap/build
      - copied, changed from r330467, maven/components/trunk/maven-mboot2/build
    maven/components/trunk/bootstrap/build.bat
      - copied, changed from r330467, maven/components/trunk/maven-mboot2/build.bat
    maven/components/trunk/bootstrap/src/
    maven/components/trunk/bootstrap/src/main/
    maven/components/trunk/bootstrap/src/main/java/
    maven/components/trunk/bootstrap/src/main/java/org/
    maven/components/trunk/bootstrap/src/main/java/org/apache/
    maven/components/trunk/bootstrap/src/main/java/org/apache/maven/
    maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/
    maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/Bootstrap.java   (with props)
    maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/compile/
    maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/compile/AbstractCompiler.java
      - copied, changed from r332227, maven/components/trunk/maven-mboot2/src/main/java/compile/AbstractCompiler.java
    maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/compile/Compiler.java
      - copied, changed from r332227, maven/components/trunk/maven-mboot2/src/main/java/compile/Compiler.java
    maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/compile/CompilerConfiguration.java
      - copied, changed from r332227, maven/components/trunk/maven-mboot2/src/main/java/compile/CompilerConfiguration.java
    maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/compile/CompilerError.java
      - copied, changed from r332227, maven/components/trunk/maven-mboot2/src/main/java/compile/CompilerError.java
    maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/compile/JavacCompiler.java
      - copied, changed from r332227, maven/components/trunk/maven-mboot2/src/main/java/compile/JavacCompiler.java
    maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/download/
    maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/download/AbstractArtifactResolver.java   (with props)
    maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/download/ArtifactResolver.java   (with props)
    maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/download/Base64.java
      - copied, changed from r330467, maven/components/trunk/maven-mboot2/src/main/java/download/Base64.java
    maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/download/DownloadFailedException.java
      - copied, changed from r330467, maven/components/trunk/maven-mboot2/src/main/java/download/DownloadFailedException.java
    maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/download/HttpUtils.java
      - copied, changed from r330467, maven/components/trunk/maven-mboot2/src/main/java/download/HttpUtils.java
    maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/download/OfflineArtifactResolver.java   (with props)
    maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/download/OnlineArtifactDownloader.java   (contents, props changed)
      - copied, changed from r330467, maven/components/trunk/maven-mboot2/src/main/java/download/ArtifactDownloader.java
    maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/download/RepositoryMetadata.java
      - copied, changed from r330467, maven/components/trunk/maven-mboot2/src/main/java/download/RepositoryMetadata.java
    maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/model/
      - copied from r330467, maven/components/trunk/maven-mboot2/src/main/java/model/
    maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/model/Dependency.java
      - copied, changed from r331671, maven/components/trunk/maven-mboot2/src/main/java/model/Dependency.java
    maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/model/Exclusion.java
      - copied, changed from r331671, maven/components/trunk/maven-mboot2/src/main/java/model/Exclusion.java
    maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/model/ModelReader.java
      - copied, changed from r331671, maven/components/trunk/maven-mboot2/src/main/java/model/ModelReader.java
    maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/model/Plugin.java   (with props)
    maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/model/Repository.java
      - copied, changed from r331671, maven/components/trunk/maven-mboot2/src/main/java/model/Repository.java
    maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/model/Resource.java
      - copied, changed from r331671, maven/components/trunk/maven-mboot2/src/main/java/model/Resource.java
    maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/settings/
    maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/settings/Mirror.java   (with props)
    maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/settings/Proxy.java   (with props)
    maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/settings/Settings.java   (with props)
    maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/util/
    maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/util/AbstractReader.java
      - copied, changed from r330467, maven/components/trunk/maven-mboot2/src/main/java/util/AbstractReader.java
    maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/util/DirectoryScanner.java
      - copied, changed from r330467, maven/components/trunk/maven-mboot2/src/main/java/util/DirectoryScanner.java
    maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/util/FileUtils.java
      - copied, changed from r330467, maven/components/trunk/maven-mboot2/src/main/java/util/FileUtils.java
    maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/util/IOUtil.java
      - copied, changed from r330467, maven/components/trunk/maven-mboot2/src/main/java/util/IOUtil.java
    maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/util/IsolatedClassLoader.java
      - copied, changed from r332227, maven/components/trunk/maven-mboot2/src/main/java/util/IsolatedClassLoader.java
    maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/util/JarMojo.java
      - copied, changed from r332227, maven/components/trunk/maven-mboot2/src/main/java/jar/JarMojo.java
    maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/util/SelectorUtils.java
      - copied, changed from r330467, maven/components/trunk/maven-mboot2/src/main/java/util/SelectorUtils.java
    maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/util/StringUtils.java
      - copied, changed from r330467, maven/components/trunk/maven-mboot2/src/main/java/util/StringUtils.java
    maven/components/trunk/bootstrap/src/main/resources/
    maven/components/trunk/bootstrap/src/main/resources/META-INF/
    maven/components/trunk/bootstrap/src/main/resources/META-INF/MANIFEST.MF
      - copied, changed from r330467, maven/components/trunk/maven-mboot2/manifest.txt

Propchange: maven/components/trunk/bootstrap/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Nov 11 07:05:53 2005
@@ -0,0 +1,2 @@
+*.iml
+target

Copied: maven/components/trunk/bootstrap/build (from r330467, maven/components/trunk/maven-mboot2/build)
URL: http://svn.apache.org/viewcvs/maven/components/trunk/bootstrap/build?p2=maven/components/trunk/bootstrap/build&p1=maven/components/trunk/maven-mboot2/build&r1=330467&r2=332580&rev=332580&view=diff
==============================================================================
--- maven/components/trunk/maven-mboot2/build (original)
+++ maven/components/trunk/bootstrap/build Fri Nov 11 07:05:53 2005
@@ -8,9 +8,6 @@
 
 mkdir -p ${classesDir}
 
-#javac -d ${classesDir} ${srcDir}/*.java
 "$JAVA_HOME/bin/javac" -g -d ${classesDir} `find ${srcDir} -name '*.java'`
 
-( cd ${classesDir} ; "$JAVA_HOME/bin/jar" -cfm ../mboot.jar ../../manifest.txt * )
-
-cp ${buildDir}/mboot.jar ..
+( cd ${classesDir} ; "$JAVA_HOME/bin/jar" -cfm ../bootstrap.jar ../../src/main/resources/META-INF/MANIFEST.MF * )

Copied: maven/components/trunk/bootstrap/build.bat (from r330467, maven/components/trunk/maven-mboot2/build.bat)
URL: http://svn.apache.org/viewcvs/maven/components/trunk/bootstrap/build.bat?p2=maven/components/trunk/bootstrap/build.bat&p1=maven/components/trunk/maven-mboot2/build.bat&r1=330467&r2=332580&rev=332580&view=diff
==============================================================================
--- maven/components/trunk/maven-mboot2/build.bat (original)
+++ maven/components/trunk/bootstrap/build.bat Fri Nov 11 07:05:53 2005
@@ -15,7 +15,5 @@
 del /F/Q sources
 
 cd %classesDir% 
-"%JAVA_HOME%\bin\jar" -cfm ..\mboot.jar ..\..\manifest.txt *.*
+"%JAVA_HOME%\bin\jar" -cfm ..\bootstrap.jar ..\..\src\main\resources\META-INF\MANIFEST.MF *.*
 cd ..\..
-
-copy %buildDir%\mboot.jar ..

Added: maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/Bootstrap.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/Bootstrap.java?rev=332580&view=auto
==============================================================================
--- maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/Bootstrap.java (added)
+++ maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/Bootstrap.java Fri Nov 11 07:05:53 2005
@@ -0,0 +1,641 @@
+package org.apache.maven.bootstrap;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.bootstrap.compile.CompilerConfiguration;
+import org.apache.maven.bootstrap.compile.JavacCompiler;
+import org.apache.maven.bootstrap.download.ArtifactResolver;
+import org.apache.maven.bootstrap.download.OfflineArtifactResolver;
+import org.apache.maven.bootstrap.download.OnlineArtifactDownloader;
+import org.apache.maven.bootstrap.model.Dependency;
+import org.apache.maven.bootstrap.model.ModelReader;
+import org.apache.maven.bootstrap.model.Plugin;
+import org.apache.maven.bootstrap.model.Repository;
+import org.apache.maven.bootstrap.settings.Mirror;
+import org.apache.maven.bootstrap.settings.Proxy;
+import org.apache.maven.bootstrap.settings.Settings;
+import org.apache.maven.bootstrap.util.FileUtils;
+import org.apache.maven.bootstrap.util.IsolatedClassLoader;
+import org.apache.maven.bootstrap.util.JarMojo;
+import org.xml.sax.SAXException;
+
+import javax.xml.parsers.ParserConfigurationException;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.lang.reflect.Method;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+import java.util.TimeZone;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Main class for bootstrap module.
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ * @version $Id$
+ */
+public class Bootstrap
+{
+    private static final String MODELLO_PLUGIN_ID = "org.codehaus.modello:modello-maven-plugin";
+
+    private Set inProgress = new HashSet();
+
+    private Map modelFileCache = new HashMap();
+
+    public static void main( String[] args )
+        throws Exception
+    {
+        Bootstrap bootstrap = new Bootstrap();
+
+        bootstrap.run( args );
+    }
+
+    private static File getSettingsPath( String userHome, String[] args )
+        throws Exception
+    {
+        for ( int i = 0; i < args.length; i++ )
+        {
+            if ( args[i].equals( "-s" ) || args[i].equals( "--settings" ) )
+            {
+                if ( i == args.length - 1 )
+                {
+                    throw new Exception( "missing argument to -s" );
+                }
+                return new File( args[i + 1] );
+            }
+        }
+        return new File( userHome, ".m2/settings.xml" );
+    }
+
+    private void run( String[] args )
+        throws Exception
+    {
+        Date fullStart = new Date();
+
+        String userHome = System.getProperty( "user.home" );
+
+        File settingsXml = getSettingsPath( userHome, args );
+
+        System.out.println( "Using settings from " + settingsXml );
+
+        Settings settings = Settings.read( userHome, settingsXml );
+
+        // TODO: have an alternative implementation of ArtifactDownloader for source compiles
+        //      - if building from source, checkout and build then resolve to built jar (still download POM?)
+        ArtifactResolver resolver = setupRepositories( settings );
+
+        String basedir = System.getProperty( "user.dir" );
+
+        // TODO: only build this guy, then move the next part to a new phase using it for resolution
+        // Root POM
+//        buildProject( basedir, "", resolver, false );
+//        buildProject( basedir, "maven-artifact-manager", resolver );
+
+        // Pre-cache models so we know where they are for dependencies
+        cacheModels( new File( basedir ), resolver );
+
+        buildProject( new File( basedir ), resolver, true );
+
+        stats( fullStart, new Date() );
+    }
+
+    private void cacheModels( File basedir, ArtifactResolver resolver )
+        throws IOException, ParserConfigurationException, SAXException
+    {
+        ModelReader reader = readModel( resolver, new File( basedir, "pom.xml" ), false );
+
+        for ( Iterator i = reader.getModules().iterator(); i.hasNext(); )
+        {
+            String module = (String) i.next();
+
+            cacheModels( new File( basedir, module ), resolver );
+        }
+    }
+
+    private void buildProject( File basedir, ArtifactResolver resolver, boolean buildModules )
+        throws Exception
+    {
+        System.setProperty( "basedir", basedir.getAbsolutePath() );
+
+        File file = new File( basedir, "pom.xml" );
+
+        ModelReader reader = readModel( resolver, file, true );
+
+        String key = reader.getGroupId() + ":" + reader.getArtifactId() + ":" + reader.getPackaging();
+        if ( inProgress.contains( key ) )
+        {
+            return;
+        }
+
+        if ( reader.getPackaging().equals( "pom" ) )
+        {
+            if ( buildModules )
+            {
+                for ( Iterator i = reader.getModules().iterator(); i.hasNext(); )
+                {
+                    String module = (String) i.next();
+
+                    buildProject( new File( basedir, module ), resolver, true );
+                }
+            }
+
+            return;
+        }
+
+        inProgress.add( key );
+
+        if ( resolver.isAlreadyBuilt( key ) )
+        {
+            return;
+        }
+
+        String sources = new File( basedir, "src/main/java" ).getAbsolutePath();
+
+        String resources = new File( basedir, "src/main/resources" ).getAbsolutePath();
+
+        String classes = new File( basedir, "target/classes" ).getAbsolutePath();
+
+        File buildDirFile = new File( basedir, "target" );
+        String buildDir = buildDirFile.getAbsolutePath();
+
+        System.out.println( "Analysing dependencies ..." );
+
+        for ( Iterator i = reader.getDependencies().iterator(); i.hasNext(); )
+        {
+            Dependency dep = (Dependency) i.next();
+
+            if ( modelFileCache.containsKey( dep.getId() ) )
+            {
+                buildProject( resolver.getArtifactFile( dep.getPomDependency() ).getParentFile(), resolver, false );
+            }
+        }
+
+        resolver.downloadDependencies( reader.getDependencies() );
+
+        System.out.println();
+        System.out.println();
+        System.out.println( "Building project in " + basedir );
+
+        line();
+
+        // clean
+        System.out.println( "Cleaning " + buildDirFile + "..." );
+        FileUtils.forceDelete( buildDirFile );
+
+        // ----------------------------------------------------------------------
+        // Generate sources - modello
+        // ----------------------------------------------------------------------
+
+        File generatedSourcesDirectory = null;
+        if ( reader.getPlugins().containsKey( MODELLO_PLUGIN_ID ) )
+        {
+            Plugin plugin = (Plugin) reader.getPlugins().get( MODELLO_PLUGIN_ID );
+
+            File model = new File( basedir, (String) plugin.getConfiguration().get( "model" ) );
+
+            System.out.println( "Model exists!" );
+
+            String modelVersion = (String) plugin.getConfiguration().get( "version" );
+            if ( modelVersion == null || modelVersion.trim().length() < 1 )
+            {
+                System.out.println( "No model version configured. Using \'1.0.0\'..." );
+                modelVersion = "1.0.0";
+            }
+
+            generatedSourcesDirectory = new File( basedir, "target/generated-sources/modello" );
+
+            if ( !generatedSourcesDirectory.exists() )
+            {
+                generatedSourcesDirectory.mkdirs();
+            }
+
+            File artifactFile = resolver.getArtifactFile( plugin.asDependencyPom() );
+            ModelReader pluginReader = readModel( resolver, artifactFile, true );
+
+            ClassLoader classLoader =
+                createClassloaderFromDependencies( pluginReader.getDependencies(), null, resolver );
+
+            System.out.println( "Generating model bindings for version \'" + modelVersion + "\' from '" + model + "'" );
+
+            generateModelloSources( model.getAbsolutePath(), "java", generatedSourcesDirectory, modelVersion, "false",
+                                    classLoader );
+            generateModelloSources( model.getAbsolutePath(), "xpp3-reader", generatedSourcesDirectory, modelVersion,
+                                    "false", classLoader );
+            generateModelloSources( model.getAbsolutePath(), "xpp3-writer", generatedSourcesDirectory, modelVersion,
+                                    "false", classLoader );
+        }
+
+        // ----------------------------------------------------------------------
+        // Standard compile
+        // ----------------------------------------------------------------------
+
+        System.out.println( "Compiling sources ..." );
+
+        compile( reader.getDependencies(), sources, classes, null, generatedSourcesDirectory, Dependency.SCOPE_COMPILE,
+                 resolver );
+
+        // ----------------------------------------------------------------------
+        // Standard resources
+        // ----------------------------------------------------------------------
+
+        System.out.println( "Packaging resources ..." );
+
+        copyResources( resources, classes );
+
+        // ----------------------------------------------------------------------
+        // Create JAR
+        // ----------------------------------------------------------------------
+
+        File jarFile = createJar( new File( basedir, "pom.xml" ), classes, buildDir, reader );
+
+        System.out.println( "Packaging " + jarFile + " ..." );
+
+        resolver.addBuiltArtifact( reader.getGroupId(), reader.getArtifactId(), "jar", jarFile );
+
+        line();
+
+        inProgress.remove( key );
+    }
+
+    private ModelReader readModel( ArtifactResolver resolver, File file, boolean resolveTransitiveDependencies )
+        throws ParserConfigurationException, SAXException, IOException
+    {
+        ModelReader reader = new ModelReader( resolver, resolveTransitiveDependencies );
+
+        reader.parse( file );
+
+        resolver.addBuiltArtifact( reader.getGroupId(), reader.getArtifactId(), "pom", file );
+
+        modelFileCache.put( reader.getGroupId() + ":" + reader.getArtifactId(), file );
+
+        return reader;
+    }
+
+    private void line()
+    {
+        System.out.println( "------------------------------------------------------------------" );
+    }
+
+    private File createJar( File pomFile, String classes, String buildDir, ModelReader reader )
+        throws Exception
+    {
+        JarMojo jarMojo = new JarMojo();
+
+        String artifactId = reader.getArtifactId();
+
+        String version = reader.getVersion();
+
+        // ----------------------------------------------------------------------
+        // Create pom.properties file
+        // ----------------------------------------------------------------------
+
+        Properties p = new Properties();
+
+        p.setProperty( "groupId", reader.getGroupId() );
+
+        p.setProperty( "artifactId", reader.getArtifactId() );
+
+        p.setProperty( "version", reader.getVersion() );
+
+        File pomPropertiesDir =
+            new File( new File( classes ), "META-INF/maven/" + reader.getGroupId() + "/" + reader.getArtifactId() );
+
+        pomPropertiesDir.mkdirs();
+
+        File pomPropertiesFile = new File( pomPropertiesDir, "pom.properties" );
+
+        OutputStream os = new FileOutputStream( pomPropertiesFile );
+
+        p.store( os, "Generated by Maven" );
+
+        os.close(); // stream is flushed but not closed by Properties.store()
+
+        FileUtils.copyFile( pomFile, new File( pomPropertiesDir, "pom.xml" ) );
+
+        File jarFile = new File( buildDir, artifactId + "-" + version + ".jar" );
+        jarMojo.execute( new File( classes ), jarFile );
+
+        return jarFile;
+    }
+
+    public String getCurrentUtcDate()
+    {
+        TimeZone timezone = TimeZone.getTimeZone( "UTC" );
+        DateFormat fmt = new SimpleDateFormat( "yyyyMMddHHmmss" );
+        fmt.setTimeZone( timezone );
+        return fmt.format( new Date() );
+    }
+
+    private void copyResources( String sourceDirectory, String destinationDirectory )
+        throws Exception
+    {
+        File sd = new File( sourceDirectory );
+
+        if ( !sd.exists() )
+        {
+            return;
+        }
+
+        List files = FileUtils.getFiles( sd, "**/**", "**/CVS/**,**/.svn/**", false );
+
+        for ( Iterator i = files.iterator(); i.hasNext(); )
+        {
+            File f = (File) i.next();
+
+            File source = new File( sourceDirectory, f.getPath() );
+
+            File dest = new File( destinationDirectory, f.getPath() );
+
+            if ( !dest.getParentFile().exists() )
+            {
+                dest.getParentFile().mkdirs();
+            }
+
+            FileUtils.copyFile( source, dest );
+        }
+    }
+
+    private static ArtifactResolver setupRepositories( Settings settings )
+        throws Exception
+    {
+        boolean online = true;
+
+        String onlineProperty = System.getProperty( "maven.online" );
+
+        if ( onlineProperty != null && onlineProperty.equals( "false" ) )
+        {
+            online = false;
+        }
+
+        Repository localRepository =
+            new Repository( "local", settings.getLocalRepository(), Repository.LAYOUT_DEFAULT, false, false );
+
+        File repoLocalFile = new File( localRepository.getBasedir() );
+        repoLocalFile.mkdirs();
+
+        if ( !repoLocalFile.canWrite() )
+        {
+            throw new Exception( "Can't write to " + repoLocalFile );
+        }
+
+        ArtifactResolver resolver;
+        if ( online )
+        {
+            OnlineArtifactDownloader downloader = new OnlineArtifactDownloader( localRepository );
+            resolver = downloader;
+            if ( settings.getActiveProxy() != null )
+            {
+                Proxy proxy = settings.getActiveProxy();
+                downloader.setProxy( proxy.getHost(), proxy.getPort(), proxy.getUserName(), proxy.getPassword() );
+            }
+
+            List remoteRepos = downloader.getRemoteRepositories();
+            List newRemoteRepos = new ArrayList();
+
+            for ( Iterator i = remoteRepos.iterator(); i.hasNext(); )
+            {
+                Repository repo = (Repository) i.next();
+
+                boolean foundMirror = false;
+                for ( Iterator j = settings.getMirrors().iterator(); j.hasNext() && !foundMirror; )
+                {
+                    Mirror m = (Mirror) j.next();
+                    if ( m.getMirrorOf().equals( repo.getId() ) )
+                    {
+                        newRemoteRepos.add( new Repository( m.getId(), m.getUrl(), repo.getLayout(), repo.isSnapshots(),
+                                                            repo.isReleases() ) );
+                        foundMirror = true;
+                    }
+                }
+                if ( !foundMirror )
+                {
+                    newRemoteRepos.add( repo );
+                }
+            }
+
+            downloader.setRemoteRepositories( newRemoteRepos );
+
+            System.out.println( "Using the following for your local repository: " + localRepository );
+            System.out.println( "Using the following for your remote repository: " + newRemoteRepos );
+        }
+        else
+        {
+            resolver = new OfflineArtifactResolver( localRepository );
+        }
+
+        return resolver;
+    }
+
+    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 );
+    }
+
+    private void compile( Collection dependencies, String sourceDirectory, String outputDirectory,
+                          String extraClasspath, File generatedSources, String scope, ArtifactResolver resolver )
+        throws Exception
+    {
+        JavacCompiler compiler = new JavacCompiler();
+
+        String[] sourceDirectories = null;
+
+        if ( generatedSources != null )
+        {
+            // We might only have generated sources
+
+            if ( new File( sourceDirectory ).exists() )
+            {
+                sourceDirectories = new String[]{sourceDirectory, generatedSources.getAbsolutePath()};
+            }
+            else
+            {
+                sourceDirectories = new String[]{generatedSources.getAbsolutePath()};
+            }
+        }
+        else
+        {
+            if ( new File( sourceDirectory ).exists() )
+            {
+                sourceDirectories = new String[]{sourceDirectory};
+            }
+        }
+
+        if ( sourceDirectories != null )
+        {
+            CompilerConfiguration compilerConfiguration = new CompilerConfiguration();
+            compilerConfiguration.setOutputLocation( outputDirectory );
+            List classpathEntries = classpath( dependencies, extraClasspath, scope, resolver );
+            compilerConfiguration.setNoWarn( true );
+            compilerConfiguration.setClasspathEntries( classpathEntries );
+            compilerConfiguration.setSourceLocations( Arrays.asList( sourceDirectories ) );
+
+            /* Compile with debugging info */
+            String debugAsString = System.getProperty( "maven.compiler.debug", "true" );
+
+            if ( !Boolean.valueOf( debugAsString ).booleanValue() )
+            {
+                compilerConfiguration.setDebug( false );
+            }
+            else
+            {
+                compilerConfiguration.setDebug( true );
+            }
+
+            List messages = compiler.compile( compilerConfiguration );
+
+            for ( Iterator i = messages.iterator(); i.hasNext(); )
+            {
+                System.out.println( i.next() );
+            }
+
+            if ( messages.size() > 0 )
+            {
+                throw new Exception( "Compilation error." );
+            }
+        }
+    }
+
+    private List classpath( Collection dependencies, String extraClasspath, String scope, ArtifactResolver resolver )
+    {
+        List classpath = new ArrayList( dependencies.size() + 1 );
+
+        for ( Iterator i = dependencies.iterator(); i.hasNext(); )
+        {
+            Dependency d = (Dependency) i.next();
+
+            String element = resolver.getArtifactFile( d ).getAbsolutePath();
+
+            if ( Dependency.SCOPE_COMPILE.equals( scope ) )
+            {
+                if ( d.getScope().equals( Dependency.SCOPE_COMPILE ) )
+                {
+                    classpath.add( element );
+                }
+            }
+            else if ( Dependency.SCOPE_RUNTIME.equals( scope ) )
+            {
+                if ( d.getScope().equals( Dependency.SCOPE_COMPILE ) ||
+                    d.getScope().equals( Dependency.SCOPE_RUNTIME ) )
+                {
+                    classpath.add( element );
+                }
+            }
+            else if ( Dependency.SCOPE_TEST.equals( scope ) )
+            {
+                classpath.add( element );
+            }
+        }
+
+        if ( extraClasspath != null )
+        {
+            classpath.add( extraClasspath );
+        }
+
+        return classpath;
+    }
+
+    private void generateModelloSources( String model, String mode, File dir, String modelVersion,
+                                         String packageWithVersion, ClassLoader modelloClassLoader )
+        throws Exception
+    {
+        Class c = modelloClassLoader.loadClass( "org.codehaus.modello.ModelloCli" );
+
+        Object generator = c.newInstance();
+
+        Method m = c.getMethod( "main", new Class[]{String[].class} );
+
+        String[] args = new String[]{model, mode, dir.getAbsolutePath(), modelVersion, packageWithVersion};
+
+        ClassLoader old = Thread.currentThread().getContextClassLoader();
+
+        Thread.currentThread().setContextClassLoader( modelloClassLoader );
+
+        m.invoke( generator, new Object[]{args} );
+
+        Thread.currentThread().setContextClassLoader( old );
+    }
+
+    private IsolatedClassLoader createClassloaderFromDependencies( Collection dependencies, ClassLoader parent,
+                                                                   ArtifactResolver resolver )
+        throws Exception
+    {
+        System.out.println( "Checking for dependencies ..." );
+
+        resolver.downloadDependencies( dependencies );
+
+        IsolatedClassLoader cl;
+        if ( parent == null )
+        {
+            cl = new IsolatedClassLoader();
+        }
+        else
+        {
+            cl = new IsolatedClassLoader( parent );
+        }
+
+        for ( Iterator i = dependencies.iterator(); i.hasNext(); )
+        {
+            Dependency dependency = (Dependency) i.next();
+
+            File f = resolver.getArtifactFile( dependency );
+            if ( !f.exists() )
+            {
+                String msg =
+                    ( !resolver.isOnline() ? "; run again online" : "; there was a problem downloading it earlier" );
+                throw new FileNotFoundException( "Missing dependency: " + dependency + msg );
+            }
+
+            cl.addURL( f.toURL() );
+        }
+
+        return cl;
+    }
+}

Propchange: maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/Bootstrap.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/Bootstrap.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Copied: maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/compile/AbstractCompiler.java (from r332227, maven/components/trunk/maven-mboot2/src/main/java/compile/AbstractCompiler.java)
URL: http://svn.apache.org/viewcvs/maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/compile/AbstractCompiler.java?p2=maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/compile/AbstractCompiler.java&p1=maven/components/trunk/maven-mboot2/src/main/java/compile/AbstractCompiler.java&r1=332227&r2=332580&rev=332580&view=diff
==============================================================================
--- maven/components/trunk/maven-mboot2/src/main/java/compile/AbstractCompiler.java (original)
+++ maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/compile/AbstractCompiler.java Fri Nov 11 07:05:53 2005
@@ -1,6 +1,22 @@
-package compile;
+package org.apache.maven.bootstrap.compile;
 
-import util.DirectoryScanner;
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.bootstrap.util.DirectoryScanner;
 
 import java.io.File;
 import java.io.IOException;

Copied: maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/compile/Compiler.java (from r332227, maven/components/trunk/maven-mboot2/src/main/java/compile/Compiler.java)
URL: http://svn.apache.org/viewcvs/maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/compile/Compiler.java?p2=maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/compile/Compiler.java&p1=maven/components/trunk/maven-mboot2/src/main/java/compile/Compiler.java&r1=332227&r2=332580&rev=332580&view=diff
==============================================================================
--- maven/components/trunk/maven-mboot2/src/main/java/compile/Compiler.java (original)
+++ maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/compile/Compiler.java Fri Nov 11 07:05:53 2005
@@ -1,7 +1,22 @@
-package compile;
+package org.apache.maven.bootstrap.compile;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 
 import java.util.List;
-import java.util.Map;
 
 /**
  *

Copied: maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/compile/CompilerConfiguration.java (from r332227, maven/components/trunk/maven-mboot2/src/main/java/compile/CompilerConfiguration.java)
URL: http://svn.apache.org/viewcvs/maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/compile/CompilerConfiguration.java?p2=maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/compile/CompilerConfiguration.java&p1=maven/components/trunk/maven-mboot2/src/main/java/compile/CompilerConfiguration.java&r1=332227&r2=332580&rev=332580&view=diff
==============================================================================
--- maven/components/trunk/maven-mboot2/src/main/java/compile/CompilerConfiguration.java (original)
+++ maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/compile/CompilerConfiguration.java Fri Nov 11 07:05:53 2005
@@ -1,5 +1,20 @@
-/* Created on Oct 4, 2004 */
-package compile;
+package org.apache.maven.bootstrap.compile;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 
 import java.util.Collections;
 import java.util.HashSet;
@@ -8,7 +23,6 @@
 import java.util.Map;
 import java.util.Set;
 import java.util.TreeMap;
-
 
 /**
  * @author jdcasey

Copied: maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/compile/CompilerError.java (from r332227, maven/components/trunk/maven-mboot2/src/main/java/compile/CompilerError.java)
URL: http://svn.apache.org/viewcvs/maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/compile/CompilerError.java?p2=maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/compile/CompilerError.java&p1=maven/components/trunk/maven-mboot2/src/main/java/compile/CompilerError.java&r1=332227&r2=332580&rev=332580&view=diff
==============================================================================
--- maven/components/trunk/maven-mboot2/src/main/java/compile/CompilerError.java (original)
+++ maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/compile/CompilerError.java Fri Nov 11 07:05:53 2005
@@ -1,21 +1,20 @@
-/**
- *
- * Copyright 2004 The Apache Software Foundation
+package org.apache.maven.bootstrap.compile;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
  *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
  *
- *     http://www.apache.org/licenses/LICENSE-2.0
+ *      http://www.apache.org/licenses/LICENSE-2.0
  *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
-
-package compile;
 
 /**
  * This class encapsulates an error message produced by a programming language

Copied: maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/compile/JavacCompiler.java (from r332227, maven/components/trunk/maven-mboot2/src/main/java/compile/JavacCompiler.java)
URL: http://svn.apache.org/viewcvs/maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/compile/JavacCompiler.java?p2=maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/compile/JavacCompiler.java&p1=maven/components/trunk/maven-mboot2/src/main/java/compile/JavacCompiler.java&r1=332227&r2=332580&rev=332580&view=diff
==============================================================================
--- maven/components/trunk/maven-mboot2/src/main/java/compile/JavacCompiler.java (original)
+++ maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/compile/JavacCompiler.java Fri Nov 11 07:05:53 2005
@@ -1,23 +1,22 @@
-/**
- *
- * Copyright 2004 The Apache Software Foundation
+package org.apache.maven.bootstrap.compile;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
  *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
  *
- *     http://www.apache.org/licenses/LICENSE-2.0
+ *      http://www.apache.org/licenses/LICENSE-2.0
  *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 
-package compile;
-
-import util.IsolatedClassLoader;
+import org.apache.maven.bootstrap.util.IsolatedClassLoader;
 
 import java.io.BufferedReader;
 import java.io.ByteArrayInputStream;
@@ -164,9 +163,9 @@
     {
         List errors = new ArrayList();
 
-        String line = null;
+        String line;
 
-        StringBuffer buffer = null;
+        StringBuffer buffer;
 
         while ( true )
         {

Added: maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/download/AbstractArtifactResolver.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/download/AbstractArtifactResolver.java?rev=332580&view=auto
==============================================================================
--- maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/download/AbstractArtifactResolver.java (added)
+++ maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/download/AbstractArtifactResolver.java Fri Nov 11 07:05:53 2005
@@ -0,0 +1,78 @@
+package org.apache.maven.bootstrap.download;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.bootstrap.model.Repository;
+import org.apache.maven.bootstrap.model.Dependency;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.io.File;
+
+/**
+ */
+public abstract class AbstractArtifactResolver
+    implements ArtifactResolver
+{
+    private Repository localRepository;
+
+    private Map builtArtifacts = new HashMap();
+
+    protected AbstractArtifactResolver( Repository localRepository )
+    {
+        if ( localRepository == null )
+        {
+            System.err.println( "local repository not specified" );
+
+            System.exit( 1 );
+        }
+
+        this.localRepository = localRepository;
+    }
+
+    public Repository getLocalRepository()
+    {
+        return localRepository;
+    }
+
+    public void addBuiltArtifact( String groupId, String artifactId, String type, File jarFile )
+    {
+        builtArtifacts.put( groupId + ":" + artifactId + ":" + type, jarFile );
+    }
+
+    public boolean isAlreadyBuilt( Dependency dep )
+    {
+        return builtArtifacts.containsKey( dep.getConflictId() );
+    }
+
+    public boolean isAlreadyBuilt( String conflictId )
+    {
+        return builtArtifacts.containsKey( conflictId );
+    }
+
+    public File getArtifactFile( Dependency dependency )
+    {
+        if ( isAlreadyBuilt( dependency ) )
+        {
+            return (File) builtArtifacts.get( dependency.getConflictId() );
+        }
+        else
+        {
+            return localRepository.getArtifactFile( dependency );
+        }
+    }
+}

Propchange: maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/download/AbstractArtifactResolver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/download/AbstractArtifactResolver.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/download/ArtifactResolver.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/download/ArtifactResolver.java?rev=332580&view=auto
==============================================================================
--- maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/download/ArtifactResolver.java (added)
+++ maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/download/ArtifactResolver.java Fri Nov 11 07:05:53 2005
@@ -0,0 +1,44 @@
+package org.apache.maven.bootstrap.download;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.bootstrap.model.Repository;
+import org.apache.maven.bootstrap.model.Dependency;
+
+import java.util.Collection;
+import java.io.File;
+
+/**
+ * Artifact resolver.
+ */
+public interface ArtifactResolver
+{
+    void downloadDependencies( Collection dependencies )
+        throws DownloadFailedException;
+
+    Repository getLocalRepository();
+
+    void addBuiltArtifact( String groupId, String artifactId, String type, File jarFile );
+
+    boolean isAlreadyBuilt( Dependency dep );
+
+    File getArtifactFile( Dependency dependency );
+
+    boolean isOnline();
+
+    boolean isAlreadyBuilt( String key );
+}

Propchange: maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/download/ArtifactResolver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/download/ArtifactResolver.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/download/Base64.java (from r330467, maven/components/trunk/maven-mboot2/src/main/java/download/Base64.java)
URL: http://svn.apache.org/viewcvs/maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/download/Base64.java?p2=maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/download/Base64.java&p1=maven/components/trunk/maven-mboot2/src/main/java/download/Base64.java&r1=330467&r2=332580&rev=332580&view=diff
==============================================================================
--- maven/components/trunk/maven-mboot2/src/main/java/download/Base64.java (original)
+++ maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/download/Base64.java Fri Nov 11 07:05:53 2005
@@ -1,27 +1,22 @@
-package download;
+package org.apache.maven.bootstrap.download;
 
 /*
- * ====================================================================
- * Copyright 2001-2004 The Apache Software Foundation.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy
- * of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
  * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- * ====================================================================
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 
 import java.io.ByteArrayOutputStream;
-
-// import org.apache.commons.logging.Log;
-// import org.apache.commons.logging.LogFactory;
 
 /**
  * Encode/Decode Base-64.

Copied: maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/download/DownloadFailedException.java (from r330467, maven/components/trunk/maven-mboot2/src/main/java/download/DownloadFailedException.java)
URL: http://svn.apache.org/viewcvs/maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/download/DownloadFailedException.java?p2=maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/download/DownloadFailedException.java&p1=maven/components/trunk/maven-mboot2/src/main/java/download/DownloadFailedException.java&r1=330467&r2=332580&rev=332580&view=diff
==============================================================================
--- maven/components/trunk/maven-mboot2/src/main/java/download/DownloadFailedException.java (original)
+++ maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/download/DownloadFailedException.java Fri Nov 11 07:05:53 2005
@@ -1,14 +1,14 @@
-package download;
+package org.apache.maven.bootstrap.download;
 
 /*
  * Copyright 2001-2005 The Apache Software Foundation.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

Copied: maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/download/HttpUtils.java (from r330467, maven/components/trunk/maven-mboot2/src/main/java/download/HttpUtils.java)
URL: http://svn.apache.org/viewcvs/maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/download/HttpUtils.java?p2=maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/download/HttpUtils.java&p1=maven/components/trunk/maven-mboot2/src/main/java/download/HttpUtils.java&r1=330467&r2=332580&rev=332580&view=diff
==============================================================================
--- maven/components/trunk/maven-mboot2/src/main/java/download/HttpUtils.java (original)
+++ maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/download/HttpUtils.java Fri Nov 11 07:05:53 2005
@@ -1,20 +1,19 @@
-package download;
+package org.apache.maven.bootstrap.download;
 
-/* ====================================================================
- *   Copyright 2001-2004 The Apache Software Foundation.
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
  *
- *   Licensed under the Apache License, Version 2.0 (the "License");
- *   you may not use this file except in compliance with the License.
- *   You may obtain a copy of the License at
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
  *
- *       http://www.apache.org/licenses/LICENSE-2.0
+ *      http://www.apache.org/licenses/LICENSE-2.0
  *
- *   Unless required by applicable law or agreed to in writing, software
- *   distributed under the License is distributed on an "AS IS" BASIS,
- *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *   See the License for the specific language governing permissions and
- *   limitations under the License.
- * ====================================================================
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 
 import java.io.File;
@@ -219,7 +218,7 @@
             // test for 404 ourselves, and throw FileNotFoundException as needed
             if ( httpConnection.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND )
             {
-                throw new FileNotFoundException( url.toString() + " (HTTP Error: " + httpConnection.getResponseCode() +
+                throw new FileNotFoundException( url + " (HTTP Error: " + httpConnection.getResponseCode() +
                     " " + httpConnection.getResponseMessage() + ")" );
             }
             if ( httpConnection.getResponseCode() == HttpURLConnection.HTTP_NOT_MODIFIED )

Added: maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/download/OfflineArtifactResolver.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/download/OfflineArtifactResolver.java?rev=332580&view=auto
==============================================================================
--- maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/download/OfflineArtifactResolver.java (added)
+++ maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/download/OfflineArtifactResolver.java Fri Nov 11 07:05:53 2005
@@ -0,0 +1,44 @@
+package org.apache.maven.bootstrap.download;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.bootstrap.model.Repository;
+
+import java.util.Collection;
+
+/**
+ * Resolve from the local repository - don't attempt to download or check out.
+ */
+public class OfflineArtifactResolver
+    extends AbstractArtifactResolver
+{
+    public OfflineArtifactResolver( Repository localRepository )
+    {
+        super( localRepository );
+    }
+
+    public void downloadDependencies( Collection dependencies )
+        throws DownloadFailedException
+    {
+        // Nothing to see here
+    }
+
+    public boolean isOnline()
+    {
+        return false;
+    }
+}

Propchange: maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/download/OfflineArtifactResolver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/download/OfflineArtifactResolver.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/download/OnlineArtifactDownloader.java (from r330467, maven/components/trunk/maven-mboot2/src/main/java/download/ArtifactDownloader.java)
URL: http://svn.apache.org/viewcvs/maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/download/OnlineArtifactDownloader.java?p2=maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/download/OnlineArtifactDownloader.java&p1=maven/components/trunk/maven-mboot2/src/main/java/download/ArtifactDownloader.java&r1=330467&r2=332580&rev=332580&view=diff
==============================================================================
--- maven/components/trunk/maven-mboot2/src/main/java/download/ArtifactDownloader.java (original)
+++ maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/download/OnlineArtifactDownloader.java Fri Nov 11 07:05:53 2005
@@ -1,7 +1,25 @@
-package download;
+package org.apache.maven.bootstrap.download;
 
-import model.Dependency;
-import model.Repository;
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.bootstrap.model.Dependency;
+import org.apache.maven.bootstrap.model.Repository;
+import org.apache.maven.bootstrap.util.FileUtils;
+import org.apache.maven.bootstrap.util.StringUtils;
 
 import java.io.File;
 import java.io.FileNotFoundException;
@@ -13,10 +31,8 @@
 import java.util.List;
 import java.util.Map;
 
-import util.FileUtils;
-import util.StringUtils;
-
-public class ArtifactDownloader
+public class OnlineArtifactDownloader
+    extends AbstractArtifactResolver
 {
     public static final String SNAPSHOT_SIGNATURE = "-SNAPSHOT";
 
@@ -32,25 +48,16 @@
 
     private String proxyPassword;
 
-    private Repository localRepository;
-
     private static final String REPO_URL = "http://repo1.maven.org/maven2";
 
     private Map downloadedArtifacts = new HashMap();
 
     private List remoteRepositories;
 
-    public ArtifactDownloader( Repository localRepository )
+    public OnlineArtifactDownloader( Repository localRepository )
         throws Exception
     {
-        if ( localRepository == null )
-        {
-            System.err.println( "local repository not specified" );
-
-            System.exit( 1 );
-        }
-
-        this.localRepository = localRepository;
+        super( localRepository );
     }
 
     public void setProxy( String host, String port, String userName, String password )
@@ -69,10 +76,15 @@
         {
             Dependency dep = (Dependency) j.next();
 
+            if ( isAlreadyBuilt( dep ) )
+            {
+                continue;
+            }
+
             String dependencyConflictId = dep.getDependencyConflictId();
             if ( !downloadedArtifacts.containsKey( dependencyConflictId ) )
             {
-                File destinationFile = localRepository.getArtifactFile( dep );
+                File destinationFile = getLocalRepository().getArtifactFile( dep );
                 // The directory structure for this project may
                 // not exists so create it if missing.
                 File directory = destinationFile.getParentFile();
@@ -82,14 +94,6 @@
                     directory.mkdirs();
                 }
 
-                boolean snapshot = isSnapshot( dep );
-
-                if ( "org.apache.maven".equals( dep.getGroupId() ) && snapshot )
-                {
-                    //skip our own
-                    continue;
-                }
-
                 if ( !getRemoteArtifact( dep, destinationFile ) )
                 {
                     throw new DownloadFailedException( "Failed to download " + dep );
@@ -105,6 +109,11 @@
         }
     }
 
+    public boolean isOnline()
+    {
+        return true;
+    }
+
     private static boolean isSnapshot( Dependency dep )
     {
         return dep.getVersion().indexOf( SNAPSHOT_SIGNATURE ) >= 0;
@@ -139,11 +148,11 @@
                 if ( snapshot )
                 {
                     String filename = "maven-metadata-" + remoteRepo.getId() + ".xml";
-                    File localFile = localRepository.getMetadataFile( dep.getGroupId(), dep.getArtifactId(),
-                                                                      dep.getVersion(), dep.getType(),
-                                                                      "maven-metadata-local.xml" );
-                    File remoteFile = localRepository.getMetadataFile( dep.getGroupId(), dep.getArtifactId(),
-                                                                       dep.getVersion(), dep.getType(), filename );
+                    File localFile = getLocalRepository().getMetadataFile( dep.getGroupId(), dep.getArtifactId(),
+                                                                           dep.getVersion(), dep.getType(),
+                                                                           "maven-metadata-local.xml" );
+                    File remoteFile = getLocalRepository().getMetadataFile( dep.getGroupId(), dep.getArtifactId(),
+                                                                            dep.getVersion(), dep.getType(), filename );
                     String metadataPath = remoteRepo.getMetadataPath( dep.getGroupId(), dep.getArtifactId(),
                                                                       dep.getVersion(), dep.getType(),
                                                                       "maven-metadata.xml" );
@@ -170,9 +179,9 @@
                         else
                         {
                             RepositoryMetadata localMetadata = RepositoryMetadata.read( localFile );
-                            
+
                             RepositoryMetadata remoteMetadata = RepositoryMetadata.read( remoteFile );
-                            
+
                             if ( remoteMetadata.getLastUpdatedUtc() > localMetadata.getLastUpdatedUtc() )
                             {
                                 file = remoteFile;
@@ -198,8 +207,8 @@
                         dep.setResolvedVersion( version );
                         if ( !version.endsWith( "SNAPSHOT" ) )
                         {
-                            String ver = version.substring(
-                                version.lastIndexOf( "-", version.lastIndexOf( "-" ) - 1 ) + 1 );
+                            String ver =
+                                version.substring( version.lastIndexOf( "-", version.lastIndexOf( "-" ) - 1 ) + 1 );
                             String extension = url.substring( url.length() - 4 );
                             url = getSnapshotMetadataFile( url, ver + extension );
                         }
@@ -213,8 +222,8 @@
                 if ( !"pom".equals( dep.getType() ) )
                 {
                     String name = dep.getArtifactId() + "-" + dep.getResolvedVersion() + ".pom";
-                    File file = localRepository.getMetadataFile( dep.getGroupId(), dep.getArtifactId(),
-                                                                 dep.getVersion(), dep.getType(), name );
+                    File file = getLocalRepository().getMetadataFile( dep.getGroupId(), dep.getArtifactId(),
+                                                                      dep.getVersion(), dep.getType(), name );
 
                     file.getParentFile().mkdirs();
 
@@ -238,7 +247,7 @@
                     }
                 }
 
-                destinationFile = localRepository.getArtifactFile( dep );
+                destinationFile = getLocalRepository().getArtifactFile( dep );
                 if ( !destinationFile.exists() )
                 {
                     log( "Downloading " + url );
@@ -295,11 +304,6 @@
     private void log( String message )
     {
         System.out.println( message );
-    }
-
-    public Repository getLocalRepository()
-    {
-        return localRepository;
     }
 
     public List getRemoteRepositories()

Propchange: maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/download/OnlineArtifactDownloader.java
------------------------------------------------------------------------------
    cvs2svn:cvs-rev = 1.17

Propchange: maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/download/OnlineArtifactDownloader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/download/OnlineArtifactDownloader.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/download/RepositoryMetadata.java (from r330467, maven/components/trunk/maven-mboot2/src/main/java/download/RepositoryMetadata.java)
URL: http://svn.apache.org/viewcvs/maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/download/RepositoryMetadata.java?p2=maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/download/RepositoryMetadata.java&p1=maven/components/trunk/maven-mboot2/src/main/java/download/RepositoryMetadata.java&r1=330467&r2=332580&rev=332580&view=diff
==============================================================================
--- maven/components/trunk/maven-mboot2/src/main/java/download/RepositoryMetadata.java (original)
+++ maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/download/RepositoryMetadata.java Fri Nov 11 07:05:53 2005
@@ -1,4 +1,4 @@
-package download;
+package org.apache.maven.bootstrap.download;
 
 /*
  * Copyright 2001-2005 The Apache Software Foundation.
@@ -16,10 +16,10 @@
  * limitations under the License.
  */
 
+import org.apache.maven.bootstrap.util.AbstractReader;
+import org.apache.maven.bootstrap.util.StringUtils;
 import org.xml.sax.Attributes;
 import org.xml.sax.SAXException;
-import util.AbstractReader;
-import util.StringUtils;
 
 import javax.xml.parsers.ParserConfigurationException;
 import java.io.File;
@@ -30,7 +30,6 @@
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
-import java.util.Date;
 import java.util.Iterator;
 import java.util.List;
 import java.util.TimeZone;
@@ -161,9 +160,7 @@
     public static RepositoryMetadata read( File file )
         throws IOException, ParserConfigurationException, SAXException
     {
-        RepositoryMetadata metadata = new RepositoryMetadata();
-        new Reader( metadata ).parse( file );
-        return metadata;
+        return new Reader().parseMetadata( file );
     }
 
     public void write( File file )
@@ -185,6 +182,7 @@
     {
         TimeZone timezone = TimeZone.getTimeZone( "UTC" );
         DateFormat fmt = new SimpleDateFormat( "yyyyMMddHHmmss" );
+        fmt.setTimeZone( timezone );
         
         try
         {
@@ -215,13 +213,15 @@
 
         private boolean insideSnapshot;
 
-        private final RepositoryMetadata metadata;
+        private final RepositoryMetadata metadata = new RepositoryMetadata();
 
         private boolean insideVersions;
 
-        public Reader( RepositoryMetadata metadata )
+        public RepositoryMetadata parseMetadata( File metadataFile )
+            throws IOException, ParserConfigurationException, SAXException
         {
-            this.metadata = metadata;
+            parse( metadataFile );
+            return metadata;
         }
 
         public void startElement( String uri, String localName, String rawName, Attributes attributes )

Copied: maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/model/Dependency.java (from r331671, maven/components/trunk/maven-mboot2/src/main/java/model/Dependency.java)
URL: http://svn.apache.org/viewcvs/maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/model/Dependency.java?p2=maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/model/Dependency.java&p1=maven/components/trunk/maven-mboot2/src/main/java/model/Dependency.java&r1=331671&r2=332580&rev=332580&view=diff
==============================================================================
--- maven/components/trunk/maven-mboot2/src/main/java/model/Dependency.java (original)
+++ maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/model/Dependency.java Fri Nov 11 07:05:53 2005
@@ -1,9 +1,4 @@
-package model;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
+package org.apache.maven.bootstrap.model;
 
 /*
  * Copyright 2001-2005 The Apache Software Foundation.
@@ -21,6 +16,11 @@
  * limitations under the License.
  */
 
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
 /**
  * Describes a dependency.
  *
@@ -207,12 +207,8 @@
 
     private boolean isValid( String value )
     {
-        if ( value != null && value.trim().equals( "" ) == false )
-        {
-            return true;
-        }
+        return value != null && !value.trim().equals( "" );
 
-        return false;
     }
 
     public String toString()
@@ -300,5 +296,10 @@
     public List getChain()
     {
         return chain;
+    }
+
+    public Dependency getPomDependency()
+    {
+        return new Dependency( groupId, artifactId, version, "pom", chain );
     }
 }

Copied: maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/model/Exclusion.java (from r331671, maven/components/trunk/maven-mboot2/src/main/java/model/Exclusion.java)
URL: http://svn.apache.org/viewcvs/maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/model/Exclusion.java?p2=maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/model/Exclusion.java&p1=maven/components/trunk/maven-mboot2/src/main/java/model/Exclusion.java&r1=331671&r2=332580&rev=332580&view=diff
==============================================================================
--- maven/components/trunk/maven-mboot2/src/main/java/model/Exclusion.java (original)
+++ maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/model/Exclusion.java Fri Nov 11 07:05:53 2005
@@ -1,4 +1,4 @@
-package model;
+package org.apache.maven.bootstrap.model;
 
 /*
  * Copyright 2001-2005 The Apache Software Foundation.

Copied: maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/model/ModelReader.java (from r331671, maven/components/trunk/maven-mboot2/src/main/java/model/ModelReader.java)
URL: http://svn.apache.org/viewcvs/maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/model/ModelReader.java?p2=maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/model/ModelReader.java&p1=maven/components/trunk/maven-mboot2/src/main/java/model/ModelReader.java&r1=331671&r2=332580&rev=332580&view=diff
==============================================================================
--- maven/components/trunk/maven-mboot2/src/main/java/model/ModelReader.java (original)
+++ maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/model/ModelReader.java Fri Nov 11 07:05:53 2005
@@ -1,4 +1,4 @@
-package model;
+package org.apache.maven.bootstrap.model;
 
 /*
  * Copyright 2001-2005 The Apache Software Foundation.
@@ -16,13 +16,14 @@
  * limitations under the License.
  */
 
-import download.ArtifactDownloader;
-import download.DownloadFailedException;
+import org.apache.maven.bootstrap.download.DownloadFailedException;
+import org.apache.maven.bootstrap.download.ArtifactResolver;
+import org.apache.maven.bootstrap.util.AbstractReader;
 import org.xml.sax.Attributes;
 import org.xml.sax.SAXException;
-import util.AbstractReader;
 
 import javax.xml.parsers.ParserConfigurationException;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -32,7 +33,8 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.io.IOException;
+
+import com.sun.corba.se.impl.ior.ObjectAdapterIdArray;
 
 /**
  * Parse a POM.
@@ -64,8 +66,6 @@
 
     private List resources = new ArrayList();
 
-    private List testResources = new ArrayList();
-
     private Map managedDependencies = new HashMap();
 
     private Dependency currentDependency;
@@ -86,7 +86,7 @@
 
     private Repository currentRepository;
 
-    private final ArtifactDownloader downloader;
+    private final ArtifactResolver resolver;
 
     private static Set inProgress = new HashSet();
 
@@ -110,15 +110,27 @@
 
     private final String inheritedScope;
 
-    public ModelReader( ArtifactDownloader downloader, boolean resolveTransitiveDependencies )
+    private Map plugins = new HashMap();
+
+    private boolean insideConfiguration;
+
+    private boolean insideBuild;
+
+    private Plugin currentPlugin;
+
+    private boolean insidePlugin;
+
+    private List modules = new ArrayList();
+
+    public ModelReader( ArtifactResolver resolver, boolean resolveTransitiveDependencies )
     {
-        this( downloader, null, resolveTransitiveDependencies, Collections.EMPTY_SET, Collections.EMPTY_LIST );
+        this( resolver, null, resolveTransitiveDependencies, Collections.EMPTY_SET, Collections.EMPTY_LIST );
     }
 
-    public ModelReader( ArtifactDownloader downloader, String inheritedScope, boolean resolveTransitiveDependencies,
+    public ModelReader( ArtifactResolver resolver, String inheritedScope, boolean resolveTransitiveDependencies,
                         Set excluded, List chain )
     {
-        this.downloader = downloader;
+        this.resolver = resolver;
 
         this.resolveTransitiveDependencies = resolveTransitiveDependencies;
 
@@ -175,6 +187,16 @@
 
             insideDependency = true;
         }
+        else if ( rawName.equals( "build" ) && depth == 1 )
+        {
+            insideBuild = true;
+        }
+        else if ( rawName.equals( "plugin" ) )
+        {
+            currentPlugin = new Plugin();
+
+            insidePlugin = true;
+        }
         else if ( rawName.equals( "dependencyManagement" ) )
         {
             insideDependencyManagement = true;
@@ -205,6 +227,10 @@
 
             currentExclusion = new Exclusion();
         }
+        else if ( rawName.equals( "configuration" ) && insidePlugin )
+        {
+            insideConfiguration = true;
+        }
         depth++;
     }
 
@@ -289,18 +315,26 @@
 
             insideResource = false;
         }
-        else if ( rawName.equals( "testResource" ) )
-        {
-            testResources.add( currentResource );
-
-            insideResource = false;
-        }
         else if ( rawName.equals( "repository" ) )
         {
             repositories.add( currentRepository );
 
             insideRepository = false;
         }
+        else if ( rawName.equals( "plugin" ) )
+        {
+            plugins.put( currentPlugin.getId(), currentPlugin );
+
+            insidePlugin = false;
+        }
+        else if ( rawName.equals( "build" ) )
+        {
+            insideBuild = false;
+        }
+        else if ( rawName.equals( "module" ) )
+        {
+            modules.add( getBodyText() );
+        }
         else if ( insideParent )
         {
             if ( rawName.equals( "groupId" ) )
@@ -358,6 +392,32 @@
                 currentDependency.setScope( getBodyText() );
             }
         }
+        else if ( insideBuild && insidePlugin )
+        {
+            if ( insideConfiguration )
+            {
+                if ( rawName.equals( "configuration" ) )
+                {
+                    insideConfiguration = false;
+                }
+                else
+                {
+                    currentPlugin.getConfiguration().put( rawName, getBodyText() );
+                }
+            }
+            else if ( rawName.equals( "groupId" ) )
+            {
+                currentPlugin.setGroupId( getBodyText() );
+            }
+            else if ( rawName.equals( "artifactId" ) )
+            {
+                currentPlugin.setArtifactId( getBodyText() );
+            }
+            else if ( rawName.equals( "version" ) )
+            {
+                currentPlugin.setVersion( getBodyText() );
+            }
+        }
         else if ( insideResource )
         {
             if ( rawName.equals( "directory" ) )
@@ -426,8 +486,11 @@
                 packaging = getBodyText();
             }
         }
-        else if ( depth == 1 ) // model / project
+
+        if ( depth == 1 ) // model / project
         {
+            resolver.addBuiltArtifact( groupId, artifactId, "pom", pomFile );
+
             resolveDependencies();
         }
 
@@ -494,12 +557,11 @@
 
                 if ( !hasDependency( d, target ) && !excluded.contains( d.getConflictId() ) )
                 {
-                    if ( "plexus".equals( d.getGroupId() ) && ( "plexus-utils".equals( d.getArtifactId() ) ||
-                        "plexus-container-default".equals( d.getArtifactId() ) ) )
+                    if ( !"plexus".equals( d.getGroupId() ) || ( !"plexus-utils".equals( d.getArtifactId() ) &&
+                        !"plexus-container-default".equals( d.getArtifactId() ) ) )
                     {
-                        throw new IllegalStateException( d.getConflictId() + " found in chain " + d.getChain() );
+                        target.put( d.getConflictId(), d );
                     }
-                    target.put( d.getConflictId(), d );
                 }
             }
         }
@@ -538,16 +600,15 @@
 
         inProgress.add( key );
 
-        ModelReader p = new ModelReader( downloader, inheritedScope, resolveTransitiveDependencies, excluded, chain );
+        ModelReader p = new ModelReader( resolver, inheritedScope, resolveTransitiveDependencies, excluded, chain );
 
         try
         {
-            Dependency pom = new Dependency( groupId, artifactId, version, type, chain );
-            downloader.downloadDependencies( Collections.singletonList( pom ) );
+            Dependency pom = new Dependency( groupId, artifactId, version, "pom", chain );
+
+            resolver.downloadDependencies( Collections.singletonList( pom ) );
 
-            Repository localRepository = downloader.getLocalRepository();
-            p.parse( localRepository.getMetadataFile( groupId, artifactId, version, type,
-                                                      artifactId + "-" + pom.getResolvedVersion() + ".pom" ) );
+            p.parse( resolver.getArtifactFile( pom ) );
         }
         catch ( IOException e )
         {
@@ -585,5 +646,15 @@
     public String getPackaging()
     {
         return packaging;
+    }
+
+    public Map getPlugins()
+    {
+        return plugins;
+    }
+
+    public List getModules()
+    {
+        return modules;
     }
 }

Added: maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/model/Plugin.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/model/Plugin.java?rev=332580&view=auto
==============================================================================
--- maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/model/Plugin.java (added)
+++ maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/model/Plugin.java Fri Nov 11 07:05:53 2005
@@ -0,0 +1,130 @@
+package org.apache.maven.bootstrap.model;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Collections;
+
+/**
+ * Describes a dependency.
+ *
+ * @version $Id$
+ */
+public class Plugin
+{
+    private String version;
+
+    private String artifactId;
+
+    private String groupId;
+
+    private Map configuration = new HashMap();
+
+    public String getId()
+    {
+        return getGroupId() + ":" + getArtifactId();
+    }
+
+    public void setGroupId( String groupId )
+    {
+        this.groupId = groupId;
+    }
+
+    public String getGroupId()
+    {
+        return groupId;
+    }
+
+    public String getArtifactId()
+    {
+        return artifactId;
+    }
+
+    public void setArtifactId( String artifactId )
+    {
+        this.artifactId = artifactId;
+    }
+
+    public void setVersion( String version )
+    {
+        this.version = version;
+    }
+
+    public String getVersion()
+    {
+        return version;
+    }
+
+    public String toString()
+    {
+        return getId() + ":" + getVersion();
+    }
+
+    public int hashCode()
+    {
+        int result = 17;
+        result = 37 * result + groupId.hashCode();
+        result = 37 * result + artifactId.hashCode();
+        result = 37 * result + version.hashCode();
+        return result;
+    }
+
+    public boolean equals( Object o )
+    {
+        if ( o == this )
+        {
+            return true;
+        }
+
+        if ( !( o instanceof Plugin ) )
+        {
+            return false;
+        }
+
+        Plugin d = (Plugin) o;
+
+        if ( !d.getGroupId().equals( groupId ) )
+        {
+            return false;
+        }
+        else if ( !d.getArtifactId().equals( artifactId ) )
+        {
+            return false;
+        }
+        else if ( !d.getVersion().equals( version ) )
+        {
+            return false;
+        }
+        return true;
+    }
+
+    public Map getConfiguration()
+    {
+        return configuration;
+    }
+
+    public Dependency asDependency()
+    {
+        return new Dependency( groupId, artifactId, version, "maven-plugin", Collections.EMPTY_LIST );
+    }
+
+    public Dependency asDependencyPom()
+    {
+        return new Dependency( groupId, artifactId, version, "pom", Collections.EMPTY_LIST );
+    }
+}

Propchange: maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/model/Plugin.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/model/Plugin.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/model/Repository.java (from r331671, maven/components/trunk/maven-mboot2/src/main/java/model/Repository.java)
URL: http://svn.apache.org/viewcvs/maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/model/Repository.java?p2=maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/model/Repository.java&p1=maven/components/trunk/maven-mboot2/src/main/java/model/Repository.java&r1=331671&r2=332580&rev=332580&view=diff
==============================================================================
--- maven/components/trunk/maven-mboot2/src/main/java/model/Repository.java (original)
+++ maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/model/Repository.java Fri Nov 11 07:05:53 2005
@@ -1,4 +1,4 @@
-package model;
+package org.apache.maven.bootstrap.model;
 
 /*
  * Copyright 2001-2005 The Apache Software Foundation.
@@ -54,7 +54,7 @@
         this.releases = releases;
     }
 
-    public File getArtifactFile( String groupId, String artifactId, String version, String type )
+    private File getArtifactFile( String groupId, String artifactId, String version, String type )
     {
         Dependency d = new Dependency( groupId, artifactId, version, type, Collections.EMPTY_LIST );
 

Copied: maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/model/Resource.java (from r331671, maven/components/trunk/maven-mboot2/src/main/java/model/Resource.java)
URL: http://svn.apache.org/viewcvs/maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/model/Resource.java?p2=maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/model/Resource.java&p1=maven/components/trunk/maven-mboot2/src/main/java/model/Resource.java&r1=331671&r2=332580&rev=332580&view=diff
==============================================================================
--- maven/components/trunk/maven-mboot2/src/main/java/model/Resource.java (original)
+++ maven/components/trunk/bootstrap/src/main/java/org/apache/maven/bootstrap/model/Resource.java Fri Nov 11 07:05:53 2005
@@ -1,4 +1,4 @@
-package model;
+package org.apache.maven.bootstrap.model;
 
 /*
  * Copyright 2001-2005 The Apache Software Foundation.



Mime
View raw message