You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by jd...@apache.org on 2007/02/20 19:09:55 UTC

svn commit: r509692 - in /maven/components/trunk: ./ maven-artifact-manager/src/main/resources/META-INF/plexus/ maven-build-context/src/main/java/org/apache/maven/context/ maven-build-context/src/test/java/org/apache/maven/context/ maven-core/src/main/...

Author: jdcasey
Date: Tue Feb 20 10:09:53 2007
New Revision: 509692

URL: http://svn.apache.org/viewvc?view=rev&rev=509692
Log:
Rearranging project-builder caching so it's done externally and available for use in the model-lineage builder and during artifact resolution as well.

Added:
    maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/CacheAwareArtifactResolver.java   (with props)
    maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/ProjectBuildCache.java   (with props)
Modified:
    maven/components/trunk/build.xml
    maven/components/trunk/maven-artifact-manager/src/main/resources/META-INF/plexus/components.xml
    maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/BuildContext.java
    maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/DefaultBuildContext.java
    maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/DefaultBuildContextManager.java
    maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/ManagedBuildData.java
    maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/SystemBuildContext.java
    maven/components/trunk/maven-build-context/src/test/java/org/apache/maven/context/AbstractBuildContextManagerTest.java
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/ExecutionBuildContext.java
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/extension/BuildExtensionScanner.java
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/extension/DefaultBuildExtensionScanner.java
    maven/components/trunk/maven-core/src/main/resources/META-INF/plexus/components.xml
    maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/CustomActivatorAdvice.java
    maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
    maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
    maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/ProjectBuildContext.java
    maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/model/DefaultModelLineageBuilder.java
    maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/model/ModelLineageBuilder.java
    maven/components/trunk/maven-project/src/main/resources/META-INF/plexus/components.xml
    maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/build/model/DefaultModelLineageBuilderTest.java

Modified: maven/components/trunk/build.xml
URL: http://svn.apache.org/viewvc/maven/components/trunk/build.xml?view=diff&rev=509692&r1=509691&r2=509692
==============================================================================
--- maven/components/trunk/build.xml (original)
+++ maven/components/trunk/build.xml Tue Feb 20 10:09:53 2007
@@ -269,7 +269,9 @@
       <classpath refid="maven.classpath"/>
       <arg value="-e"/>
       <arg value="-B"/>
+<!--
       <arg value="-X"/>
+ -->
       <arg value="clean"/>
       <arg value="install"/>
     </java>

Modified: maven/components/trunk/maven-artifact-manager/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-artifact-manager/src/main/resources/META-INF/plexus/components.xml?view=diff&rev=509692&r1=509691&r2=509692
==============================================================================
--- maven/components/trunk/maven-artifact-manager/src/main/resources/META-INF/plexus/components.xml (original)
+++ maven/components/trunk/maven-artifact-manager/src/main/resources/META-INF/plexus/components.xml Tue Feb 20 10:09:53 2007
@@ -109,6 +109,7 @@
     <component>
       <role>org.apache.maven.artifact.resolver.ArtifactResolver</role>
       <implementation>org.apache.maven.artifact.resolver.DefaultArtifactResolver</implementation>
+      <role-hint>default</role-hint>
       <requirements>
         <requirement>
           <role>org.apache.maven.artifact.manager.ArtifactManager</role>

Modified: maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/BuildContext.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/BuildContext.java?view=diff&rev=509692&r1=509691&r2=509692
==============================================================================
--- maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/BuildContext.java (original)
+++ maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/BuildContext.java Tue Feb 20 10:09:53 2007
@@ -28,7 +28,24 @@
     /**
      * Add a new piece of managed build data to the build context. Managed data elements supply their
      * own storage key.
+     * 
+     * @deprecated Use store(..) instead.
      */
     void put( ManagedBuildData managedData );
+    
+    /**
+     * Add a new piece of managed build data to the build context. Managed data elements supply their
+     * own storage key.
+     */
+    void store( ManagedBuildData managedData );
+    
+    /**
+     * Retrieve the data map for a given type of managed build data, and use this to restore this
+     * instance's state to that which was stored in the build context.
+     * 
+     * @param managedData The managed data instance to restore from the build context.
+     * @return true if the data was retrieved from the build context, false otherwise
+     */
+    boolean retrieve( ManagedBuildData managedData );
     
 }

Modified: maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/DefaultBuildContext.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/DefaultBuildContext.java?view=diff&rev=509692&r1=509691&r2=509692
==============================================================================
--- maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/DefaultBuildContext.java (original)
+++ maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/DefaultBuildContext.java Tue Feb 20 10:09:53 2007
@@ -76,10 +76,41 @@
     /**
      * Add a new piece of managed data to the build context, using the key supplied by 
      * managedData.getStorageKey().
+     * 
+     * @deprecated Use store(..) instead
      */
     public void put( ManagedBuildData managedData )
     {
-        contextMap.put( managedData.getStorageKey(), managedData );
+        store( managedData );
+    }
+    
+    /**
+     * Add a new piece of managed data to the build context, using the key supplied by 
+     * managedData.getStorageKey().
+     */
+    public void store( ManagedBuildData managedData )
+    {
+        contextMap.put( managedData.getStorageKey(), managedData.getData() );
+    }
+
+    /**
+     * Retrieve the data map for a given type of managed build data, and use this to restore this
+     * instance's state to that which was stored in the build context.
+     * 
+     * @param managedData The managed data instance to restore from the build context.
+     * @return true if the data was retrieved from the build context, false otherwise
+     */
+    public boolean retrieve( ManagedBuildData managedData )
+    {
+        Map dataMap = (Map) contextMap.get( managedData.getStorageKey() );
+        
+        if ( dataMap != null )
+        {
+            managedData.setData( dataMap );
+            return true;
+        }
+        
+        return false;
     }
 
 }

Modified: maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/DefaultBuildContextManager.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/DefaultBuildContextManager.java?view=diff&rev=509692&r1=509691&r2=509692
==============================================================================
--- maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/DefaultBuildContextManager.java (original)
+++ maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/DefaultBuildContextManager.java Tue Feb 20 10:09:53 2007
@@ -1,8 +1,6 @@
 package org.apache.maven.context;
 
 import org.codehaus.plexus.context.Context;
-import org.codehaus.plexus.context.ContextException;
-import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
 
 import java.util.HashMap;
 import java.util.Map;
@@ -14,22 +12,25 @@
  * @author jdcasey
  */
 public class DefaultBuildContextManager
-    implements BuildContextManager, Contextualizable
+    implements BuildContextManager
 {
     public static final String ROLE_HINT = "default";
     
     protected static final String BUILD_CONTEXT_MAP_KEY = ROLE + ":" + ROLE_HINT + ":contextMap";
     
-    private Context context;
+    private InheritableThreadLocal tl = new InheritableThreadLocal();
     
     public DefaultBuildContextManager()
     {
         // used for plexus initialization
     }
     
+    /**
+     * @deprecated Using ThreadLocal now, not container context, for thread safety.
+     */
     public DefaultBuildContextManager( Context context )
     {
-        this.context = context;
+        // obsolete, does nothing...
     }
     
     /**
@@ -37,7 +38,7 @@
      */
     public void clearBuildContext()
     {
-        clearContextContainerMap();
+        tl.set( null );
     }
 
     /**
@@ -49,7 +50,7 @@
     {
         Map contextMap = getContextContainerMap( create );
         
-        if ( !create && contextMap == null )
+        if ( contextMap == null && !create )
         {
             return null;
         }
@@ -66,7 +67,7 @@
     {
         if ( context instanceof DefaultBuildContext )
         {
-            this.context.put( BUILD_CONTEXT_MAP_KEY, ((DefaultBuildContext)context).getContextMap() );
+            tl.set( ((DefaultBuildContext)context).getContextMap() );
         }
         else
         {
@@ -76,25 +77,12 @@
 
     protected Map getContextContainerMap( boolean create )
     {
-        Map containerMap = null;
+        Map containerMap = (Map) tl.get();
 
-        if ( context.contains( BUILD_CONTEXT_MAP_KEY ) )
-        {
-            try
-            {
-                containerMap = (Map) context.get( BUILD_CONTEXT_MAP_KEY );
-            }
-            catch ( ContextException e )
-            {
-                throw new IllegalStateException( "Failed to retrieve BuildAdvisor "
-                                + "serialization map from context, though the context claims it exists. Error: "
-                                + e.getMessage() );
-            }
-        }
-        else if ( create )
+        if ( containerMap == null && create )
         {
             containerMap = new HashMap();
-            context.put( BUILD_CONTEXT_MAP_KEY, containerMap );
+            tl.set( containerMap );
         }
 
         return containerMap;
@@ -111,20 +99,12 @@
     }
 
     /**
-     * Retrieve the container context for storing the BuildContext data.
+     * @deprecated Using ThreadLocal now, not container context, for thread safety.
      */
-    public void contextualize( Context context )
-        throws ContextException
-    {
-        this.context = context;
-    }
-
     public Context reorientToContext( Context context )
     {
-        Context oldContext = this.context;
-        this.context = context;
-        
-        return oldContext;
+        // obsolete, does nothing...
+        return context;
     }
 
 }

Modified: maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/ManagedBuildData.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/ManagedBuildData.java?view=diff&rev=509692&r1=509691&r2=509692
==============================================================================
--- maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/ManagedBuildData.java (original)
+++ maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/ManagedBuildData.java Tue Feb 20 10:09:53 2007
@@ -1,5 +1,7 @@
 package org.apache.maven.context;
 
+import java.util.Map;
+
 /**
  * Management interface for things that are meant to be stored/retrieved from the Maven BuildContext
  * natively. Such things need to give the BuildContextManager a key for mapping it into the context.
@@ -17,5 +19,21 @@
      * @return The BuildContext mapping key.
      */
     String getStorageKey();
+
+    /**
+     * Provides a way for a complex object to serialize itself to primitives for storage in the
+     * build context, so the same class loaded from different classloaders (as in the case of plugin
+     * dependencies) don't incur a ClassCastException when trying to retrieve stored information.
+     * 
+     * @return The object's data in primitive (shared classes, like Strings) form, keyed for
+     *   retrieval.
+     */
+    Map getData();
+    
+    /**
+     * Restore the object's state from the primitives stored in the build context.
+     * @param data The map of primitives that were stored in the build context
+     */
+    void setData( Map data );
 
 }

Modified: maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/SystemBuildContext.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/SystemBuildContext.java?view=diff&rev=509692&r1=509691&r2=509692
==============================================================================
--- maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/SystemBuildContext.java (original)
+++ maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/SystemBuildContext.java Tue Feb 20 10:09:53 2007
@@ -1,5 +1,7 @@
 package org.apache.maven.context;
 
+import java.util.HashMap;
+import java.util.Map;
 import java.util.Properties;
 
 public class SystemBuildContext
@@ -7,6 +9,10 @@
 {
     
     public static final String BUILD_CONTEXT_KEY = SystemBuildContext.class.getName();
+
+    private static final String SYSTEM_PROPERTIES_KEY = "system-properties";
+
+    private static final String ENVIRONMENT_VARIABLES_KEY = "environment-variables";
     
     private Properties systemProperties;
     private Properties envars;
@@ -50,11 +56,16 @@
     {
         BuildContext buildContext = buildContextManager.readBuildContext( false );
         
-        SystemBuildContext systemContext = null;
+        SystemBuildContext systemContext = new SystemBuildContext();
         
         if ( buildContext != null )
         {
-            systemContext = (SystemBuildContext) buildContext.get( BUILD_CONTEXT_KEY );
+            SystemBuildContext ctx = new SystemBuildContext();
+            
+            if ( buildContext.retrieve( ctx ) || create )
+            {
+                systemContext = ctx;
+            }
         }
         
         if ( create && systemContext == null )
@@ -69,8 +80,23 @@
     {
         BuildContext buildContext = buildContextManager.readBuildContext( true );
         
-        buildContext.put( this );
+        buildContext.store( this );
         
         buildContextManager.storeBuildContext( buildContext );
+    }
+
+    public Map getData()
+    {
+        Map data = new HashMap( 2 );
+        data.put( SYSTEM_PROPERTIES_KEY, systemProperties );
+        data.put( ENVIRONMENT_VARIABLES_KEY, envars );
+        
+        return data;
+    }
+
+    public void setData( Map data )
+    {
+        this.systemProperties = (Properties) data.get( SYSTEM_PROPERTIES_KEY );
+        this.envars = (Properties) data.get( ENVIRONMENT_VARIABLES_KEY );
     }
 }

Modified: maven/components/trunk/maven-build-context/src/test/java/org/apache/maven/context/AbstractBuildContextManagerTest.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-build-context/src/test/java/org/apache/maven/context/AbstractBuildContextManagerTest.java?view=diff&rev=509692&r1=509691&r2=509692
==============================================================================
--- maven/components/trunk/maven-build-context/src/test/java/org/apache/maven/context/AbstractBuildContextManagerTest.java (original)
+++ maven/components/trunk/maven-build-context/src/test/java/org/apache/maven/context/AbstractBuildContextManagerTest.java Tue Feb 20 10:09:53 2007
@@ -71,7 +71,7 @@
         
         BuildContext ctx3 = mgr.readBuildContext( false );
         
-        assertNull( ctx3.get( key ) );
+        assertNull( ctx3 );
     }
 
 }

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java?view=diff&rev=509692&r1=509691&r2=509692
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java Tue Feb 20 10:09:53 2007
@@ -31,7 +31,6 @@
 import org.apache.maven.execution.ReactorManager;
 import org.apache.maven.execution.RuntimeInformation;
 import org.apache.maven.extension.BuildExtensionScanner;
-import org.apache.maven.extension.ExtensionManager;
 import org.apache.maven.extension.ExtensionScanningException;
 import org.apache.maven.lifecycle.LifecycleExecutor;
 import org.apache.maven.monitor.event.DefaultEventDispatcher;
@@ -44,7 +43,6 @@
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.project.MavenProjectBuilder;
 import org.apache.maven.project.ProjectBuildingException;
-import org.apache.maven.project.build.model.ModelLineageBuilder;
 import org.apache.maven.reactor.MavenExecutionException;
 import org.apache.maven.settings.Settings;
 import org.apache.maven.usability.diagnostics.ErrorDiagnostics;
@@ -64,10 +62,8 @@
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Date;
-import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Map;
 import java.util.TimeZone;
 
 /**
@@ -347,15 +343,13 @@
         
         // TODO: We should probably do this discovery just-in-time, if we can move to building project
         // instances just-in-time.
-        Map cache = new HashMap();
-        
         for ( Iterator it = files.iterator(); it.hasNext(); )
         {
             File pom = (File) it.next();
 
             try
             {
-                buildExtensionScanner.scanForBuildExtensions( pom, request.getLocalRepository(), globalProfileManager, cache );
+                buildExtensionScanner.scanForBuildExtensions( pom, request.getLocalRepository(), globalProfileManager );
             }
             catch ( ExtensionScanningException e )
             {

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/ExecutionBuildContext.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/ExecutionBuildContext.java?view=diff&rev=509692&r1=509691&r2=509692
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/ExecutionBuildContext.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/ExecutionBuildContext.java Tue Feb 20 10:09:53 2007
@@ -11,6 +11,7 @@
 import java.util.Collections;
 import java.util.Date;
 import java.util.List;
+import java.util.Map;
 import java.util.Properties;
 
 /*
@@ -39,7 +40,13 @@
     
     public static final String BUILD_CONTEXT_KEY = ExecutionBuildContext.class.getName();
     
-    private final MavenExecutionRequest request;
+    private static final String REQUEST_KEY = "request";
+    
+    private MavenExecutionRequest request;
+    
+    private ExecutionBuildContext()
+    {
+    }
 
     public ExecutionBuildContext( MavenExecutionRequest request )
     {
@@ -195,11 +202,14 @@
     {
         BuildContext buildContext = buildContextManager.readBuildContext( false );
         
-        ExecutionBuildContext executionContext = null;
+        ExecutionBuildContext executionContext = new ExecutionBuildContext();
         
         if ( buildContext != null )
         {
-            executionContext = (ExecutionBuildContext) buildContext.get( BUILD_CONTEXT_KEY );
+            if ( !buildContext.retrieve( executionContext ) )
+            {
+                return null;
+            }
         }
         
         return executionContext;
@@ -209,8 +219,18 @@
     {
         BuildContext buildContext = buildContextManager.readBuildContext( true );
         
-        buildContext.put( this );
+        buildContext.store( this );
         
         buildContextManager.storeBuildContext( buildContext );
+    }
+
+    public Map getData()
+    {
+        return Collections.singletonMap( REQUEST_KEY, request );
+    }
+
+    public void setData( Map data )
+    {
+        this.request = (MavenExecutionRequest) data.get( REQUEST_KEY );
     }
 }

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/extension/BuildExtensionScanner.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/extension/BuildExtensionScanner.java?view=diff&rev=509692&r1=509691&r2=509692
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/extension/BuildExtensionScanner.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/extension/BuildExtensionScanner.java Tue Feb 20 10:09:53 2007
@@ -4,14 +4,13 @@
 import org.apache.maven.profiles.ProfileManager;
 
 import java.io.File;
-import java.util.Map;
 
 public interface BuildExtensionScanner
 {
     
     String ROLE = BuildExtensionScanner.class.getName();
     
-    void scanForBuildExtensions( File pom, ArtifactRepository localRepository, ProfileManager globalProfileManager, Map pomFilesById )
+    void scanForBuildExtensions( File pom, ArtifactRepository localRepository, ProfileManager globalProfileManager )
         throws ExtensionScanningException;
 
 }

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/extension/DefaultBuildExtensionScanner.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/extension/DefaultBuildExtensionScanner.java?view=diff&rev=509692&r1=509691&r2=509692
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/extension/DefaultBuildExtensionScanner.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/extension/DefaultBuildExtensionScanner.java Tue Feb 20 10:09:53 2007
@@ -8,6 +8,7 @@
 import org.apache.maven.model.Build;
 import org.apache.maven.model.Extension;
 import org.apache.maven.model.Model;
+import org.apache.maven.model.Parent;
 import org.apache.maven.profiles.ProfileManager;
 import org.apache.maven.profiles.activation.CustomActivatorAdvice;
 import org.apache.maven.project.MavenProject;
@@ -25,6 +26,7 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -48,9 +50,17 @@
     private ModelInterpolator modelInterpolator;
 
     public void scanForBuildExtensions( File pom, ArtifactRepository localRepository,
-                                        ProfileManager globalProfileManager, Map pomFilesById )
+                                        ProfileManager globalProfileManager )
         throws ExtensionScanningException
     {
+        scanInternal( pom, localRepository, globalProfileManager, new ArrayList() );
+    }
+    
+    private void scanInternal( File pom, ArtifactRepository localRepository, ProfileManager globalProfileManager,
+                               List visitedModelIds )
+        throws ExtensionScanningException
+    {
+        
         // setup the CustomActivatorAdvice to fail quietly while we discover extensions...then, we'll
         // reset it.
         CustomActivatorAdvice activatorAdvice = CustomActivatorAdvice.getCustomActivatorAdvice( buildContextManager );
@@ -64,15 +74,26 @@
             getLogger().debug( "Pre-scanning POM lineage of: " + pom + " for build extensions." );
 
             ModelLineage lineage = buildModelLineage( pom, localRepository, originalRemoteRepositories,
-                                                      globalProfileManager, pomFilesById );
+                                                      globalProfileManager );
 
             Map inheritedInterpolationValues = new HashMap();
             
             for ( ModelLineageIterator lineageIterator = lineage.reversedLineageIterator(); lineageIterator.hasNext(); )
             {
                 Model model = (Model) lineageIterator.next();
+                String key = createKey( model );
+                
+                if ( visitedModelIds.contains( key ) )
+                {
+                    getLogger().debug( "Already visited: " + key + "; continuing." );
+                    continue;
+                }
+                
+                visitedModelIds.add( key );
+                
+                File modelPom = lineageIterator.getPOMFile();
 
-                getLogger().debug( "Checking: " + model.getId() + " for extensions." );
+                getLogger().debug( "Checking: " + model.getId() + " for extensions. (It has " + model.getModules().size() + " modules.)" );
                 
                 if ( inheritedInterpolationValues == null )
                 {
@@ -83,8 +104,7 @@
 
                 checkModelBuildForExtensions( model, localRepository, lineageIterator.getArtifactRepositories() );
 
-                checkModulesForExtensions( pom, model, localRepository, originalRemoteRepositories, globalProfileManager,
-                                           pomFilesById );
+                checkModulesForExtensions( modelPom, model, localRepository, originalRemoteRepositories, globalProfileManager, visitedModelIds );
                 
                 Properties modelProps = model.getProperties();
                 if ( modelProps != null )
@@ -108,9 +128,24 @@
         }
     }
 
+    private String createKey( Model model )
+    {
+        Parent parent = model.getParent();
+        
+        String groupId = model.getGroupId();
+        if ( groupId == null )
+        {
+            groupId = parent.getGroupId();
+        }
+        
+        String artifactId = model.getArtifactId();
+        
+        return groupId + ":" + artifactId;
+    }
+
     private void checkModulesForExtensions( File containingPom, Model model, ArtifactRepository localRepository,
                                             List originalRemoteRepositories, ProfileManager globalProfileManager,
-                                            Map pomFilesById )
+                                            List visitedModelIds )
         throws ExtensionScanningException
     {
         // FIXME: This gets a little sticky, because modules can be added by profiles that require
@@ -120,6 +155,7 @@
         if ( modules != null )
         {
             File basedir = containingPom.getParentFile();
+            getLogger().debug( "Basedir is: " + basedir );
 
             for ( Iterator it = modules.iterator(); it.hasNext(); )
             {
@@ -170,11 +206,11 @@
                 {
                     getLogger().debug(
                                        "Cannot find POM for module: " + moduleSubpath
-                                           + "; continuing scan with next module." );
+                                           + "; continuing scan with next module. (Full path was: " + modulePomDirectory + ")" );
                     continue;
                 }
 
-                scanForBuildExtensions( modulePomDirectory, localRepository, globalProfileManager, pomFilesById );
+                scanInternal( modulePomDirectory, localRepository, globalProfileManager, visitedModelIds );
             }
         }
     }
@@ -226,8 +262,7 @@
     }
 
     private ModelLineage buildModelLineage( File pom, ArtifactRepository localRepository,
-                                            List originalRemoteRepositories, ProfileManager globalProfileManager,
-                                            Map cache )
+                                            List originalRemoteRepositories, ProfileManager globalProfileManager )
         throws ExtensionScanningException
     {
         ModelLineage lineage;
@@ -236,7 +271,7 @@
             getLogger().debug( "Building model-lineage for: " + pom + " to pre-scan for extensions." );
 
             lineage = modelLineageBuilder.buildModelLineage( pom, localRepository, originalRemoteRepositories,
-                                                             globalProfileManager, cache );
+                                                             globalProfileManager );
         }
         catch ( ProjectBuildingException e )
         {

Modified: maven/components/trunk/maven-core/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/resources/META-INF/plexus/components.xml?view=diff&rev=509692&r1=509691&r2=509692
==============================================================================
--- maven/components/trunk/maven-core/src/main/resources/META-INF/plexus/components.xml (original)
+++ maven/components/trunk/maven-core/src/main/resources/META-INF/plexus/components.xml Tue Feb 20 10:09:53 2007
@@ -50,6 +50,7 @@
         </requirement>
         <requirement>
           <role>org.apache.maven.artifact.resolver.ArtifactResolver</role>
+          <role-hint>project-cache-aware</role-hint>
         </requirement>
         <requirement>
           <role>org.apache.maven.artifact.metadata.ArtifactMetadataSource</role>
@@ -78,6 +79,7 @@
         </requirement>
         <requirement>
           <role>org.apache.maven.artifact.resolver.ArtifactResolver</role>
+          <role-hint>project-cache-aware</role-hint>
         </requirement>
         <requirement>
           <role>org.apache.maven.artifact.metadata.ArtifactMetadataSource</role>

Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/CustomActivatorAdvice.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/CustomActivatorAdvice.java?view=diff&rev=509692&r1=509691&r2=509692
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/CustomActivatorAdvice.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/CustomActivatorAdvice.java Tue Feb 20 10:09:53 2007
@@ -4,6 +4,9 @@
 import org.apache.maven.context.BuildContextManager;
 import org.apache.maven.context.ManagedBuildData;
 
+import java.util.Collections;
+import java.util.Map;
+
 /**
  * Advice for the custom profile activator, which tells how to handle cases where custom activators
  * cannot be found or configured. This is used to suppress missing activators when pre-scanning for
@@ -17,6 +20,8 @@
     
     public static final String BUILD_CONTEXT_KEY = CustomActivatorAdvice.class.getName();
     
+    private static final String FAIL_QUIETLY_KEY = "fail-quietly";
+    
     private static final boolean DEFAULT_FAIL_QUIETLY = false;
     
     /**
@@ -54,16 +59,11 @@
     {
         BuildContext buildContext = buildContextManager.readBuildContext( false );
         
-        CustomActivatorAdvice advice = null;
+        CustomActivatorAdvice advice = new CustomActivatorAdvice();
         
         if ( buildContext != null )
         {
-            advice = (CustomActivatorAdvice) buildContext.get( BUILD_CONTEXT_KEY );
-        }
-        
-        if ( advice == null )
-        {
-            advice = new CustomActivatorAdvice();
+            buildContext.retrieve( advice );
         }
         
         return advice;
@@ -73,8 +73,18 @@
     {
         BuildContext buildContext = buildContextManager.readBuildContext( true );
         
-        buildContext.put( this );
+        buildContext.store( this );
         
         buildContextManager.storeBuildContext( buildContext );
+    }
+
+    public Map getData()
+    {
+        return Collections.singletonMap( FAIL_QUIETLY_KEY, Boolean.valueOf( failQuietly ) );
+    }
+
+    public void setData( Map data )
+    {
+        this.failQuietly = ((Boolean) data.get( FAIL_QUIETLY_KEY )).booleanValue();
     }
 }

Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java?view=diff&rev=509692&r1=509691&r2=509692
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java Tue Feb 20 10:09:53 2007
@@ -23,7 +23,6 @@
 import org.apache.maven.artifact.InvalidRepositoryException;
 import org.apache.maven.artifact.factory.ArtifactFactory;
 import org.apache.maven.artifact.manager.ArtifactManager;
-import org.apache.maven.artifact.manager.WagonManager;
 import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
@@ -48,6 +47,7 @@
 import org.apache.maven.profiles.ProfileManager;
 import org.apache.maven.profiles.activation.ProfileActivationException;
 import org.apache.maven.project.artifact.InvalidDependencyVersionException;
+import org.apache.maven.project.build.ProjectBuildCache;
 import org.apache.maven.project.build.ProjectBuildContext;
 import org.apache.maven.project.build.model.DefaultModelLineage;
 import org.apache.maven.project.build.model.ModelLineage;
@@ -151,10 +151,6 @@
 
     private ModelValidator validator;
     
-    private Map processedProjectCache = new HashMap();
-    
-    private Map cachedPomFilesByModelId = new HashMap();
-
     // TODO: make it a component
     private MavenXpp3Reader modelReader;
 
@@ -220,9 +216,9 @@
                                              boolean allowStubModel )
         throws ProjectBuildingException
     {
-        String cacheKey = createCacheKey( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion() );
-
-        MavenProject project = (MavenProject) processedProjectCache.get( cacheKey );
+        ProjectBuildCache projectBuildCache = ProjectBuildCache.read( buildContextManager );
+        
+        MavenProject project = (MavenProject) projectBuildCache.getCachedProject( artifact );
 
         if ( project != null )
         {
@@ -753,7 +749,9 @@
             throw new InvalidProjectModelException( projectId, pomLocation, e.getMessage(), e );
         }
 
-        processedProjectCache.put( createCacheKey( project.getGroupId(), project.getArtifactId(), project.getVersion() ), project );
+        ProjectBuildCache projectBuildCache = ProjectBuildCache.read( buildContextManager );
+        projectBuildCache.cacheProject( project );
+        projectBuildCache.store( buildContextManager );
 
         // jvz:note
         // this only happens if we are building from a source file
@@ -778,9 +776,7 @@
         
         if ( rawParent != null )
         {
-            String cacheKey = createCacheKey( rawParent.getGroupId(), rawParent.getArtifactId(), rawParent.getVersion() );
-            
-            MavenProject processedParent = (MavenProject) processedProjectCache.get( cacheKey );
+            MavenProject processedParent = (MavenProject) projectBuildCache.getCachedProject( rawParent );
             
             // yeah, this null check might be a bit paranoid, but better safe than sorry...
             if ( processedParent != null )
@@ -1012,7 +1008,7 @@
         ModelLineage modelLineage = new DefaultModelLineage();
         modelLineage.setOrigin( model, new File( projectDir, "pom.xml" ), new ArrayList( aggregatedRemoteWagonRepositories ) );
         
-        modelLineageBuilder.resumeBuildingModelLineage( modelLineage, localRepository, externalProfileManager, cachedPomFilesByModelId );
+        modelLineageBuilder.resumeBuildingModelLineage( modelLineage, localRepository, externalProfileManager );
         
         ProjectBuildContext projectContext = ProjectBuildContext.getProjectBuildContext( buildContextManager, true );
         

Added: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/CacheAwareArtifactResolver.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/CacheAwareArtifactResolver.java?view=auto&rev=509692
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/CacheAwareArtifactResolver.java (added)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/CacheAwareArtifactResolver.java Tue Feb 20 10:09:53 2007
@@ -0,0 +1,80 @@
+package org.apache.maven.project.artifact;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.handler.ArtifactHandler;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
+import org.apache.maven.artifact.resolver.ArtifactResolutionException;
+import org.apache.maven.artifact.resolver.ArtifactResolver;
+import org.apache.maven.artifact.resolver.DefaultArtifactResolver;
+import org.apache.maven.context.BuildContextManager;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.build.ProjectBuildCache;
+
+import java.io.File;
+import java.util.List;
+
+public class CacheAwareArtifactResolver
+    extends DefaultArtifactResolver
+{
+    
+    private ArtifactResolver delegate;
+    
+    private BuildContextManager buildContextManager;
+
+    public void resolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository )
+        throws ArtifactResolutionException, ArtifactNotFoundException
+    {
+        resolveFromCache( artifact );
+        
+        if ( !artifact.isResolved() )
+        {
+            delegate.resolve( artifact, remoteRepositories, localRepository );
+        }
+    }
+
+    public void resolveAlways( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository )
+        throws ArtifactResolutionException, ArtifactNotFoundException
+    {
+        resolveFromCache( artifact );
+        
+        if ( !artifact.isResolved() )
+        {
+            delegate.resolveAlways( artifact, remoteRepositories, localRepository );
+        }
+    }
+
+    private void resolveFromCache( Artifact artifact )
+    {
+        ProjectBuildCache cache = ProjectBuildCache.read( buildContextManager );
+        
+        if ( "pom".equals( artifact.getType() ) )
+        {
+            File pomFile = cache.getCachedModelFile( artifact );
+            
+            if ( pomFile != null )
+            {
+                artifact.setFile( pomFile );
+                artifact.setResolved( true );
+            }
+        }
+        // currently, artifacts with classifiers are not really supported as the main project artifact...
+        else if ( artifact.getClassifier() == null )
+        {
+            MavenProject project = cache.getCachedProject( artifact );
+            ArtifactHandler handler = artifact.getArtifactHandler();
+            
+            if ( project != null && handler.getPackaging().equals( project.getPackaging() ) )
+            {
+                File projectArtifactFile = project.getArtifact().getFile();
+                
+                if ( projectArtifactFile != null )
+                {
+                    artifact.setFile( projectArtifactFile );
+                    artifact.setResolved( true );
+                }
+            }
+        }
+    }
+
+}

Propchange: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/CacheAwareArtifactResolver.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java?view=diff&rev=509692&r1=509691&r2=509692
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java Tue Feb 20 10:09:53 2007
@@ -33,6 +33,7 @@
 import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
 import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
 import org.apache.maven.artifact.versioning.VersionRange;
+import org.apache.maven.context.BuildContextManager;
 import org.apache.maven.model.Dependency;
 import org.apache.maven.model.DistributionManagement;
 import org.apache.maven.model.Exclusion;
@@ -41,6 +42,7 @@
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.project.MavenProjectBuilder;
 import org.apache.maven.project.ProjectBuildingException;
+import org.apache.maven.project.build.ProjectBuildCache;
 import org.apache.maven.project.validation.ModelValidationResult;
 import org.codehaus.plexus.logging.AbstractLogEnabled;
 import org.codehaus.plexus.util.StringUtils;
@@ -69,6 +71,8 @@
     private ArtifactFactory artifactFactory;
 
     private RepositoryMetadataManager repositoryMetadataManager;
+    
+    private BuildContextManager buildContextManager;
 
     // lazily instantiated and cached.
     private MavenProject superProject;
@@ -81,6 +85,8 @@
     public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories )
         throws ArtifactMetadataRetrievalException
     {
+        ProjectBuildCache cache = ProjectBuildCache.read( buildContextManager );
+        
         MavenProject project = null;
 
         Artifact pomArtifact;
@@ -97,40 +103,46 @@
             }
             else
             {
-                try
+                project = cache.getCachedProject( artifact );
+                
+                if ( project == null )
                 {
-                    project = mavenProjectBuilder.buildFromRepository( pomArtifact, remoteRepositories, localRepository,
-                                                                       true );
-                }
-                catch ( InvalidProjectModelException e )
-                {
-                    getLogger().warn( "POM for \'" + pomArtifact +
-                        "\' is invalid. It will be ignored for artifact resolution. Reason: " + e.getMessage() );
-
-                    if ( getLogger().isDebugEnabled() )
+                    try
                     {
-                        getLogger().debug( "Reason: " + e.getMessage() );
-                        
-                        ModelValidationResult validationResult = e.getValidationResult();
+                        project = mavenProjectBuilder.buildFromRepository( pomArtifact, remoteRepositories, localRepository,
+                                                                           true );
+                    }
+                    catch ( InvalidProjectModelException e )
+                    {
+                        getLogger().warn( "POM for \'" + pomArtifact +
+                            "\' is invalid. It will be ignored for artifact resolution. Reason: " + e.getMessage() );
 
-                        if ( validationResult != null )
+                        if ( getLogger().isDebugEnabled() )
                         {
-                            getLogger().debug( "\nValidation Errors:" );
-                            for ( Iterator i = validationResult.getMessages().iterator(); i.hasNext(); )
+                            getLogger().debug( "Reason: " + e.getMessage() );
+                            
+                            ModelValidationResult validationResult = e.getValidationResult();
+
+                            if ( validationResult != null )
                             {
-                                getLogger().debug( i.next().toString() );
+                                getLogger().debug( "\nValidation Errors:" );
+                                for ( Iterator i = validationResult.getMessages().iterator(); i.hasNext(); )
+                                {
+                                    getLogger().debug( i.next().toString() );
+                                }
+                                getLogger().debug( "\n" );
                             }
-                            getLogger().debug( "\n" );
                         }
-                    }
 
-                    project = null;
-                }
-                catch ( ProjectBuildingException e )
-                {
-                    throw new ArtifactMetadataRetrievalException( "Unable to read the metadata file for artifact '" +
-                        artifact.getDependencyConflictId() + "': " + e.getMessage(), e );
+                        project = null;
+                    }
+                    catch ( ProjectBuildingException e )
+                    {
+                        throw new ArtifactMetadataRetrievalException( "Unable to read the metadata file for artifact '" +
+                            artifact.getDependencyConflictId() + "': " + e.getMessage(), e );
+                    }
                 }
+                
 
                 if ( project != null )
                 {
@@ -176,13 +188,13 @@
 
                         if ( artifact.getDependencyTrail() != null && artifact.getDependencyTrail().size() == 1 )
                         {
-                            getLogger().warn( "While downloading " + pomArtifact.getGroupId() + ":" +
-                                pomArtifact.getArtifactId() + ":" + pomArtifact.getVersion() + message + "\n" );
+                            getLogger().warn( "While downloading " + artifact.getGroupId() + ":" +
+                                artifact.getArtifactId() + ":" + artifact.getVersion() + message + "\n" );
                         }
                         else
                         {
-                            getLogger().debug( "While downloading " + pomArtifact.getGroupId() + ":" +
-                                pomArtifact.getArtifactId() + ":" + pomArtifact.getVersion() + message + "\n" );
+                            getLogger().debug( "While downloading " + artifact.getGroupId() + ":" +
+                                artifact.getArtifactId() + ":" + artifact.getVersion() + message + "\n" );
                         }
                     }
                     else

Added: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/ProjectBuildCache.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/ProjectBuildCache.java?view=auto&rev=509692
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/ProjectBuildCache.java (added)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/ProjectBuildCache.java Tue Feb 20 10:09:53 2007
@@ -0,0 +1,181 @@
+package org.apache.maven.project.build;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.context.BuildContext;
+import org.apache.maven.context.BuildContextManager;
+import org.apache.maven.context.ManagedBuildData;
+import org.apache.maven.model.Model;
+import org.apache.maven.model.Parent;
+import org.apache.maven.project.MavenProject;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * This cache is meant to provide a reference of the project instances that are in the current build
+ * in order to avoid storing a hidden caching mechanism in the project builder, and avoid the need
+ * to store inter-project references as such in MavenProject instances. An ArtifactResolver instance
+ * will be used that can utilize this cache, but will also wrap the "default" ArtifactResolver
+ * instance, so that can be used as a target for replacement implementations.
+ * 
+ * To retrieve from the build context: buildContext.retrieve( new ProjectBuildCache( false ) );
+ * 
+ * @author jdcasey
+ */
+public class ProjectBuildCache
+    implements ManagedBuildData
+{
+    
+    private static final String BUILD_CONTEXT_KEY = ProjectBuildCache.class.getName();
+    
+    private static final String PROJECT_CACHE = "project-cache";
+    
+    private static final String POM_FILE_CACHE = "pom-file-cache";
+    
+    private Map projectCache;
+    
+    private Map pomFileCache;
+    
+    public ProjectBuildCache()
+    {
+        this( true );
+    }
+    
+    /**
+     * @param liveInstance If false, this instance's state is meant to be retrieved from the build
+     *   context. If true, this instance can serve as the authoritative instance where the cache is
+     *   established.
+     */
+    public ProjectBuildCache( boolean liveInstance )
+    {
+        if ( liveInstance )
+        {
+            projectCache = new HashMap();
+            pomFileCache = new HashMap();
+        }
+    }
+    
+    public void cacheProject( MavenProject project )
+    {
+        projectCache.put( generateCacheKey( project ), project );
+    }
+    
+    public MavenProject getCachedProject( String groupId, String artifactId, String version )
+    {
+        return (MavenProject) projectCache.get( generateCacheKey( groupId, artifactId, version ) );
+    }
+    
+    public MavenProject getCachedProject( Artifact artifact )
+    {
+        return (MavenProject) projectCache.get( generateCacheKey( artifact ) );
+    }
+    
+    public MavenProject getCachedProject( MavenProject exampleInstance )
+    {
+        return (MavenProject) projectCache.get( generateCacheKey( exampleInstance ) );
+    }
+
+    public void cacheModelFileForModel( File modelFile, Model model )
+    {
+        pomFileCache.put( generateCacheKey( model ), modelFile );
+    }
+    
+    public File getCachedModelFile( Artifact artifact )
+    {
+        return (File) pomFileCache.get( generateCacheKey( artifact ) );
+    }
+
+    public File getCachedModelFile( Parent parent )
+    {
+        return (File) pomFileCache.get( generateCacheKey( parent ) );
+    }
+
+    public File getCachedModelFile( String groupId, String artifactId, String version )
+    {
+        return (File) pomFileCache.get( generateCacheKey( groupId, artifactId, version ) );
+    }
+
+    public Map getData()
+    {
+        Map data = new HashMap( 2 );
+        
+        data.put( PROJECT_CACHE, projectCache );
+        data.put( POM_FILE_CACHE, pomFileCache );
+        
+        return data;
+    }
+
+    public String getStorageKey()
+    {
+        return BUILD_CONTEXT_KEY;
+    }
+
+    public void setData( Map data )
+    {
+        this.projectCache = (Map) data.get( PROJECT_CACHE );
+        this.pomFileCache = (Map) data.get( POM_FILE_CACHE );
+    }
+
+    public void store( BuildContextManager buildContextManager )
+    {
+        BuildContext buildContext = buildContextManager.readBuildContext( true );
+        buildContext.store( this );
+        buildContextManager.storeBuildContext( buildContext );
+    }
+
+    public static ProjectBuildCache read( BuildContextManager buildContextManager )
+    {
+        BuildContext buildContext = buildContextManager.readBuildContext( true );
+        
+        ProjectBuildCache cache = new ProjectBuildCache();
+        
+        buildContext.retrieve( cache );
+        
+        return cache;
+    }
+
+    private static String generateCacheKey( Model model )
+    {
+        Parent modelParent = model.getParent();
+
+        String groupId = model.getGroupId();
+
+        if ( groupId == null && modelParent != null )
+        {
+            groupId = modelParent.getGroupId();
+        }
+
+        String artifactId = model.getArtifactId();
+
+        String version = model.getVersion();
+
+        if ( version == null && modelParent != null )
+        {
+            version = modelParent.getVersion();
+        }
+
+        return generateCacheKey( groupId, artifactId, version );
+    }
+    
+    private static String generateCacheKey( Parent parent )
+    {
+        return generateCacheKey( parent.getGroupId(), parent.getArtifactId(), parent.getVersion() );
+    }
+    
+    private static String generateCacheKey( Artifact artifact )
+    {
+        return generateCacheKey( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion() );
+    }
+    
+    private static String generateCacheKey( MavenProject project )
+    {
+        return generateCacheKey( project.getGroupId(), project.getArtifactId(), project.getVersion() );
+    }
+    
+    private static String generateCacheKey( String groupId, String artifactId, String version )
+    {
+        return groupId + ":" + artifactId + ":" + version;
+    }
+
+}

Propchange: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/ProjectBuildCache.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/ProjectBuildContext.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/ProjectBuildContext.java?view=diff&rev=509692&r1=509691&r2=509692
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/ProjectBuildContext.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/ProjectBuildContext.java Tue Feb 20 10:09:53 2007
@@ -6,6 +6,9 @@
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.project.build.model.ModelLineage;
 
+import java.util.HashMap;
+import java.util.Map;
+
 /*
  * Copyright 2001-2005 The Apache Software Foundation.
  *
@@ -34,6 +37,10 @@
 {
     
     public static final String BUILD_CONTEXT_KEY = ProjectBuildContext.class.getName();
+
+    private static final String MODEL_LINEAGE = "model-lineage";
+
+    private static final String CURRENT_PROJECT = "current-project";
     
     private ModelLineage modelLineage;
     
@@ -72,16 +79,14 @@
     {
         BuildContext buildContext = buildContextManager.readBuildContext( false );
         
-        ProjectBuildContext projectContext = null;
+        ProjectBuildContext projectContext = new ProjectBuildContext();
         
         if ( buildContext != null )
         {
-            projectContext = (ProjectBuildContext) buildContext.get( BUILD_CONTEXT_KEY );
-        }
-        
-        if ( create && projectContext == null )
-        {
-            projectContext = new ProjectBuildContext();
+            if ( !buildContext.retrieve( projectContext ) && !create )
+            {
+                return null;
+            }
         }
         
         return projectContext;
@@ -91,8 +96,24 @@
     {
         BuildContext buildContext = buildContextManager.readBuildContext( true );
         
-        buildContext.put( this );
+        buildContext.store( this );
         
         buildContextManager.storeBuildContext( buildContext );
+    }
+
+    public Map getData()
+    {
+        Map data = new HashMap( 2 );
+        
+        data.put( MODEL_LINEAGE, modelLineage );
+        data.put( CURRENT_PROJECT, currentProject );
+        
+        return data;
+    }
+
+    public void setData( Map data )
+    {
+        this.modelLineage = (ModelLineage) data.get( MODEL_LINEAGE );
+        this.currentProject = (MavenProject) data.get( CURRENT_PROJECT );
     }
 }

Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/model/DefaultModelLineageBuilder.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/model/DefaultModelLineageBuilder.java?view=diff&rev=509692&r1=509691&r2=509692
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/model/DefaultModelLineageBuilder.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/model/DefaultModelLineageBuilder.java Tue Feb 20 10:09:53 2007
@@ -8,11 +8,13 @@
 import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
 import org.apache.maven.artifact.resolver.ArtifactResolutionException;
 import org.apache.maven.artifact.resolver.ArtifactResolver;
+import org.apache.maven.context.BuildContextManager;
 import org.apache.maven.model.Model;
 import org.apache.maven.model.Parent;
 import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
 import org.apache.maven.profiles.ProfileManager;
 import org.apache.maven.project.ProjectBuildingException;
+import org.apache.maven.project.build.ProjectBuildCache;
 import org.apache.maven.project.build.profile.ProfileAdvisor;
 import org.codehaus.plexus.logging.LogEnabled;
 import org.codehaus.plexus.logging.Logger;
@@ -28,7 +30,6 @@
 import java.util.Collections;
 import java.util.LinkedHashSet;
 import java.util.List;
-import java.util.Map;
 import java.util.Set;
 
 /**
@@ -47,6 +48,8 @@
     private MavenTools mavenTools;
 
     private ProfileAdvisor profileAdvisor;
+    
+    private BuildContextManager buildContextManager;
 
     private Logger logger;
 
@@ -54,19 +57,22 @@
     {
     }
 
-    public DefaultModelLineageBuilder( ArtifactResolver resolver, ArtifactFactory artifactFactory )
+    public DefaultModelLineageBuilder( ArtifactResolver resolver, ArtifactFactory artifactFactory, BuildContextManager buildContextManager )
     {
         this.artifactResolver = resolver;
         this.artifactFactory = artifactFactory;
+        this.buildContextManager = buildContextManager;
     }
 
     /**
      * @see org.apache.maven.project.build.model.ModelLineageBuilder#buildModelLineage(java.io.File, org.apache.maven.artifact.repository.ArtifactRepository, java.util.List)
      */
     public ModelLineage buildModelLineage( File pom, ArtifactRepository localRepository, List remoteRepositories,
-                                           ProfileManager profileManager, Map cachedPomFilesByModelId )
+                                           ProfileManager profileManager )
         throws ProjectBuildingException
     {
+        ProjectBuildCache projectBuildCache = ProjectBuildCache.read( buildContextManager );
+        
         ModelLineage lineage = new DefaultModelLineage();
 
         File pomFile = pom;
@@ -75,7 +81,7 @@
 
         while ( pomFile != null )
         {
-            Model model = readModel( pomFile, cachedPomFilesByModelId );
+            Model model = readModel( pomFile, projectBuildCache );
 
             if ( lineage.size() == 0 )
             {
@@ -89,16 +95,18 @@
             currentRemoteRepositories = updateRepositorySet( model, currentRemoteRepositories, pomFile, profileManager );
 
             pomFile = resolveParentPom( model, currentRemoteRepositories, localRepository, pomFile,
-                                        cachedPomFilesByModelId );
+                                        projectBuildCache );
         }
 
         return lineage;
     }
 
     public void resumeBuildingModelLineage( ModelLineage lineage, ArtifactRepository localRepository,
-                                            ProfileManager profileManager, Map cachedPomFilesByModelId )
+                                            ProfileManager profileManager )
         throws ProjectBuildingException
     {
+        ProjectBuildCache projectBuildCache = ProjectBuildCache.read( buildContextManager );
+        
         File pomFile = lineage.getDeepestFile();
         List currentRemoteRepositories = lineage.getDeepestArtifactRepositoryList();
 
@@ -110,11 +118,11 @@
         Model model = lineage.getDeepestModel();
 
         // use the above information to re-bootstrap the resolution chain...
-        pomFile = resolveParentPom( model, currentRemoteRepositories, localRepository, pomFile, cachedPomFilesByModelId );
+        pomFile = resolveParentPom( model, currentRemoteRepositories, localRepository, pomFile, projectBuildCache );
 
         while ( pomFile != null )
         {
-            model = readModel( pomFile, cachedPomFilesByModelId );
+            model = readModel( pomFile, projectBuildCache );
 
             if ( lineage.size() == 0 )
             {
@@ -128,7 +136,7 @@
             currentRemoteRepositories = updateRepositorySet( model, currentRemoteRepositories, pomFile, profileManager );
 
             pomFile = resolveParentPom( model, currentRemoteRepositories, localRepository, pomFile,
-                                        cachedPomFilesByModelId );
+                                        projectBuildCache );
         }
     }
 
@@ -146,10 +154,10 @@
      * Read the Model instance from the given POM file, and cache it in the given Map before 
      * returning it.
      */
-    private Model readModel( File pomFile, Map cachedPomFilesByModelId )
+    private Model readModel( File pomFile, ProjectBuildCache projectBuildCache )
         throws ProjectBuildingException
     {
-        return readModel( pomFile, cachedPomFilesByModelId, false );
+        return readModel( pomFile, projectBuildCache, false );
     }
 
     /**
@@ -157,7 +165,7 @@
      * Model instance in the given Map before returning it. The skipCache flag controls whether the
      * Model instance is actually cached.
      */
-    private Model readModel( File pom, Map cachedPomFilesByModelId, boolean skipCache )
+    private Model readModel( File pom, ProjectBuildCache projectBuildCache, boolean skipCache )
         throws ProjectBuildingException
     {
         File pomFile = pom;
@@ -190,7 +198,8 @@
 
         if ( !skipCache )
         {
-            cachedPomFilesByModelId.put( createCacheKey( model, pomFile ), pomFile );
+            projectBuildCache.cacheModelFileForModel( pomFile, model );
+            projectBuildCache.store( buildContextManager );
         }
 
         return model;
@@ -265,10 +274,10 @@
     /**
      * Pull the parent specification out of the given model, construct an Artifact instance, and
      * resolve that artifact...then, return the resolved POM file for the parent.
-     * @param cachedModelsById 
+     * @param projectBuildCache 
      */
     private File resolveParentPom( Model model, List remoteRepositories, ArtifactRepository localRepository,
-                                   File modelPomFile, Map cachedModelsById )
+                                   File modelPomFile, ProjectBuildCache projectBuildCache )
         throws ProjectBuildingException
     {
         Parent modelParent = model.getParent();
@@ -279,11 +288,9 @@
         {
             validateParentDeclaration( modelParent, model );
 
-            String cacheKey = createCacheKey( modelParent );
-            
 //            getLogger().debug( "Looking for cached parent POM under: " + cacheKey );
             
-            pomFile = (File) cachedModelsById.get( cacheKey );
+            pomFile = (File) projectBuildCache.getCachedModelFile( modelParent );
 
             if ( pomFile == null )
             {
@@ -297,42 +304,6 @@
         }
 
         return pomFile;
-    }
-
-    private String createCacheKey( Parent modelParent )
-    {
-        return modelParent.getGroupId() + ":" + modelParent.getArtifactId() + ":" + modelParent.getVersion();
-    }
-
-    private String createCacheKey( Model model, File pomFile )
-        throws ProjectBuildingException
-    {
-        Parent modelParent = model.getParent();
-
-        String groupId = model.getGroupId();
-
-        if ( groupId == null && modelParent != null )
-        {
-            groupId = modelParent.getGroupId();
-        }
-
-        String artifactId = model.getArtifactId();
-
-        String version = model.getVersion();
-
-        if ( version == null && modelParent != null )
-        {
-            version = modelParent.getVersion();
-        }
-
-        if ( groupId == null || version == null )
-        {
-            throw new ProjectBuildingException( model.getId(),
-                                                "Invalid model. Must either specify groupId and version directly, or specify a parent groupId and version.\nIn POM: "
-                                                    + pomFile );
-        }
-
-        return groupId + ":" + artifactId + ":" + version;
     }
 
     private void validateParentDeclaration( Parent modelParent, Model model )

Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/model/ModelLineageBuilder.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/model/ModelLineageBuilder.java?view=diff&rev=509692&r1=509691&r2=509692
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/model/ModelLineageBuilder.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/model/ModelLineageBuilder.java Tue Feb 20 10:09:53 2007
@@ -6,7 +6,6 @@
 
 import java.io.File;
 import java.util.List;
-import java.util.Map;
 
 /**
  * Builds the lineage of Model instances, starting from a given POM file, and stretching back through
@@ -32,12 +31,9 @@
      *   should be resolved
      * @param profileManager The profile manager containing information about global profiles to be
      *   applied (from settings.xml, for instance)
-     * @param cachedPomFilesByModelId A "global" cache of Model source files, partially for 
-     *   optimization, and partially for loading Models that are unavailable in the repository and 
-     *   have an incorrect relativePath
      */
     ModelLineage buildModelLineage( File pom, ArtifactRepository localRepository, List remoteRepositories,
-                                    ProfileManager profileManager, Map cachedPomFilesByModelId )
+                                    ProfileManager profileManager )
         throws ProjectBuildingException;
 
     /**
@@ -48,12 +44,9 @@
      * @param localRepository The local repository against which parent POMs should be resolved
      * @param profileManager The profile manager containing information about global profiles to be
      *   applied (from settings.xml, for instance)
-     * @param cachedPomFilesByModelId A "global" cache of Model source files, partially for 
-     *   optimization, and partially for loading Models that are unavailable in the repository and 
-     *   have an incorrect relativePath
      */
     void resumeBuildingModelLineage( ModelLineage lineage, ArtifactRepository localRepository,
-                                     ProfileManager profileManager, Map cachedPomFilesByModelId )
+                                     ProfileManager profileManager )
         throws ProjectBuildingException;
 
 }

Modified: maven/components/trunk/maven-project/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/resources/META-INF/plexus/components.xml?view=diff&rev=509692&r1=509691&r2=509692
==============================================================================
--- maven/components/trunk/maven-project/src/main/resources/META-INF/plexus/components.xml (original)
+++ maven/components/trunk/maven-project/src/main/resources/META-INF/plexus/components.xml Tue Feb 20 10:09:53 2007
@@ -1,5 +1,38 @@
 <component-set>
   <components>
+    <!--
+     |
+     | Resolver
+     |
+     -->
+    <component>
+      <role>org.apache.maven.artifact.resolver.ArtifactResolver</role>
+      <implementation>org.apache.maven.project.artifact.CacheAwareArtifactResolver</implementation>
+      <role-hint>project-cache-aware</role-hint>
+      <requirements>
+        <requirement>
+          <role>org.apache.maven.artifact.manager.ArtifactManager</role>
+        </requirement>
+        <requirement>
+          <role>org.apache.maven.artifact.transform.ArtifactTransformationManager</role>
+        </requirement>
+        <requirement>
+          <role>org.apache.maven.artifact.factory.ArtifactFactory</role>
+        </requirement>
+        <requirement>
+          <role>org.apache.maven.artifact.resolver.ArtifactCollector</role>
+        </requirement>
+        <requirement>
+          <role>org.apache.maven.artifact.resolver.ArtifactResolver</role>
+          <role-hint>default</role-hint>
+        </requirement>
+        <requirement>
+          <role>org.apache.maven.context.BuildContextManager</role>
+          <role-hint>default</role-hint>
+        </requirement>
+      </requirements>
+    </component>
+
     <component>
       <role>org.apache.maven.project.build.profile.ProfileAdvisor</role>
       <role-hint>default</role-hint>
@@ -37,6 +70,11 @@
         </requirement>
         <requirement>
           <role>org.apache.maven.artifact.resolver.ArtifactResolver</role>
+          <role-hint>project-cache-aware</role-hint>
+        </requirement>
+        <requirement>
+          <role>org.apache.maven.context.BuildContextManager</role>
+          <role-hint>default</role-hint>
         </requirement>
       </requirements>
     </component>
@@ -264,6 +302,10 @@
         </requirement>
         <requirement>
           <role>org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager</role>
+        </requirement>
+        <requirement>
+          <role>org.apache.maven.context.BuildContextManager</role>
+          <role-hint>default</role-hint>
         </requirement>
       </requirements>
     </component>

Modified: maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/build/model/DefaultModelLineageBuilderTest.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/build/model/DefaultModelLineageBuilderTest.java?view=diff&rev=509692&r1=509691&r2=509692
==============================================================================
--- maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/build/model/DefaultModelLineageBuilderTest.java (original)
+++ maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/build/model/DefaultModelLineageBuilderTest.java Tue Feb 20 10:09:53 2007
@@ -3,10 +3,12 @@
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.artifact.repository.DefaultArtifactRepository;
 import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
+import org.apache.maven.context.BuildContextManager;
 import org.apache.maven.model.Model;
 import org.apache.maven.model.Parent;
 import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
 import org.apache.maven.project.ProjectBuildingException;
+import org.apache.maven.project.build.ProjectBuildCache;
 import org.codehaus.plexus.PlexusTestCase;
 import org.codehaus.plexus.logging.Logger;
 import org.codehaus.plexus.util.FileUtils;
@@ -16,9 +18,7 @@
 import java.io.FileWriter;
 import java.io.IOException;
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.Iterator;
-import java.util.Map;
 
 public class DefaultModelLineageBuilderTest
     extends PlexusTestCase
@@ -68,7 +68,7 @@
             IOUtil.close( writer );
         }
 
-        ModelLineage lineage = modelLineageBuilder.buildModelLineage( pomFile, null, null, null, new HashMap() );
+        ModelLineage lineage = modelLineageBuilder.buildModelLineage( pomFile, null, null, null );
 
         assertEquals( 1, lineage.size() );
 
@@ -126,7 +126,7 @@
             .toExternalForm(), defaultLayout );
 
         ModelLineage lineage = modelLineageBuilder.buildModelLineage( currentPOM, localRepository,
-                                                                      Collections.EMPTY_LIST, null, new HashMap() );
+                                                                      Collections.EMPTY_LIST, null );
 
         assertEquals( 3, lineage.size() );
 
@@ -198,7 +198,7 @@
             .toExternalForm(), defaultLayout );
 
         ModelLineage lineage = modelLineageBuilder.buildModelLineage( currentPOM, localRepository, Collections
-            .singletonList( remoteRepository ), null, new HashMap() );
+            .singletonList( remoteRepository ), null );
 
         assertEquals( 3, lineage.size() );
 
@@ -253,7 +253,7 @@
             .toExternalForm(), defaultLayout );
 
         ModelLineage lineage = modelLineageBuilder.buildModelLineage( currentPOM, localRepository,
-                                                                      Collections.EMPTY_LIST, null, new HashMap() );
+                                                                      Collections.EMPTY_LIST, null );
 
         assertEquals( 2, lineage.size() );
 
@@ -303,7 +303,7 @@
     }
 
     public void testReadPOMWithParentInOtherLocalFileWithBadRelativePath()
-        throws IOException, ProjectBuildingException
+        throws Exception
     {
         // 1. create the parent model in a "local" POM file.
         File parentPOM = File.createTempFile( "DefaultModelLineageBuilder.test.", ".pom" );
@@ -314,8 +314,11 @@
         // 4. write the parent model to the local repo directory
         writeModel( parent, parentPOM );
         
-        Map cache = new HashMap();
-        cache.put( "group:parent:1", parentPOM );
+        BuildContextManager buildContextManager = (BuildContextManager) lookup( BuildContextManager.ROLE, "default" );
+        
+        ProjectBuildCache cache = ProjectBuildCache.read( buildContextManager );
+        cache.cacheModelFileForModel( parentPOM, parent );
+        cache.store( buildContextManager );
 
         // 5. create the current pom with a parent-ref on the parent model
         Model current = createModel( "group", "current", "1" );
@@ -336,13 +339,12 @@
 
         // 7. build the lineage.
         ModelLineage lineage = modelLineageBuilder.buildModelLineage( currentPOM, null, Collections
-            .EMPTY_LIST, null, cache );
+            .EMPTY_LIST, null );
 
         assertEquals( 2, lineage.size() );
 
         Iterator modelIterator = lineage.modelIterator();
 
-        assertEquals( 2, cache.size() );
         assertEquals( current.getId(), ( (Model) modelIterator.next() ).getId() );
         assertEquals( parent.getId(), ( (Model) modelIterator.next() ).getId() );
     }



Re: svn commit: r509692 - in /maven/components/trunk: ./ maven-artifact-manager/src/main/resources/META-INF/plexus/ maven-build-context/src/main/java/org/apache/maven/context/ maven-build-context/src/test/java/org/apache/maven/context/ maven-core/src/main/...

Posted by Jason van Zyl <ja...@maven.org>.
On 20 Feb 07, at 2:30 PM 20 Feb 07, Joakim Erdfelt wrote:

> Any chance we can make this use plexus-cache?

I honestly think that is overkill because it is never going to be  
used past the session because there is no need to. We only need to  
hold the relationship for the life of the reactor to link up compiled  
classes.

> for maven client, we can
> use the simple HashMap based provider, but for larger apps (like
> archiva) we can swap out the usage to a more robust cache provider
> (oscache, ehcache, etc...)

There is no need, they do not live on and never should have past the  
reactor. If you want to build them and cache them for an application  
Maven is not the place for it.

Jason.

>
> - Joakim
>
> jdcasey@apache.org wrote:
>> Author: jdcasey
>> Date: Tue Feb 20 10:09:53 2007
>> New Revision: 509692
>>
>> URL: http://svn.apache.org/viewvc?view=rev&rev=509692
>> Log:
>> Rearranging project-builder caching so it's done externally and  
>> available for use in the model-lineage builder and during artifact  
>> resolution as well.
>>
>> Added:
>>     maven/components/trunk/maven-project/src/main/java/org/apache/ 
>> maven/project/artifact/CacheAwareArtifactResolver.java   (with props)
>>     maven/components/trunk/maven-project/src/main/java/org/apache/ 
>> maven/project/build/ProjectBuildCache.java   (with props)
>> Modified:
>>     maven/components/trunk/build.xml
>>     maven/components/trunk/maven-artifact-manager/src/main/ 
>> resources/META-INF/plexus/components.xml
>>     maven/components/trunk/maven-build-context/src/main/java/org/ 
>> apache/maven/context/BuildContext.java
>>     maven/components/trunk/maven-build-context/src/main/java/org/ 
>> apache/maven/context/DefaultBuildContext.java
>>     maven/components/trunk/maven-build-context/src/main/java/org/ 
>> apache/maven/context/DefaultBuildContextManager.java
>>     maven/components/trunk/maven-build-context/src/main/java/org/ 
>> apache/maven/context/ManagedBuildData.java
>>     maven/components/trunk/maven-build-context/src/main/java/org/ 
>> apache/maven/context/SystemBuildContext.java
>>     maven/components/trunk/maven-build-context/src/test/java/org/ 
>> apache/maven/context/AbstractBuildContextManagerTest.java
>>     maven/components/trunk/maven-core/src/main/java/org/apache/ 
>> maven/DefaultMaven.java
>>     maven/components/trunk/maven-core/src/main/java/org/apache/ 
>> maven/execution/ExecutionBuildContext.java
>>     maven/components/trunk/maven-core/src/main/java/org/apache/ 
>> maven/extension/BuildExtensionScanner.java
>>     maven/components/trunk/maven-core/src/main/java/org/apache/ 
>> maven/extension/DefaultBuildExtensionScanner.java
>>     maven/components/trunk/maven-core/src/main/resources/META-INF/ 
>> plexus/components.xml
>>     maven/components/trunk/maven-project/src/main/java/org/apache/ 
>> maven/profiles/activation/CustomActivatorAdvice.java
>>     maven/components/trunk/maven-project/src/main/java/org/apache/ 
>> maven/project/DefaultMavenProjectBuilder.java
>>     maven/components/trunk/maven-project/src/main/java/org/apache/ 
>> maven/project/artifact/MavenMetadataSource.java
>>     maven/components/trunk/maven-project/src/main/java/org/apache/ 
>> maven/project/build/ProjectBuildContext.java
>>     maven/components/trunk/maven-project/src/main/java/org/apache/ 
>> maven/project/build/model/DefaultModelLineageBuilder.java
>>     maven/components/trunk/maven-project/src/main/java/org/apache/ 
>> maven/project/build/model/ModelLineageBuilder.java
>>     maven/components/trunk/maven-project/src/main/resources/META- 
>> INF/plexus/components.xml
>>     maven/components/trunk/maven-project/src/test/java/org/apache/ 
>> maven/project/build/model/DefaultModelLineageBuilderTest.java
>>
>> Modified: maven/components/trunk/build.xml
>> URL: http://svn.apache.org/viewvc/maven/components/trunk/build.xml? 
>> view=diff&rev=509692&r1=509691&r2=509692
>> ===================================================================== 
>> =========
>> --- maven/components/trunk/build.xml (original)
>> +++ maven/components/trunk/build.xml Tue Feb 20 10:09:53 2007
>> @@ -269,7 +269,9 @@
>>        <classpath refid="maven.classpath"/>
>>        <arg value="-e"/>
>>        <arg value="-B"/>
>> +<!--
>>        <arg value="-X"/>
>> + -->
>>        <arg value="clean"/>
>>        <arg value="install"/>
>>      </java>
>>
>> Modified: maven/components/trunk/maven-artifact-manager/src/main/ 
>> resources/META-INF/plexus/components.xml
>> URL: http://svn.apache.org/viewvc/maven/components/trunk/maven- 
>> artifact-manager/src/main/resources/META-INF/plexus/components.xml? 
>> view=diff&rev=509692&r1=509691&r2=509692
>> ===================================================================== 
>> =========
>> --- maven/components/trunk/maven-artifact-manager/src/main/ 
>> resources/META-INF/plexus/components.xml (original)
>> +++ maven/components/trunk/maven-artifact-manager/src/main/ 
>> resources/META-INF/plexus/components.xml Tue Feb 20 10:09:53 2007
>> @@ -109,6 +109,7 @@
>>      <component>
>>        <role>org.apache.maven.artifact.resolver.ArtifactResolver</ 
>> role>
>>         
>> <implementation>org.apache.maven.artifact.resolver.DefaultArtifactRes 
>> olver</implementation>
>> +      <role-hint>default</role-hint>
>>        <requirements>
>>          <requirement>
>>             
>> <role>org.apache.maven.artifact.manager.ArtifactManager</role>
>>
>> Modified: maven/components/trunk/maven-build-context/src/main/java/ 
>> org/apache/maven/context/BuildContext.java
>> URL: http://svn.apache.org/viewvc/maven/components/trunk/maven- 
>> build-context/src/main/java/org/apache/maven/context/ 
>> BuildContext.java?view=diff&rev=509692&r1=509691&r2=509692
>> ===================================================================== 
>> =========
>> --- maven/components/trunk/maven-build-context/src/main/java/org/ 
>> apache/maven/context/BuildContext.java (original)
>> +++ maven/components/trunk/maven-build-context/src/main/java/org/ 
>> apache/maven/context/BuildContext.java Tue Feb 20 10:09:53 2007
>> @@ -28,7 +28,24 @@
>>      /**
>>       * Add a new piece of managed build data to the build  
>> context. Managed data elements supply their
>>       * own storage key.
>> +     *
>> +     * @deprecated Use store(..) instead.
>>       */
>>      void put( ManagedBuildData managedData );
>> +
>> +    /**
>> +     * Add a new piece of managed build data to the build  
>> context. Managed data elements supply their
>> +     * own storage key.
>> +     */
>> +    void store( ManagedBuildData managedData );
>> +
>> +    /**
>> +     * Retrieve the data map for a given type of managed build  
>> data, and use this to restore this
>> +     * instance's state to that which was stored in the build  
>> context.
>> +     *
>> +     * @param managedData The managed data instance to restore  
>> from the build context.
>> +     * @return true if the data was retrieved from the build  
>> context, false otherwise
>> +     */
>> +    boolean retrieve( ManagedBuildData managedData );
>>
>>  }
>>
>> Modified: maven/components/trunk/maven-build-context/src/main/java/ 
>> org/apache/maven/context/DefaultBuildContext.java
>> URL: http://svn.apache.org/viewvc/maven/components/trunk/maven- 
>> build-context/src/main/java/org/apache/maven/context/ 
>> DefaultBuildContext.java?view=diff&rev=509692&r1=509691&r2=509692
>> ===================================================================== 
>> =========
>> --- maven/components/trunk/maven-build-context/src/main/java/org/ 
>> apache/maven/context/DefaultBuildContext.java (original)
>> +++ maven/components/trunk/maven-build-context/src/main/java/org/ 
>> apache/maven/context/DefaultBuildContext.java Tue Feb 20 10:09:53  
>> 2007
>> @@ -76,10 +76,41 @@
>>      /**
>>       * Add a new piece of managed data to the build context,  
>> using the key supplied by
>>       * managedData.getStorageKey().
>> +     *
>> +     * @deprecated Use store(..) instead
>>       */
>>      public void put( ManagedBuildData managedData )
>>      {
>> -        contextMap.put( managedData.getStorageKey(), managedData );
>> +        store( managedData );
>> +    }
>> +
>> +    /**
>> +     * Add a new piece of managed data to the build context,  
>> using the key supplied by
>> +     * managedData.getStorageKey().
>> +     */
>> +    public void store( ManagedBuildData managedData )
>> +    {
>> +        contextMap.put( managedData.getStorageKey(),  
>> managedData.getData() );
>> +    }
>> +
>> +    /**
>> +     * Retrieve the data map for a given type of managed build  
>> data, and use this to restore this
>> +     * instance's state to that which was stored in the build  
>> context.
>> +     *
>> +     * @param managedData The managed data instance to restore  
>> from the build context.
>> +     * @return true if the data was retrieved from the build  
>> context, false otherwise
>> +     */
>> +    public boolean retrieve( ManagedBuildData managedData )
>> +    {
>> +        Map dataMap = (Map) contextMap.get 
>> ( managedData.getStorageKey() );
>> +
>> +        if ( dataMap != null )
>> +        {
>> +            managedData.setData( dataMap );
>> +            return true;
>> +        }
>> +
>> +        return false;
>>      }
>>
>>  }
>>
>> Modified: maven/components/trunk/maven-build-context/src/main/java/ 
>> org/apache/maven/context/DefaultBuildContextManager.java
>> URL: http://svn.apache.org/viewvc/maven/components/trunk/maven- 
>> build-context/src/main/java/org/apache/maven/context/ 
>> DefaultBuildContextManager.java? 
>> view=diff&rev=509692&r1=509691&r2=509692
>> ===================================================================== 
>> =========
>> --- maven/components/trunk/maven-build-context/src/main/java/org/ 
>> apache/maven/context/DefaultBuildContextManager.java (original)
>> +++ maven/components/trunk/maven-build-context/src/main/java/org/ 
>> apache/maven/context/DefaultBuildContextManager.java Tue Feb 20  
>> 10:09:53 2007
>> @@ -1,8 +1,6 @@
>>  package org.apache.maven.context;
>>
>>  import org.codehaus.plexus.context.Context;
>> -import org.codehaus.plexus.context.ContextException;
>> -import  
>> org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizab 
>> le;
>>
>>  import java.util.HashMap;
>>  import java.util.Map;
>> @@ -14,22 +12,25 @@
>>   * @author jdcasey
>>   */
>>  public class DefaultBuildContextManager
>> -    implements BuildContextManager, Contextualizable
>> +    implements BuildContextManager
>>  {
>>      public static final String ROLE_HINT = "default";
>>
>>      protected static final String BUILD_CONTEXT_MAP_KEY = ROLE +  
>> ":" + ROLE_HINT + ":contextMap";
>>
>> -    private Context context;
>> +    private InheritableThreadLocal tl = new InheritableThreadLocal 
>> ();
>>
>>      public DefaultBuildContextManager()
>>      {
>>          // used for plexus initialization
>>      }
>>
>> +    /**
>> +     * @deprecated Using ThreadLocal now, not container context,  
>> for thread safety.
>> +     */
>>      public DefaultBuildContextManager( Context context )
>>      {
>> -        this.context = context;
>> +        // obsolete, does nothing...
>>      }
>>
>>      /**
>> @@ -37,7 +38,7 @@
>>       */
>>      public void clearBuildContext()
>>      {
>> -        clearContextContainerMap();
>> +        tl.set( null );
>>      }
>>
>>      /**
>> @@ -49,7 +50,7 @@
>>      {
>>          Map contextMap = getContextContainerMap( create );
>>
>> -        if ( !create && contextMap == null )
>> +        if ( contextMap == null && !create )
>>          {
>>              return null;
>>          }
>> @@ -66,7 +67,7 @@
>>      {
>>          if ( context instanceof DefaultBuildContext )
>>          {
>> -            this.context.put( BUILD_CONTEXT_MAP_KEY,  
>> ((DefaultBuildContext)context).getContextMap() );
>> +            tl.set( ((DefaultBuildContext)context).getContextMap 
>> () );
>>          }
>>          else
>>          {
>> @@ -76,25 +77,12 @@
>>
>>      protected Map getContextContainerMap( boolean create )
>>      {
>> -        Map containerMap = null;
>> +        Map containerMap = (Map) tl.get();
>>
>> -        if ( context.contains( BUILD_CONTEXT_MAP_KEY ) )
>> -        {
>> -            try
>> -            {
>> -                containerMap = (Map) context.get 
>> ( BUILD_CONTEXT_MAP_KEY );
>> -            }
>> -            catch ( ContextException e )
>> -            {
>> -                throw new IllegalStateException( "Failed to  
>> retrieve BuildAdvisor "
>> -                                + "serialization map from  
>> context, though the context claims it exists. Error: "
>> -                                + e.getMessage() );
>> -            }
>> -        }
>> -        else if ( create )
>> +        if ( containerMap == null && create )
>>          {
>>              containerMap = new HashMap();
>> -            context.put( BUILD_CONTEXT_MAP_KEY, containerMap );
>> +            tl.set( containerMap );
>>          }
>>
>>          return containerMap;
>> @@ -111,20 +99,12 @@
>>      }
>>
>>      /**
>> -     * Retrieve the container context for storing the  
>> BuildContext data.
>> +     * @deprecated Using ThreadLocal now, not container context,  
>> for thread safety.
>>       */
>> -    public void contextualize( Context context )
>> -        throws ContextException
>> -    {
>> -        this.context = context;
>> -    }
>> -
>>      public Context reorientToContext( Context context )
>>      {
>> -        Context oldContext = this.context;
>> -        this.context = context;
>> -
>> -        return oldContext;
>> +        // obsolete, does nothing...
>> +        return context;
>>      }
>>
>>  }
>>
>> Modified: maven/components/trunk/maven-build-context/src/main/java/ 
>> org/apache/maven/context/ManagedBuildData.java
>> URL: http://svn.apache.org/viewvc/maven/components/trunk/maven- 
>> build-context/src/main/java/org/apache/maven/context/ 
>> ManagedBuildData.java?view=diff&rev=509692&r1=509691&r2=509692
>> ===================================================================== 
>> =========
>> --- maven/components/trunk/maven-build-context/src/main/java/org/ 
>> apache/maven/context/ManagedBuildData.java (original)
>> +++ maven/components/trunk/maven-build-context/src/main/java/org/ 
>> apache/maven/context/ManagedBuildData.java Tue Feb 20 10:09:53 2007
>> @@ -1,5 +1,7 @@
>>  package org.apache.maven.context;
>>
>> +import java.util.Map;
>> +
>>  /**
>>   * Management interface for things that are meant to be stored/ 
>> retrieved from the Maven BuildContext
>>   * natively. Such things need to give the BuildContextManager a  
>> key for mapping it into the context.
>> @@ -17,5 +19,21 @@
>>       * @return The BuildContext mapping key.
>>       */
>>      String getStorageKey();
>> +
>> +    /**
>> +     * Provides a way for a complex object to serialize itself to  
>> primitives for storage in the
>> +     * build context, so the same class loaded from different  
>> classloaders (as in the case of plugin
>> +     * dependencies) don't incur a ClassCastException when trying  
>> to retrieve stored information.
>> +     *
>> +     * @return The object's data in primitive (shared classes,  
>> like Strings) form, keyed for
>> +     *   retrieval.
>> +     */
>> +    Map getData();
>> +
>> +    /**
>> +     * Restore the object's state from the primitives stored in  
>> the build context.
>> +     * @param data The map of primitives that were stored in the  
>> build context
>> +     */
>> +    void setData( Map data );
>>
>>  }
>>
>> Modified: maven/components/trunk/maven-build-context/src/main/java/ 
>> org/apache/maven/context/SystemBuildContext.java
>> URL: http://svn.apache.org/viewvc/maven/components/trunk/maven- 
>> build-context/src/main/java/org/apache/maven/context/ 
>> SystemBuildContext.java?view=diff&rev=509692&r1=509691&r2=509692
>> ===================================================================== 
>> =========
>> --- maven/components/trunk/maven-build-context/src/main/java/org/ 
>> apache/maven/context/SystemBuildContext.java (original)
>> +++ maven/components/trunk/maven-build-context/src/main/java/org/ 
>> apache/maven/context/SystemBuildContext.java Tue Feb 20 10:09:53 2007
>> @@ -1,5 +1,7 @@
>>  package org.apache.maven.context;
>>
>> +import java.util.HashMap;
>> +import java.util.Map;
>>  import java.util.Properties;
>>
>>  public class SystemBuildContext
>> @@ -7,6 +9,10 @@
>>  {
>>
>>      public static final String BUILD_CONTEXT_KEY =  
>> SystemBuildContext.class.getName();
>> +
>> +    private static final String SYSTEM_PROPERTIES_KEY = "system- 
>> properties";
>> +
>> +    private static final String ENVIRONMENT_VARIABLES_KEY =  
>> "environment-variables";
>>
>>      private Properties systemProperties;
>>      private Properties envars;
>> @@ -50,11 +56,16 @@
>>      {
>>          BuildContext buildContext =  
>> buildContextManager.readBuildContext( false );
>>
>> -        SystemBuildContext systemContext = null;
>> +        SystemBuildContext systemContext = new SystemBuildContext();
>>
>>          if ( buildContext != null )
>>          {
>> -            systemContext = (SystemBuildContext) buildContext.get 
>> ( BUILD_CONTEXT_KEY );
>> +            SystemBuildContext ctx = new SystemBuildContext();
>> +
>> +            if ( buildContext.retrieve( ctx ) || create )
>> +            {
>> +                systemContext = ctx;
>> +            }
>>          }
>>
>>          if ( create && systemContext == null )
>> @@ -69,8 +80,23 @@
>>      {
>>          BuildContext buildContext =  
>> buildContextManager.readBuildContext( true );
>>
>> -        buildContext.put( this );
>> +        buildContext.store( this );
>>
>>          buildContextManager.storeBuildContext( buildContext );
>> +    }
>> +
>> +    public Map getData()
>> +    {
>> +        Map data = new HashMap( 2 );
>> +        data.put( SYSTEM_PROPERTIES_KEY, systemProperties );
>> +        data.put( ENVIRONMENT_VARIABLES_KEY, envars );
>> +
>> +        return data;
>> +    }
>> +
>> +    public void setData( Map data )
>> +    {
>> +        this.systemProperties = (Properties) data.get 
>> ( SYSTEM_PROPERTIES_KEY );
>> +        this.envars = (Properties) data.get 
>> ( ENVIRONMENT_VARIABLES_KEY );
>>      }
>>  }
>>
>> Modified: maven/components/trunk/maven-build-context/src/test/java/ 
>> org/apache/maven/context/AbstractBuildContextManagerTest.java
>> URL: http://svn.apache.org/viewvc/maven/components/trunk/maven- 
>> build-context/src/test/java/org/apache/maven/context/ 
>> AbstractBuildContextManagerTest.java? 
>> view=diff&rev=509692&r1=509691&r2=509692
>> ===================================================================== 
>> =========
>> --- maven/components/trunk/maven-build-context/src/test/java/org/ 
>> apache/maven/context/AbstractBuildContextManagerTest.java (original)
>> +++ maven/components/trunk/maven-build-context/src/test/java/org/ 
>> apache/maven/context/AbstractBuildContextManagerTest.java Tue Feb  
>> 20 10:09:53 2007
>> @@ -71,7 +71,7 @@
>>
>>          BuildContext ctx3 = mgr.readBuildContext( false );
>>
>> -        assertNull( ctx3.get( key ) );
>> +        assertNull( ctx3 );
>>      }
>>
>>  }
>>
>> Modified: maven/components/trunk/maven-core/src/main/java/org/ 
>> apache/maven/DefaultMaven.java
>> URL: http://svn.apache.org/viewvc/maven/components/trunk/maven- 
>> core/src/main/java/org/apache/maven/DefaultMaven.java? 
>> view=diff&rev=509692&r1=509691&r2=509692
>> ===================================================================== 
>> =========
>> --- maven/components/trunk/maven-core/src/main/java/org/apache/ 
>> maven/DefaultMaven.java (original)
>> +++ maven/components/trunk/maven-core/src/main/java/org/apache/ 
>> maven/DefaultMaven.java Tue Feb 20 10:09:53 2007
>> @@ -31,7 +31,6 @@
>>  import org.apache.maven.execution.ReactorManager;
>>  import org.apache.maven.execution.RuntimeInformation;
>>  import org.apache.maven.extension.BuildExtensionScanner;
>> -import org.apache.maven.extension.ExtensionManager;
>>  import org.apache.maven.extension.ExtensionScanningException;
>>  import org.apache.maven.lifecycle.LifecycleExecutor;
>>  import org.apache.maven.monitor.event.DefaultEventDispatcher;
>> @@ -44,7 +43,6 @@
>>  import org.apache.maven.project.MavenProject;
>>  import org.apache.maven.project.MavenProjectBuilder;
>>  import org.apache.maven.project.ProjectBuildingException;
>> -import org.apache.maven.project.build.model.ModelLineageBuilder;
>>  import org.apache.maven.reactor.MavenExecutionException;
>>  import org.apache.maven.settings.Settings;
>>  import org.apache.maven.usability.diagnostics.ErrorDiagnostics;
>> @@ -64,10 +62,8 @@
>>  import java.util.ArrayList;
>>  import java.util.Collections;
>>  import java.util.Date;
>> -import java.util.HashMap;
>>  import java.util.Iterator;
>>  import java.util.List;
>> -import java.util.Map;
>>  import java.util.TimeZone;
>>
>>  /**
>> @@ -347,15 +343,13 @@
>>
>>          // TODO: We should probably do this discovery just-in- 
>> time, if we can move to building project
>>          // instances just-in-time.
>> -        Map cache = new HashMap();
>> -
>>          for ( Iterator it = files.iterator(); it.hasNext(); )
>>          {
>>              File pom = (File) it.next();
>>
>>              try
>>              {
>> -                buildExtensionScanner.scanForBuildExtensions 
>> ( pom, request.getLocalRepository(), globalProfileManager, cache );
>> +                buildExtensionScanner.scanForBuildExtensions 
>> ( pom, request.getLocalRepository(), globalProfileManager );
>>              }
>>              catch ( ExtensionScanningException e )
>>              {
>>
>> Modified: maven/components/trunk/maven-core/src/main/java/org/ 
>> apache/maven/execution/ExecutionBuildContext.java
>> URL: http://svn.apache.org/viewvc/maven/components/trunk/maven- 
>> core/src/main/java/org/apache/maven/execution/ 
>> ExecutionBuildContext.java?view=diff&rev=509692&r1=509691&r2=509692
>> ===================================================================== 
>> =========
>> --- maven/components/trunk/maven-core/src/main/java/org/apache/ 
>> maven/execution/ExecutionBuildContext.java (original)
>> +++ maven/components/trunk/maven-core/src/main/java/org/apache/ 
>> maven/execution/ExecutionBuildContext.java Tue Feb 20 10:09:53 2007
>> @@ -11,6 +11,7 @@
>>  import java.util.Collections;
>>  import java.util.Date;
>>  import java.util.List;
>> +import java.util.Map;
>>  import java.util.Properties;
>>
>>  /*
>> @@ -39,7 +40,13 @@
>>
>>      public static final String BUILD_CONTEXT_KEY =  
>> ExecutionBuildContext.class.getName();
>>
>> -    private final MavenExecutionRequest request;
>> +    private static final String REQUEST_KEY = "request";
>> +
>> +    private MavenExecutionRequest request;
>> +
>> +    private ExecutionBuildContext()
>> +    {
>> +    }
>>
>>      public ExecutionBuildContext( MavenExecutionRequest request )
>>      {
>> @@ -195,11 +202,14 @@
>>      {
>>          BuildContext buildContext =  
>> buildContextManager.readBuildContext( false );
>>
>> -        ExecutionBuildContext executionContext = null;
>> +        ExecutionBuildContext executionContext = new  
>> ExecutionBuildContext();
>>
>>          if ( buildContext != null )
>>          {
>> -            executionContext = (ExecutionBuildContext)  
>> buildContext.get( BUILD_CONTEXT_KEY );
>> +            if ( !buildContext.retrieve( executionContext ) )
>> +            {
>> +                return null;
>> +            }
>>          }
>>
>>          return executionContext;
>> @@ -209,8 +219,18 @@
>>      {
>>          BuildContext buildContext =  
>> buildContextManager.readBuildContext( true );
>>
>> -        buildContext.put( this );
>> +        buildContext.store( this );
>>
>>          buildContextManager.storeBuildContext( buildContext );
>> +    }
>> +
>> +    public Map getData()
>> +    {
>> +        return Collections.singletonMap( REQUEST_KEY, request );
>> +    }
>> +
>> +    public void setData( Map data )
>> +    {
>> +        this.request = (MavenExecutionRequest) data.get 
>> ( REQUEST_KEY );
>>      }
>>  }
>>
>> Modified: maven/components/trunk/maven-core/src/main/java/org/ 
>> apache/maven/extension/BuildExtensionScanner.java
>> URL: http://svn.apache.org/viewvc/maven/components/trunk/maven- 
>> core/src/main/java/org/apache/maven/extension/ 
>> BuildExtensionScanner.java?view=diff&rev=509692&r1=509691&r2=509692
>> ===================================================================== 
>> =========
>> --- maven/components/trunk/maven-core/src/main/java/org/apache/ 
>> maven/extension/BuildExtensionScanner.java (original)
>> +++ maven/components/trunk/maven-core/src/main/java/org/apache/ 
>> maven/extension/BuildExtensionScanner.java Tue Feb 20 10:09:53 2007
>> @@ -4,14 +4,13 @@
>>  import org.apache.maven.profiles.ProfileManager;
>>
>>  import java.io.File;
>> -import java.util.Map;
>>
>>  public interface BuildExtensionScanner
>>  {
>>
>>      String ROLE = BuildExtensionScanner.class.getName();
>>
>> -    void scanForBuildExtensions( File pom, ArtifactRepository  
>> localRepository, ProfileManager globalProfileManager, Map  
>> pomFilesById )
>> +    void scanForBuildExtensions( File pom, ArtifactRepository  
>> localRepository, ProfileManager globalProfileManager )
>>          throws ExtensionScanningException;
>>
>>  }
>>
>> Modified: maven/components/trunk/maven-core/src/main/java/org/ 
>> apache/maven/extension/DefaultBuildExtensionScanner.java
>> URL: http://svn.apache.org/viewvc/maven/components/trunk/maven- 
>> core/src/main/java/org/apache/maven/extension/ 
>> DefaultBuildExtensionScanner.java? 
>> view=diff&rev=509692&r1=509691&r2=509692
>> ===================================================================== 
>> =========
>> --- maven/components/trunk/maven-core/src/main/java/org/apache/ 
>> maven/extension/DefaultBuildExtensionScanner.java (original)
>> +++ maven/components/trunk/maven-core/src/main/java/org/apache/ 
>> maven/extension/DefaultBuildExtensionScanner.java Tue Feb 20  
>> 10:09:53 2007
>> @@ -8,6 +8,7 @@
>>  import org.apache.maven.model.Build;
>>  import org.apache.maven.model.Extension;
>>  import org.apache.maven.model.Model;
>> +import org.apache.maven.model.Parent;
>>  import org.apache.maven.profiles.ProfileManager;
>>  import org.apache.maven.profiles.activation.CustomActivatorAdvice;
>>  import org.apache.maven.project.MavenProject;
>> @@ -25,6 +26,7 @@
>>
>>  import java.io.File;
>>  import java.io.IOException;
>> +import java.util.ArrayList;
>>  import java.util.HashMap;
>>  import java.util.Iterator;
>>  import java.util.List;
>> @@ -48,9 +50,17 @@
>>      private ModelInterpolator modelInterpolator;
>>
>>      public void scanForBuildExtensions( File pom,  
>> ArtifactRepository localRepository,
>> -                                        ProfileManager  
>> globalProfileManager, Map pomFilesById )
>> +                                        ProfileManager  
>> globalProfileManager )
>>          throws ExtensionScanningException
>>      {
>> +        scanInternal( pom, localRepository, globalProfileManager,  
>> new ArrayList() );
>> +    }
>> +
>> +    private void scanInternal( File pom, ArtifactRepository  
>> localRepository, ProfileManager globalProfileManager,
>> +                               List visitedModelIds )
>> +        throws ExtensionScanningException
>> +    {
>> +
>>          // setup the CustomActivatorAdvice to fail quietly while  
>> we discover extensions...then, we'll
>>          // reset it.
>>          CustomActivatorAdvice activatorAdvice =  
>> CustomActivatorAdvice.getCustomActivatorAdvice 
>> ( buildContextManager );
>> @@ -64,15 +74,26 @@
>>              getLogger().debug( "Pre-scanning POM lineage of: " +  
>> pom + " for build extensions." );
>>
>>              ModelLineage lineage = buildModelLineage( pom,  
>> localRepository, originalRemoteRepositories,
>> -                                                       
>> globalProfileManager, pomFilesById );
>> +                                                       
>> globalProfileManager );
>>
>>              Map inheritedInterpolationValues = new HashMap();
>>
>>              for ( ModelLineageIterator lineageIterator =  
>> lineage.reversedLineageIterator(); lineageIterator.hasNext(); )
>>              {
>>                  Model model = (Model) lineageIterator.next();
>> +                String key = createKey( model );
>> +
>> +                if ( visitedModelIds.contains( key ) )
>> +                {
>> +                    getLogger().debug( "Already visited: " + key  
>> + "; continuing." );
>> +                    continue;
>> +                }
>> +
>> +                visitedModelIds.add( key );
>> +
>> +                File modelPom = lineageIterator.getPOMFile();
>>
>> -                getLogger().debug( "Checking: " + model.getId() +  
>> " for extensions." );
>> +                getLogger().debug( "Checking: " + model.getId() +  
>> " for extensions. (It has " + model.getModules().size() + "  
>> modules.)" );
>>
>>                  if ( inheritedInterpolationValues == null )
>>                  {
>> @@ -83,8 +104,7 @@
>>
>>                  checkModelBuildForExtensions( model,  
>> localRepository, lineageIterator.getArtifactRepositories() );
>>
>> -                checkModulesForExtensions( pom, model,  
>> localRepository, originalRemoteRepositories, globalProfileManager,
>> -                                           pomFilesById );
>> +                checkModulesForExtensions( modelPom, model,  
>> localRepository, originalRemoteRepositories, globalProfileManager,  
>> visitedModelIds );
>>
>>                  Properties modelProps = model.getProperties();
>>                  if ( modelProps != null )
>> @@ -108,9 +128,24 @@
>>          }
>>      }
>>
>> +    private String createKey( Model model )
>> +    {
>> +        Parent parent = model.getParent();
>> +
>> +        String groupId = model.getGroupId();
>> +        if ( groupId == null )
>> +        {
>> +            groupId = parent.getGroupId();
>> +        }
>> +
>> +        String artifactId = model.getArtifactId();
>> +
>> +        return groupId + ":" + artifactId;
>> +    }
>> +
>>      private void checkModulesForExtensions( File containingPom,  
>> Model model, ArtifactRepository localRepository,
>>                                              List  
>> originalRemoteRepositories, ProfileManager globalProfileManager,
>> -                                            Map pomFilesById )
>> +                                            List visitedModelIds )
>>          throws ExtensionScanningException
>>      {
>>          // FIXME: This gets a little sticky, because modules can  
>> be added by profiles that require
>> @@ -120,6 +155,7 @@
>>          if ( modules != null )
>>          {
>>              File basedir = containingPom.getParentFile();
>> +            getLogger().debug( "Basedir is: " + basedir );
>>
>>              for ( Iterator it = modules.iterator(); it.hasNext(); )
>>              {
>> @@ -170,11 +206,11 @@
>>                  {
>>                      getLogger().debug(
>>                                         "Cannot find POM for  
>> module: " + moduleSubpath
>> -                                           + "; continuing scan  
>> with next module." );
>> +                                           + "; continuing scan  
>> with next module. (Full path was: " + modulePomDirectory + ")" );
>>                      continue;
>>                  }
>>
>> -                scanForBuildExtensions( modulePomDirectory,  
>> localRepository, globalProfileManager, pomFilesById );
>> +                scanInternal( modulePomDirectory,  
>> localRepository, globalProfileManager, visitedModelIds );
>>              }
>>          }
>>      }
>> @@ -226,8 +262,7 @@
>>      }
>>
>>      private ModelLineage buildModelLineage( File pom,  
>> ArtifactRepository localRepository,
>> -                                            List  
>> originalRemoteRepositories, ProfileManager globalProfileManager,
>> -                                            Map cache )
>> +                                            List  
>> originalRemoteRepositories, ProfileManager globalProfileManager )
>>          throws ExtensionScanningException
>>      {
>>          ModelLineage lineage;
>> @@ -236,7 +271,7 @@
>>              getLogger().debug( "Building model-lineage for: " +  
>> pom + " to pre-scan for extensions." );
>>
>>              lineage = modelLineageBuilder.buildModelLineage( pom,  
>> localRepository, originalRemoteRepositories,
>> -                                                              
>> globalProfileManager, cache );
>> +                                                              
>> globalProfileManager );
>>          }
>>          catch ( ProjectBuildingException e )
>>          {
>>
>> Modified: maven/components/trunk/maven-core/src/main/resources/ 
>> META-INF/plexus/components.xml
>> URL: http://svn.apache.org/viewvc/maven/components/trunk/maven- 
>> core/src/main/resources/META-INF/plexus/components.xml? 
>> view=diff&rev=509692&r1=509691&r2=509692
>> ===================================================================== 
>> =========
>> --- maven/components/trunk/maven-core/src/main/resources/META-INF/ 
>> plexus/components.xml (original)
>> +++ maven/components/trunk/maven-core/src/main/resources/META-INF/ 
>> plexus/components.xml Tue Feb 20 10:09:53 2007
>> @@ -50,6 +50,7 @@
>>          </requirement>
>>          <requirement>
>>             
>> <role>org.apache.maven.artifact.resolver.ArtifactResolver</role>
>> +          <role-hint>project-cache-aware</role-hint>
>>          </requirement>
>>          <requirement>
>>             
>> <role>org.apache.maven.artifact.metadata.ArtifactMetadataSource</ 
>> role>
>> @@ -78,6 +79,7 @@
>>          </requirement>
>>          <requirement>
>>             
>> <role>org.apache.maven.artifact.resolver.ArtifactResolver</role>
>> +          <role-hint>project-cache-aware</role-hint>
>>          </requirement>
>>          <requirement>
>>             
>> <role>org.apache.maven.artifact.metadata.ArtifactMetadataSource</ 
>> role>
>>
>> Modified: maven/components/trunk/maven-project/src/main/java/org/ 
>> apache/maven/profiles/activation/CustomActivatorAdvice.java
>> URL: http://svn.apache.org/viewvc/maven/components/trunk/maven- 
>> project/src/main/java/org/apache/maven/profiles/activation/ 
>> CustomActivatorAdvice.java?view=diff&rev=509692&r1=509691&r2=509692
>> ===================================================================== 
>> =========
>> --- maven/components/trunk/maven-project/src/main/java/org/apache/ 
>> maven/profiles/activation/CustomActivatorAdvice.java (original)
>> +++ maven/components/trunk/maven-project/src/main/java/org/apache/ 
>> maven/profiles/activation/CustomActivatorAdvice.java Tue Feb 20  
>> 10:09:53 2007
>> @@ -4,6 +4,9 @@
>>  import org.apache.maven.context.BuildContextManager;
>>  import org.apache.maven.context.ManagedBuildData;
>>
>> +import java.util.Collections;
>> +import java.util.Map;
>> +
>>  /**
>>   * Advice for the custom profile activator, which tells how to  
>> handle cases where custom activators
>>   * cannot be found or configured. This is used to suppress  
>> missing activators when pre-scanning for
>> @@ -17,6 +20,8 @@
>>
>>      public static final String BUILD_CONTEXT_KEY =  
>> CustomActivatorAdvice.class.getName();
>>
>> +    private static final String FAIL_QUIETLY_KEY = "fail-quietly";
>> +
>>      private static final boolean DEFAULT_FAIL_QUIETLY = false;
>>
>>      /**
>> @@ -54,16 +59,11 @@
>>      {
>>          BuildContext buildContext =  
>> buildContextManager.readBuildContext( false );
>>
>> -        CustomActivatorAdvice advice = null;
>> +        CustomActivatorAdvice advice = new CustomActivatorAdvice();
>>
>>          if ( buildContext != null )
>>          {
>> -            advice = (CustomActivatorAdvice) buildContext.get 
>> ( BUILD_CONTEXT_KEY );
>> -        }
>> -
>> -        if ( advice == null )
>> -        {
>> -            advice = new CustomActivatorAdvice();
>> +            buildContext.retrieve( advice );
>>          }
>>
>>          return advice;
>> @@ -73,8 +73,18 @@
>>      {
>>          BuildContext buildContext =  
>> buildContextManager.readBuildContext( true );
>>
>> -        buildContext.put( this );
>> +        buildContext.store( this );
>>
>>          buildContextManager.storeBuildContext( buildContext );
>> +    }
>> +
>> +    public Map getData()
>> +    {
>> +        return Collections.singletonMap( FAIL_QUIETLY_KEY,  
>> Boolean.valueOf( failQuietly ) );
>> +    }
>> +
>> +    public void setData( Map data )
>> +    {
>> +        this.failQuietly = ((Boolean) data.get 
>> ( FAIL_QUIETLY_KEY )).booleanValue();
>>      }
>>  }
>>
>> Modified: maven/components/trunk/maven-project/src/main/java/org/ 
>> apache/maven/project/DefaultMavenProjectBuilder.java
>> URL: http://svn.apache.org/viewvc/maven/components/trunk/maven- 
>> project/src/main/java/org/apache/maven/project/ 
>> DefaultMavenProjectBuilder.java? 
>> view=diff&rev=509692&r1=509691&r2=509692
>> ===================================================================== 
>> =========
>> --- maven/components/trunk/maven-project/src/main/java/org/apache/ 
>> maven/project/DefaultMavenProjectBuilder.java (original)
>> +++ maven/components/trunk/maven-project/src/main/java/org/apache/ 
>> maven/project/DefaultMavenProjectBuilder.java Tue Feb 20 10:09:53  
>> 2007
>> @@ -23,7 +23,6 @@
>>  import org.apache.maven.artifact.InvalidRepositoryException;
>>  import org.apache.maven.artifact.factory.ArtifactFactory;
>>  import org.apache.maven.artifact.manager.ArtifactManager;
>> -import org.apache.maven.artifact.manager.WagonManager;
>>  import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
>>  import org.apache.maven.artifact.repository.ArtifactRepository;
>>  import  
>> org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
>> @@ -48,6 +47,7 @@
>>  import org.apache.maven.profiles.ProfileManager;
>>  import  
>> org.apache.maven.profiles.activation.ProfileActivationException;
>>  import  
>> org.apache.maven.project.artifact.InvalidDependencyVersionException;
>> +import org.apache.maven.project.build.ProjectBuildCache;
>>  import org.apache.maven.project.build.ProjectBuildContext;
>>  import org.apache.maven.project.build.model.DefaultModelLineage;
>>  import org.apache.maven.project.build.model.ModelLineage;
>> @@ -151,10 +151,6 @@
>>
>>      private ModelValidator validator;
>>
>> -    private Map processedProjectCache = new HashMap();
>> -
>> -    private Map cachedPomFilesByModelId = new HashMap();
>> -
>>      // TODO: make it a component
>>      private MavenXpp3Reader modelReader;
>>
>> @@ -220,9 +216,9 @@
>>                                               boolean  
>> allowStubModel )
>>          throws ProjectBuildingException
>>      {
>> -        String cacheKey = createCacheKey( artifact.getGroupId(),  
>> artifact.getArtifactId(), artifact.getVersion() );
>> -
>> -        MavenProject project = (MavenProject)  
>> processedProjectCache.get( cacheKey );
>> +        ProjectBuildCache projectBuildCache =  
>> ProjectBuildCache.read( buildContextManager );
>> +
>> +        MavenProject project = (MavenProject)  
>> projectBuildCache.getCachedProject( artifact );
>>
>>          if ( project != null )
>>          {
>> @@ -753,7 +749,9 @@
>>              throw new InvalidProjectModelException( projectId,  
>> pomLocation, e.getMessage(), e );
>>          }
>>
>> -        processedProjectCache.put( createCacheKey 
>> ( project.getGroupId(), project.getArtifactId(), project.getVersion 
>> () ), project );
>> +        ProjectBuildCache projectBuildCache =  
>> ProjectBuildCache.read( buildContextManager );
>> +        projectBuildCache.cacheProject( project );
>> +        projectBuildCache.store( buildContextManager );
>>
>>          // jvz:note
>>          // this only happens if we are building from a source file
>> @@ -778,9 +776,7 @@
>>
>>          if ( rawParent != null )
>>          {
>> -            String cacheKey = createCacheKey( rawParent.getGroupId 
>> (), rawParent.getArtifactId(), rawParent.getVersion() );
>> -
>> -            MavenProject processedParent = (MavenProject)  
>> processedProjectCache.get( cacheKey );
>> +            MavenProject processedParent = (MavenProject)  
>> projectBuildCache.getCachedProject( rawParent );
>>
>>              // yeah, this null check might be a bit paranoid, but  
>> better safe than sorry...
>>              if ( processedParent != null )
>> @@ -1012,7 +1008,7 @@
>>          ModelLineage modelLineage = new DefaultModelLineage();
>>          modelLineage.setOrigin( model, new File( projectDir,  
>> "pom.xml" ), new ArrayList( aggregatedRemoteWagonRepositories ) );
>>
>> -        modelLineageBuilder.resumeBuildingModelLineage 
>> ( modelLineage, localRepository, externalProfileManager,  
>> cachedPomFilesByModelId );
>> +        modelLineageBuilder.resumeBuildingModelLineage 
>> ( modelLineage, localRepository, externalProfileManager );
>>
>>          ProjectBuildContext projectContext =  
>> ProjectBuildContext.getProjectBuildContext( buildContextManager,  
>> true );
>>
>>
>> Added: maven/components/trunk/maven-project/src/main/java/org/ 
>> apache/maven/project/artifact/CacheAwareArtifactResolver.java
>> URL: http://svn.apache.org/viewvc/maven/components/trunk/maven- 
>> project/src/main/java/org/apache/maven/project/artifact/ 
>> CacheAwareArtifactResolver.java?view=auto&rev=509692
>> ===================================================================== 
>> =========
>> --- maven/components/trunk/maven-project/src/main/java/org/apache/ 
>> maven/project/artifact/CacheAwareArtifactResolver.java (added)
>> +++ maven/components/trunk/maven-project/src/main/java/org/apache/ 
>> maven/project/artifact/CacheAwareArtifactResolver.java Tue Feb 20  
>> 10:09:53 2007
>> @@ -0,0 +1,80 @@
>> +package org.apache.maven.project.artifact;
>> +
>> +import org.apache.maven.artifact.Artifact;
>> +import org.apache.maven.artifact.handler.ArtifactHandler;
>> +import org.apache.maven.artifact.repository.ArtifactRepository;
>> +import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
>> +import  
>> org.apache.maven.artifact.resolver.ArtifactResolutionException;
>> +import org.apache.maven.artifact.resolver.ArtifactResolver;
>> +import org.apache.maven.artifact.resolver.DefaultArtifactResolver;
>> +import org.apache.maven.context.BuildContextManager;
>> +import org.apache.maven.project.MavenProject;
>> +import org.apache.maven.project.build.ProjectBuildCache;
>> +
>> +import java.io.File;
>> +import java.util.List;
>> +
>> +public class CacheAwareArtifactResolver
>> +    extends DefaultArtifactResolver
>> +{
>> +
>> +    private ArtifactResolver delegate;
>> +
>> +    private BuildContextManager buildContextManager;
>> +
>> +    public void resolve( Artifact artifact, List  
>> remoteRepositories, ArtifactRepository localRepository )
>> +        throws ArtifactResolutionException,  
>> ArtifactNotFoundException
>> +    {
>> +        resolveFromCache( artifact );
>> +
>> +        if ( !artifact.isResolved() )
>> +        {
>> +            delegate.resolve( artifact, remoteRepositories,  
>> localRepository );
>> +        }
>> +    }
>> +
>> +    public void resolveAlways( Artifact artifact, List  
>> remoteRepositories, ArtifactRepository localRepository )
>> +        throws ArtifactResolutionException,  
>> ArtifactNotFoundException
>> +    {
>> +        resolveFromCache( artifact );
>> +
>> +        if ( !artifact.isResolved() )
>> +        {
>> +            delegate.resolveAlways( artifact, remoteRepositories,  
>> localRepository );
>> +        }
>> +    }
>> +
>> +    private void resolveFromCache( Artifact artifact )
>> +    {
>> +        ProjectBuildCache cache = ProjectBuildCache.read 
>> ( buildContextManager );
>> +
>> +        if ( "pom".equals( artifact.getType() ) )
>> +        {
>> +            File pomFile = cache.getCachedModelFile( artifact );
>> +
>> +            if ( pomFile != null )
>> +            {
>> +                artifact.setFile( pomFile );
>> +                artifact.setResolved( true );
>> +            }
>> +        }
>> +        // currently, artifacts with classifiers are not really  
>> supported as the main project artifact...
>> +        else if ( artifact.getClassifier() == null )
>> +        {
>> +            MavenProject project = cache.getCachedProject 
>> ( artifact );
>> +            ArtifactHandler handler = artifact.getArtifactHandler();
>> +
>> +            if ( project != null && handler.getPackaging().equals 
>> ( project.getPackaging() ) )
>> +            {
>> +                File projectArtifactFile = project.getArtifact 
>> ().getFile();
>> +
>> +                if ( projectArtifactFile != null )
>> +                {
>> +                    artifact.setFile( projectArtifactFile );
>> +                    artifact.setResolved( true );
>> +                }
>> +            }
>> +        }
>> +    }
>> +
>> +}
>>
>> Propchange: maven/components/trunk/maven-project/src/main/java/org/ 
>> apache/maven/project/artifact/CacheAwareArtifactResolver.java
>> --------------------------------------------------------------------- 
>> ---------
>>     svn:eol-style = native
>>
>> Propchange: maven/components/trunk/maven-project/src/main/java/org/ 
>> apache/maven/project/artifact/CacheAwareArtifactResolver.java
>> --------------------------------------------------------------------- 
>> ---------
>>     svn:keywords = "Author Date Id Revision"
>>
>> Modified: maven/components/trunk/maven-project/src/main/java/org/ 
>> apache/maven/project/artifact/MavenMetadataSource.java
>> URL: http://svn.apache.org/viewvc/maven/components/trunk/maven- 
>> project/src/main/java/org/apache/maven/project/artifact/ 
>> MavenMetadataSource.java?view=diff&rev=509692&r1=509691&r2=509692
>> ===================================================================== 
>> =========
>> --- maven/components/trunk/maven-project/src/main/java/org/apache/ 
>> maven/project/artifact/MavenMetadataSource.java (original)
>> +++ maven/components/trunk/maven-project/src/main/java/org/apache/ 
>> maven/project/artifact/MavenMetadataSource.java Tue Feb 20  
>> 10:09:53 2007
>> @@ -33,6 +33,7 @@
>>  import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
>>  import  
>> org.apache.maven.artifact.versioning.InvalidVersionSpecificationExcep 
>> tion;
>>  import org.apache.maven.artifact.versioning.VersionRange;
>> +import org.apache.maven.context.BuildContextManager;
>>  import org.apache.maven.model.Dependency;
>>  import org.apache.maven.model.DistributionManagement;
>>  import org.apache.maven.model.Exclusion;
>> @@ -41,6 +42,7 @@
>>  import org.apache.maven.project.MavenProject;
>>  import org.apache.maven.project.MavenProjectBuilder;
>>  import org.apache.maven.project.ProjectBuildingException;
>> +import org.apache.maven.project.build.ProjectBuildCache;
>>  import org.apache.maven.project.validation.ModelValidationResult;
>>  import org.codehaus.plexus.logging.AbstractLogEnabled;
>>  import org.codehaus.plexus.util.StringUtils;
>> @@ -69,6 +71,8 @@
>>      private ArtifactFactory artifactFactory;
>>
>>      private RepositoryMetadataManager repositoryMetadataManager;
>> +
>> +    private BuildContextManager buildContextManager;
>>
>>      // lazily instantiated and cached.
>>      private MavenProject superProject;
>> @@ -81,6 +85,8 @@
>>      public ResolutionGroup retrieve( Artifact artifact,  
>> ArtifactRepository localRepository, List remoteRepositories )
>>          throws ArtifactMetadataRetrievalException
>>      {
>> +        ProjectBuildCache cache = ProjectBuildCache.read 
>> ( buildContextManager );
>> +
>>          MavenProject project = null;
>>
>>          Artifact pomArtifact;
>> @@ -97,40 +103,46 @@
>>              }
>>              else
>>              {
>> -                try
>> +                project = cache.getCachedProject( artifact );
>> +
>> +                if ( project == null )
>>                  {
>> -                    project =  
>> mavenProjectBuilder.buildFromRepository( pomArtifact,  
>> remoteRepositories, localRepository,
>> -                                                                     
>>    true );
>> -                }
>> -                catch ( InvalidProjectModelException e )
>> -                {
>> -                    getLogger().warn( "POM for \'" + pomArtifact +
>> -                        "\' is invalid. It will be ignored for  
>> artifact resolution. Reason: " + e.getMessage() );
>> -
>> -                    if ( getLogger().isDebugEnabled() )
>> +                    try
>>                      {
>> -                        getLogger().debug( "Reason: " +  
>> e.getMessage() );
>> -
>> -                        ModelValidationResult validationResult =  
>> e.getValidationResult();
>> +                        project =  
>> mavenProjectBuilder.buildFromRepository( pomArtifact,  
>> remoteRepositories, localRepository,
>> +                                                                     
>>        true );
>> +                    }
>> +                    catch ( InvalidProjectModelException e )
>> +                    {
>> +                        getLogger().warn( "POM for \'" +  
>> pomArtifact +
>> +                            "\' is invalid. It will be ignored  
>> for artifact resolution. Reason: " + e.getMessage() );
>>
>> -                        if ( validationResult != null )
>> +                        if ( getLogger().isDebugEnabled() )
>>                          {
>> -                            getLogger().debug( "\nValidation  
>> Errors:" );
>> -                            for ( Iterator i =  
>> validationResult.getMessages().iterator(); i.hasNext(); )
>> +                            getLogger().debug( "Reason: " +  
>> e.getMessage() );
>> +
>> +                            ModelValidationResult  
>> validationResult = e.getValidationResult();
>> +
>> +                            if ( validationResult != null )
>>                              {
>> -                                getLogger().debug( i.next 
>> ().toString() );
>> +                                getLogger().debug( "\nValidation  
>> Errors:" );
>> +                                for ( Iterator i =  
>> validationResult.getMessages().iterator(); i.hasNext(); )
>> +                                {
>> +                                    getLogger().debug( i.next 
>> ().toString() );
>> +                                }
>> +                                getLogger().debug( "\n" );
>>                              }
>> -                            getLogger().debug( "\n" );
>>                          }
>> -                    }
>>
>> -                    project = null;
>> -                }
>> -                catch ( ProjectBuildingException e )
>> -                {
>> -                    throw new ArtifactMetadataRetrievalException 
>> ( "Unable to read the metadata file for artifact '" +
>> -                        artifact.getDependencyConflictId() + "':  
>> " + e.getMessage(), e );
>> +                        project = null;
>> +                    }
>> +                    catch ( ProjectBuildingException e )
>> +                    {
>> +                        throw new  
>> ArtifactMetadataRetrievalException( "Unable to read the metadata  
>> file for artifact '" +
>> +                            artifact.getDependencyConflictId() +  
>> "': " + e.getMessage(), e );
>> +                    }
>>                  }
>> +
>>
>>                  if ( project != null )
>>                  {
>> @@ -176,13 +188,13 @@
>>
>>                          if ( artifact.getDependencyTrail() !=  
>> null && artifact.getDependencyTrail().size() == 1 )
>>                          {
>> -                            getLogger().warn( "While downloading  
>> " + pomArtifact.getGroupId() + ":" +
>> -                                pomArtifact.getArtifactId() + ":"  
>> + pomArtifact.getVersion() + message + "\n" );
>> +                            getLogger().warn( "While downloading  
>> " + artifact.getGroupId() + ":" +
>> +                                artifact.getArtifactId() + ":" +  
>> artifact.getVersion() + message + "\n" );
>>                          }
>>                          else
>>                          {
>> -                            getLogger().debug( "While downloading  
>> " + pomArtifact.getGroupId() + ":" +
>> -                                pomArtifact.getArtifactId() + ":"  
>> + pomArtifact.getVersion() + message + "\n" );
>> +                            getLogger().debug( "While downloading  
>> " + artifact.getGroupId() + ":" +
>> +                                artifact.getArtifactId() + ":" +  
>> artifact.getVersion() + message + "\n" );
>>                          }
>>                      }
>>                      else
>>
>> Added: maven/components/trunk/maven-project/src/main/java/org/ 
>> apache/maven/project/build/ProjectBuildCache.java
>> URL: http://svn.apache.org/viewvc/maven/components/trunk/maven- 
>> project/src/main/java/org/apache/maven/project/build/ 
>> ProjectBuildCache.java?view=auto&rev=509692
>> ===================================================================== 
>> =========
>> --- maven/components/trunk/maven-project/src/main/java/org/apache/ 
>> maven/project/build/ProjectBuildCache.java (added)
>> +++ maven/components/trunk/maven-project/src/main/java/org/apache/ 
>> maven/project/build/ProjectBuildCache.java Tue Feb 20 10:09:53 2007
>> @@ -0,0 +1,181 @@
>> +package org.apache.maven.project.build;
>> +
>> +import org.apache.maven.artifact.Artifact;
>> +import org.apache.maven.context.BuildContext;
>> +import org.apache.maven.context.BuildContextManager;
>> +import org.apache.maven.context.ManagedBuildData;
>> +import org.apache.maven.model.Model;
>> +import org.apache.maven.model.Parent;
>> +import org.apache.maven.project.MavenProject;
>> +
>> +import java.io.File;
>> +import java.util.HashMap;
>> +import java.util.Map;
>> +
>> +/**
>> + * This cache is meant to provide a reference of the project  
>> instances that are in the current build
>> + * in order to avoid storing a hidden caching mechanism in the  
>> project builder, and avoid the need
>> + * to store inter-project references as such in MavenProject  
>> instances. An ArtifactResolver instance
>> + * will be used that can utilize this cache, but will also wrap  
>> the "default" ArtifactResolver
>> + * instance, so that can be used as a target for replacement  
>> implementations.
>> + *
>> + * To retrieve from the build context: buildContext.retrieve( new  
>> ProjectBuildCache( false ) );
>> + *
>> + * @author jdcasey
>> + */
>> +public class ProjectBuildCache
>> +    implements ManagedBuildData
>> +{
>> +
>> +    private static final String BUILD_CONTEXT_KEY =  
>> ProjectBuildCache.class.getName();
>> +
>> +    private static final String PROJECT_CACHE = "project-cache";
>> +
>> +    private static final String POM_FILE_CACHE = "pom-file-cache";
>> +
>> +    private Map projectCache;
>> +
>> +    private Map pomFileCache;
>> +
>> +    public ProjectBuildCache()
>> +    {
>> +        this( true );
>> +    }
>> +
>> +    /**
>> +     * @param liveInstance If false, this instance's state is  
>> meant to be retrieved from the build
>> +     *   context. If true, this instance can serve as the  
>> authoritative instance where the cache is
>> +     *   established.
>> +     */
>> +    public ProjectBuildCache( boolean liveInstance )
>> +    {
>> +        if ( liveInstance )
>> +        {
>> +            projectCache = new HashMap();
>> +            pomFileCache = new HashMap();
>> +        }
>> +    }
>> +
>> +    public void cacheProject( MavenProject project )
>> +    {
>> +        projectCache.put( generateCacheKey( project ), project );
>> +    }
>> +
>> +    public MavenProject getCachedProject( String groupId, String  
>> artifactId, String version )
>> +    {
>> +        return (MavenProject) projectCache.get( generateCacheKey 
>> ( groupId, artifactId, version ) );
>> +    }
>> +
>> +    public MavenProject getCachedProject( Artifact artifact )
>> +    {
>> +        return (MavenProject) projectCache.get( generateCacheKey 
>> ( artifact ) );
>> +    }
>> +
>> +    public MavenProject getCachedProject( MavenProject  
>> exampleInstance )
>> +    {
>> +        return (MavenProject) projectCache.get( generateCacheKey 
>> ( exampleInstance ) );
>> +    }
>> +
>> +    public void cacheModelFileForModel( File modelFile, Model  
>> model )
>> +    {
>> +        pomFileCache.put( generateCacheKey( model ), modelFile );
>> +    }
>> +
>> +    public File getCachedModelFile( Artifact artifact )
>> +    {
>> +        return (File) pomFileCache.get( generateCacheKey 
>> ( artifact ) );
>> +    }
>> +
>> +    public File getCachedModelFile( Parent parent )
>> +    {
>> +        return (File) pomFileCache.get( generateCacheKey 
>> ( parent ) );
>> +    }
>> +
>> +    public File getCachedModelFile( String groupId, String  
>> artifactId, String version )
>> +    {
>> +        return (File) pomFileCache.get( generateCacheKey 
>> ( groupId, artifactId, version ) );
>> +    }
>> +
>> +    public Map getData()
>> +    {
>> +        Map data = new HashMap( 2 );
>> +
>> +        data.put( PROJECT_CACHE, projectCache );
>> +        data.put( POM_FILE_CACHE, pomFileCache );
>> +
>> +        return data;
>> +    }
>> +
>> +    public String getStorageKey()
>> +    {
>> +        return BUILD_CONTEXT_KEY;
>> +    }
>> +
>> +    public void setData( Map data )
>> +    {
>> +        this.projectCache = (Map) data.get( PROJECT_CACHE );
>> +        this.pomFileCache = (Map) data.get( POM_FILE_CACHE );
>> +    }
>> +
>> +    public void store( BuildContextManager buildContextManager )
>> +    {
>> +        BuildContext buildContext =  
>> buildContextManager.readBuildContext( true );
>> +        buildContext.store( this );
>> +        buildContextManager.storeBuildContext( buildContext );
>> +    }
>> +
>> +    public static ProjectBuildCache read( BuildContextManager  
>> buildContextManager )
>> +    {
>> +        BuildContext buildContext =  
>> buildContextManager.readBuildContext( true );
>> +
>> +        ProjectBuildCache cache = new ProjectBuildCache();
>> +
>> +        buildContext.retrieve( cache );
>> +
>> +        return cache;
>> +    }
>> +
>> +    private static String generateCacheKey( Model model )
>> +    {
>> +        Parent modelParent = model.getParent();
>> +
>> +        String groupId = model.getGroupId();
>> +
>> +        if ( groupId == null && modelParent != null )
>> +        {
>> +            groupId = modelParent.getGroupId();
>> +        }
>> +
>> +        String artifactId = model.getArtifactId();
>> +
>> +        String version = model.getVersion();
>> +
>> +        if ( version == null && modelParent != null )
>> +        {
>> +            version = modelParent.getVersion();
>> +        }
>> +
>> +        return generateCacheKey( groupId, artifactId, version );
>> +    }
>> +
>> +    private static String generateCacheKey( Parent parent )
>> +    {
>> +        return generateCacheKey( parent.getGroupId(),  
>> parent.getArtifactId(), parent.getVersion() );
>> +    }
>> +
>> +    private static String generateCacheKey( Artifact artifact )
>> +    {
>> +        return generateCacheKey( artifact.getGroupId(),  
>> artifact.getArtifactId(), artifact.getVersion() );
>> +    }
>> +
>> +    private static String generateCacheKey( MavenProject project )
>> +    {
>> +        return generateCacheKey( project.getGroupId(),  
>> project.getArtifactId(), project.getVersion() );
>> +    }
>> +
>> +    private static String generateCacheKey( String groupId,  
>> String artifactId, String version )
>> +    {
>> +        return groupId + ":" + artifactId + ":" + version;
>> +    }
>> +
>> +}
>>
>> Propchange: maven/components/trunk/maven-project/src/main/java/org/ 
>> apache/maven/project/build/ProjectBuildCache.java
>> --------------------------------------------------------------------- 
>> ---------
>>     svn:eol-style = native
>>
>> Propchange: maven/components/trunk/maven-project/src/main/java/org/ 
>> apache/maven/project/build/ProjectBuildCache.java
>> --------------------------------------------------------------------- 
>> ---------
>>     svn:keywords = "Author Date Id Revision"
>>
>> Modified: maven/components/trunk/maven-project/src/main/java/org/ 
>> apache/maven/project/build/ProjectBuildContext.java
>> URL: http://svn.apache.org/viewvc/maven/components/trunk/maven- 
>> project/src/main/java/org/apache/maven/project/build/ 
>> ProjectBuildContext.java?view=diff&rev=509692&r1=509691&r2=509692
>> ===================================================================== 
>> =========
>> --- maven/components/trunk/maven-project/src/main/java/org/apache/ 
>> maven/project/build/ProjectBuildContext.java (original)
>> +++ maven/components/trunk/maven-project/src/main/java/org/apache/ 
>> maven/project/build/ProjectBuildContext.java Tue Feb 20 10:09:53 2007
>> @@ -6,6 +6,9 @@
>>  import org.apache.maven.project.MavenProject;
>>  import org.apache.maven.project.build.model.ModelLineage;
>>
>> +import java.util.HashMap;
>> +import java.util.Map;
>> +
>>  /*
>>   * Copyright 2001-2005 The Apache Software Foundation.
>>   *
>> @@ -34,6 +37,10 @@
>>  {
>>
>>      public static final String BUILD_CONTEXT_KEY =  
>> ProjectBuildContext.class.getName();
>> +
>> +    private static final String MODEL_LINEAGE = "model-lineage";
>> +
>> +    private static final String CURRENT_PROJECT = "current-project";
>>
>>      private ModelLineage modelLineage;
>>
>> @@ -72,16 +79,14 @@
>>      {
>>          BuildContext buildContext =  
>> buildContextManager.readBuildContext( false );
>>
>> -        ProjectBuildContext projectContext = null;
>> +        ProjectBuildContext projectContext = new  
>> ProjectBuildContext();
>>
>>          if ( buildContext != null )
>>          {
>> -            projectContext = (ProjectBuildContext)  
>> buildContext.get( BUILD_CONTEXT_KEY );
>> -        }
>> -
>> -        if ( create && projectContext == null )
>> -        {
>> -            projectContext = new ProjectBuildContext();
>> +            if ( !buildContext.retrieve( projectContext ) && ! 
>> create )
>> +            {
>> +                return null;
>> +            }
>>          }
>>
>>          return projectContext;
>> @@ -91,8 +96,24 @@
>>      {
>>          BuildContext buildContext =  
>> buildContextManager.readBuildContext( true );
>>
>> -        buildContext.put( this );
>> +        buildContext.store( this );
>>
>>          buildContextManager.storeBuildContext( buildContext );
>> +    }
>> +
>> +    public Map getData()
>> +    {
>> +        Map data = new HashMap( 2 );
>> +
>> +        data.put( MODEL_LINEAGE, modelLineage );
>> +        data.put( CURRENT_PROJECT, currentProject );
>> +
>> +        return data;
>> +    }
>> +
>> +    public void setData( Map data )
>> +    {
>> +        this.modelLineage = (ModelLineage) data.get 
>> ( MODEL_LINEAGE );
>> +        this.currentProject = (MavenProject) data.get 
>> ( CURRENT_PROJECT );
>>      }
>>  }
>>
>> Modified: maven/components/trunk/maven-project/src/main/java/org/ 
>> apache/maven/project/build/model/DefaultModelLineageBuilder.java
>> URL: http://svn.apache.org/viewvc/maven/components/trunk/maven- 
>> project/src/main/java/org/apache/maven/project/build/model/ 
>> DefaultModelLineageBuilder.java? 
>> view=diff&rev=509692&r1=509691&r2=509692
>> ===================================================================== 
>> =========
>> --- maven/components/trunk/maven-project/src/main/java/org/apache/ 
>> maven/project/build/model/DefaultModelLineageBuilder.java (original)
>> +++ maven/components/trunk/maven-project/src/main/java/org/apache/ 
>> maven/project/build/model/DefaultModelLineageBuilder.java Tue Feb  
>> 20 10:09:53 2007
>> @@ -8,11 +8,13 @@
>>  import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
>>  import  
>> org.apache.maven.artifact.resolver.ArtifactResolutionException;
>>  import org.apache.maven.artifact.resolver.ArtifactResolver;
>> +import org.apache.maven.context.BuildContextManager;
>>  import org.apache.maven.model.Model;
>>  import org.apache.maven.model.Parent;
>>  import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
>>  import org.apache.maven.profiles.ProfileManager;
>>  import org.apache.maven.project.ProjectBuildingException;
>> +import org.apache.maven.project.build.ProjectBuildCache;
>>  import org.apache.maven.project.build.profile.ProfileAdvisor;
>>  import org.codehaus.plexus.logging.LogEnabled;
>>  import org.codehaus.plexus.logging.Logger;
>> @@ -28,7 +30,6 @@
>>  import java.util.Collections;
>>  import java.util.LinkedHashSet;
>>  import java.util.List;
>> -import java.util.Map;
>>  import java.util.Set;
>>
>>  /**
>> @@ -47,6 +48,8 @@
>>      private MavenTools mavenTools;
>>
>>      private ProfileAdvisor profileAdvisor;
>> +
>> +    private BuildContextManager buildContextManager;
>>
>>      private Logger logger;
>>
>> @@ -54,19 +57,22 @@
>>      {
>>      }
>>
>> -    public DefaultModelLineageBuilder( ArtifactResolver resolver,  
>> ArtifactFactory artifactFactory )
>> +    public DefaultModelLineageBuilder( ArtifactResolver resolver,  
>> ArtifactFactory artifactFactory, BuildContextManager  
>> buildContextManager )
>>      {
>>          this.artifactResolver = resolver;
>>          this.artifactFactory = artifactFactory;
>> +        this.buildContextManager = buildContextManager;
>>      }
>>
>>      /**
>>       * @see  
>> org.apache.maven.project.build.model.ModelLineageBuilder#buildModelLi 
>> neage(java.io.File,  
>> org.apache.maven.artifact.repository.ArtifactRepository,  
>> java.util.List)
>>       */
>>      public ModelLineage buildModelLineage( File pom,  
>> ArtifactRepository localRepository, List remoteRepositories,
>> -                                           ProfileManager  
>> profileManager, Map cachedPomFilesByModelId )
>> +                                           ProfileManager  
>> profileManager )
>>          throws ProjectBuildingException
>>      {
>> +        ProjectBuildCache projectBuildCache =  
>> ProjectBuildCache.read( buildContextManager );
>> +
>>          ModelLineage lineage = new DefaultModelLineage();
>>
>>          File pomFile = pom;
>> @@ -75,7 +81,7 @@
>>
>>          while ( pomFile != null )
>>          {
>> -            Model model = readModel( pomFile,  
>> cachedPomFilesByModelId );
>> +            Model model = readModel( pomFile, projectBuildCache );
>>
>>              if ( lineage.size() == 0 )
>>              {
>> @@ -89,16 +95,18 @@
>>              currentRemoteRepositories = updateRepositorySet 
>> ( model, currentRemoteRepositories, pomFile, profileManager );
>>
>>              pomFile = resolveParentPom( model,  
>> currentRemoteRepositories, localRepository, pomFile,
>> -                                        cachedPomFilesByModelId );
>> +                                        projectBuildCache );
>>          }
>>
>>          return lineage;
>>      }
>>
>>      public void resumeBuildingModelLineage( ModelLineage lineage,  
>> ArtifactRepository localRepository,
>> -                                            ProfileManager  
>> profileManager, Map cachedPomFilesByModelId )
>> +                                            ProfileManager  
>> profileManager )
>>          throws ProjectBuildingException
>>      {
>> +        ProjectBuildCache projectBuildCache =  
>> ProjectBuildCache.read( buildContextManager );
>> +
>>          File pomFile = lineage.getDeepestFile();
>>          List currentRemoteRepositories =  
>> lineage.getDeepestArtifactRepositoryList();
>>
>> @@ -110,11 +118,11 @@
>>          Model model = lineage.getDeepestModel();
>>
>>          // use the above information to re-bootstrap the  
>> resolution chain...
>> -        pomFile = resolveParentPom( model,  
>> currentRemoteRepositories, localRepository, pomFile,  
>> cachedPomFilesByModelId );
>> +        pomFile = resolveParentPom( model,  
>> currentRemoteRepositories, localRepository, pomFile,  
>> projectBuildCache );
>>
>>          while ( pomFile != null )
>>          {
>> -            model = readModel( pomFile, cachedPomFilesByModelId );
>> +            model = readModel( pomFile, projectBuildCache );
>>
>>              if ( lineage.size() == 0 )
>>              {
>> @@ -128,7 +136,7 @@
>>              currentRemoteRepositories = updateRepositorySet 
>> ( model, currentRemoteRepositories, pomFile, profileManager );
>>
>>              pomFile = resolveParentPom( model,  
>> currentRemoteRepositories, localRepository, pomFile,
>> -                                        cachedPomFilesByModelId );
>> +                                        projectBuildCache );
>>          }
>>      }
>>
>> @@ -146,10 +154,10 @@
>>       * Read the Model instance from the given POM file, and cache  
>> it in the given Map before
>>       * returning it.
>>       */
>> -    private Model readModel( File pomFile, Map  
>> cachedPomFilesByModelId )
>> +    private Model readModel( File pomFile, ProjectBuildCache  
>> projectBuildCache )
>>          throws ProjectBuildingException
>>      {
>> -        return readModel( pomFile, cachedPomFilesByModelId, false );
>> +        return readModel( pomFile, projectBuildCache, false );
>>      }
>>
>>      /**
>> @@ -157,7 +165,7 @@
>>       * Model instance in the given Map before returning it. The  
>> skipCache flag controls whether the
>>       * Model instance is actually cached.
>>       */
>> -    private Model readModel( File pom, Map  
>> cachedPomFilesByModelId, boolean skipCache )
>> +    private Model readModel( File pom, ProjectBuildCache  
>> projectBuildCache, boolean skipCache )
>>          throws ProjectBuildingException
>>      {
>>          File pomFile = pom;
>> @@ -190,7 +198,8 @@
>>
>>          if ( !skipCache )
>>          {
>> -            cachedPomFilesByModelId.put( createCacheKey( model,  
>> pomFile ), pomFile );
>> +            projectBuildCache.cacheModelFileForModel( pomFile,  
>> model );
>> +            projectBuildCache.store( buildContextManager );
>>          }
>>
>>          return model;
>> @@ -265,10 +274,10 @@
>>      /**
>>       * Pull the parent specification out of the given model,  
>> construct an Artifact instance, and
>>       * resolve that artifact...then, return the resolved POM file  
>> for the parent.
>> -     * @param cachedModelsById
>> +     * @param projectBuildCache
>>       */
>>      private File resolveParentPom( Model model, List  
>> remoteRepositories, ArtifactRepository localRepository,
>> -                                   File modelPomFile, Map  
>> cachedModelsById )
>> +                                   File modelPomFile,  
>> ProjectBuildCache projectBuildCache )
>>          throws ProjectBuildingException
>>      {
>>          Parent modelParent = model.getParent();
>> @@ -279,11 +288,9 @@
>>          {
>>              validateParentDeclaration( modelParent, model );
>>
>> -            String cacheKey = createCacheKey( modelParent );
>> -
>>  //            getLogger().debug( "Looking for cached parent POM  
>> under: " + cacheKey );
>>
>> -            pomFile = (File) cachedModelsById.get( cacheKey );
>> +            pomFile = (File) projectBuildCache.getCachedModelFile 
>> ( modelParent );
>>
>>              if ( pomFile == null )
>>              {
>> @@ -297,42 +304,6 @@
>>          }
>>
>>          return pomFile;
>> -    }
>> -
>> -    private String createCacheKey( Parent modelParent )
>> -    {
>> -        return modelParent.getGroupId() + ":" +  
>> modelParent.getArtifactId() + ":" + modelParent.getVersion();
>> -    }
>> -
>> -    private String createCacheKey( Model model, File pomFile )
>> -        throws ProjectBuildingException
>> -    {
>> -        Parent modelParent = model.getParent();
>> -
>> -        String groupId = model.getGroupId();
>> -
>> -        if ( groupId == null && modelParent != null )
>> -        {
>> -            groupId = modelParent.getGroupId();
>> -        }
>> -
>> -        String artifactId = model.getArtifactId();
>> -
>> -        String version = model.getVersion();
>> -
>> -        if ( version == null && modelParent != null )
>> -        {
>> -            version = modelParent.getVersion();
>> -        }
>> -
>> -        if ( groupId == null || version == null )
>> -        {
>> -            throw new ProjectBuildingException( model.getId(),
>> -                                                "Invalid model.  
>> Must either specify groupId and version directly, or specify a  
>> parent groupId and version.\nIn POM: "
>> -                                                    + pomFile );
>> -        }
>> -
>> -        return groupId + ":" + artifactId + ":" + version;
>>      }
>>
>>      private void validateParentDeclaration( Parent modelParent,  
>> Model model )
>>
>> Modified: maven/components/trunk/maven-project/src/main/java/org/ 
>> apache/maven/project/build/model/ModelLineageBuilder.java
>> URL: http://svn.apache.org/viewvc/maven/components/trunk/maven- 
>> project/src/main/java/org/apache/maven/project/build/model/ 
>> ModelLineageBuilder.java?view=diff&rev=509692&r1=509691&r2=509692
>> ===================================================================== 
>> =========
>> --- maven/components/trunk/maven-project/src/main/java/org/apache/ 
>> maven/project/build/model/ModelLineageBuilder.java (original)
>> +++ maven/components/trunk/maven-project/src/main/java/org/apache/ 
>> maven/project/build/model/ModelLineageBuilder.java Tue Feb 20  
>> 10:09:53 2007
>> @@ -6,7 +6,6 @@
>>
>>  import java.io.File;
>>  import java.util.List;
>> -import java.util.Map;
>>
>>  /**
>>   * Builds the lineage of Model instances, starting from a given  
>> POM file, and stretching back through
>> @@ -32,12 +31,9 @@
>>       *   should be resolved
>>       * @param profileManager The profile manager containing  
>> information about global profiles to be
>>       *   applied (from settings.xml, for instance)
>> -     * @param cachedPomFilesByModelId A "global" cache of Model  
>> source files, partially for
>> -     *   optimization, and partially for loading Models that are  
>> unavailable in the repository and
>> -     *   have an incorrect relativePath
>>       */
>>      ModelLineage buildModelLineage( File pom, ArtifactRepository  
>> localRepository, List remoteRepositories,
>> -                                    ProfileManager  
>> profileManager, Map cachedPomFilesByModelId )
>> +                                    ProfileManager profileManager )
>>          throws ProjectBuildingException;
>>
>>      /**
>> @@ -48,12 +44,9 @@
>>       * @param localRepository The local repository against which  
>> parent POMs should be resolved
>>       * @param profileManager The profile manager containing  
>> information about global profiles to be
>>       *   applied (from settings.xml, for instance)
>> -     * @param cachedPomFilesByModelId A "global" cache of Model  
>> source files, partially for
>> -     *   optimization, and partially for loading Models that are  
>> unavailable in the repository and
>> -     *   have an incorrect relativePath
>>       */
>>      void resumeBuildingModelLineage( ModelLineage lineage,  
>> ArtifactRepository localRepository,
>> -                                     ProfileManager  
>> profileManager, Map cachedPomFilesByModelId )
>> +                                     ProfileManager profileManager )
>>          throws ProjectBuildingException;
>>
>>  }
>>
>> Modified: maven/components/trunk/maven-project/src/main/resources/ 
>> META-INF/plexus/components.xml
>> URL: http://svn.apache.org/viewvc/maven/components/trunk/maven- 
>> project/src/main/resources/META-INF/plexus/components.xml? 
>> view=diff&rev=509692&r1=509691&r2=509692
>> ===================================================================== 
>> =========
>> --- maven/components/trunk/maven-project/src/main/resources/META- 
>> INF/plexus/components.xml (original)
>> +++ maven/components/trunk/maven-project/src/main/resources/META- 
>> INF/plexus/components.xml Tue Feb 20 10:09:53 2007
>> @@ -1,5 +1,38 @@
>>  <component-set>
>>    <components>
>> +    <!--
>> +     |
>> +     | Resolver
>> +     |
>> +     -->
>> +    <component>
>> +      <role>org.apache.maven.artifact.resolver.ArtifactResolver</ 
>> role>
>> +       
>> <implementation>org.apache.maven.project.artifact.CacheAwareArtifactR 
>> esolver</implementation>
>> +      <role-hint>project-cache-aware</role-hint>
>> +      <requirements>
>> +        <requirement>
>> +           
>> <role>org.apache.maven.artifact.manager.ArtifactManager</role>
>> +        </requirement>
>> +        <requirement>
>> +           
>> <role>org.apache.maven.artifact.transform.ArtifactTransformationManag 
>> er</role>
>> +        </requirement>
>> +        <requirement>
>> +           
>> <role>org.apache.maven.artifact.factory.ArtifactFactory</role>
>> +        </requirement>
>> +        <requirement>
>> +           
>> <role>org.apache.maven.artifact.resolver.ArtifactCollector</role>
>> +        </requirement>
>> +        <requirement>
>> +           
>> <role>org.apache.maven.artifact.resolver.ArtifactResolver</role>
>> +          <role-hint>default</role-hint>
>> +        </requirement>
>> +        <requirement>
>> +          <role>org.apache.maven.context.BuildContextManager</role>
>> +          <role-hint>default</role-hint>
>> +        </requirement>
>> +      </requirements>
>> +    </component>
>> +
>>      <component>
>>         
>> <role>org.apache.maven.project.build.profile.ProfileAdvisor</role>
>>        <role-hint>default</role-hint>
>> @@ -37,6 +70,11 @@
>>          </requirement>
>>          <requirement>
>>             
>> <role>org.apache.maven.artifact.resolver.ArtifactResolver</role>
>> +          <role-hint>project-cache-aware</role-hint>
>> +        </requirement>
>> +        <requirement>
>> +          <role>org.apache.maven.context.BuildContextManager</role>
>> +          <role-hint>default</role-hint>
>>          </requirement>
>>        </requirements>
>>      </component>
>> @@ -264,6 +302,10 @@
>>          </requirement>
>>          <requirement>
>>             
>> <role>org.apache.maven.artifact.repository.metadata.RepositoryMetadat 
>> aManager</role>
>> +        </requirement>
>> +        <requirement>
>> +          <role>org.apache.maven.context.BuildContextManager</role>
>> +          <role-hint>default</role-hint>
>>          </requirement>
>>        </requirements>
>>      </component>
>>
>> Modified: maven/components/trunk/maven-project/src/test/java/org/ 
>> apache/maven/project/build/model/DefaultModelLineageBuilderTest.java
>> URL: http://svn.apache.org/viewvc/maven/components/trunk/maven- 
>> project/src/test/java/org/apache/maven/project/build/model/ 
>> DefaultModelLineageBuilderTest.java? 
>> view=diff&rev=509692&r1=509691&r2=509692
>> ===================================================================== 
>> =========
>> --- maven/components/trunk/maven-project/src/test/java/org/apache/ 
>> maven/project/build/model/DefaultModelLineageBuilderTest.java  
>> (original)
>> +++ maven/components/trunk/maven-project/src/test/java/org/apache/ 
>> maven/project/build/model/DefaultModelLineageBuilderTest.java Tue  
>> Feb 20 10:09:53 2007
>> @@ -3,10 +3,12 @@
>>  import org.apache.maven.artifact.repository.ArtifactRepository;
>>  import  
>> org.apache.maven.artifact.repository.DefaultArtifactRepository;
>>  import  
>> org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
>> +import org.apache.maven.context.BuildContextManager;
>>  import org.apache.maven.model.Model;
>>  import org.apache.maven.model.Parent;
>>  import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
>>  import org.apache.maven.project.ProjectBuildingException;
>> +import org.apache.maven.project.build.ProjectBuildCache;
>>  import org.codehaus.plexus.PlexusTestCase;
>>  import org.codehaus.plexus.logging.Logger;
>>  import org.codehaus.plexus.util.FileUtils;
>> @@ -16,9 +18,7 @@
>>  import java.io.FileWriter;
>>  import java.io.IOException;
>>  import java.util.Collections;
>> -import java.util.HashMap;
>>  import java.util.Iterator;
>> -import java.util.Map;
>>
>>  public class DefaultModelLineageBuilderTest
>>      extends PlexusTestCase
>> @@ -68,7 +68,7 @@
>>              IOUtil.close( writer );
>>          }
>>
>> -        ModelLineage lineage =  
>> modelLineageBuilder.buildModelLineage( pomFile, null, null, null,  
>> new HashMap() );
>> +        ModelLineage lineage =  
>> modelLineageBuilder.buildModelLineage( pomFile, null, null, null );
>>
>>          assertEquals( 1, lineage.size() );
>>
>> @@ -126,7 +126,7 @@
>>              .toExternalForm(), defaultLayout );
>>
>>          ModelLineage lineage =  
>> modelLineageBuilder.buildModelLineage( currentPOM, localRepository,
>> -                                                                     
>>   Collections.EMPTY_LIST, null, new HashMap() );
>> +                                                                     
>>   Collections.EMPTY_LIST, null );
>>
>>          assertEquals( 3, lineage.size() );
>>
>> @@ -198,7 +198,7 @@
>>              .toExternalForm(), defaultLayout );
>>
>>          ModelLineage lineage =  
>> modelLineageBuilder.buildModelLineage( currentPOM,  
>> localRepository, Collections
>> -            .singletonList( remoteRepository ), null, new HashMap 
>> () );
>> +            .singletonList( remoteRepository ), null );
>>
>>          assertEquals( 3, lineage.size() );
>>
>> @@ -253,7 +253,7 @@
>>              .toExternalForm(), defaultLayout );
>>
>>          ModelLineage lineage =  
>> modelLineageBuilder.buildModelLineage( currentPOM, localRepository,
>> -                                                                     
>>   Collections.EMPTY_LIST, null, new HashMap() );
>> +                                                                     
>>   Collections.EMPTY_LIST, null );
>>
>>          assertEquals( 2, lineage.size() );
>>
>> @@ -303,7 +303,7 @@
>>      }
>>
>>      public void  
>> testReadPOMWithParentInOtherLocalFileWithBadRelativePath()
>> -        throws IOException, ProjectBuildingException
>> +        throws Exception
>>      {
>>          // 1. create the parent model in a "local" POM file.
>>          File parentPOM = File.createTempFile 
>> ( "DefaultModelLineageBuilder.test.", ".pom" );
>> @@ -314,8 +314,11 @@
>>          // 4. write the parent model to the local repo directory
>>          writeModel( parent, parentPOM );
>>
>> -        Map cache = new HashMap();
>> -        cache.put( "group:parent:1", parentPOM );
>> +        BuildContextManager buildContextManager =  
>> (BuildContextManager) lookup( BuildContextManager.ROLE, "default" );
>> +
>> +        ProjectBuildCache cache = ProjectBuildCache.read 
>> ( buildContextManager );
>> +        cache.cacheModelFileForModel( parentPOM, parent );
>> +        cache.store( buildContextManager );
>>
>>          // 5. create the current pom with a parent-ref on the  
>> parent model
>>          Model current = createModel( "group", "current", "1" );
>> @@ -336,13 +339,12 @@
>>
>>          // 7. build the lineage.
>>          ModelLineage lineage =  
>> modelLineageBuilder.buildModelLineage( currentPOM, null, Collections
>> -            .EMPTY_LIST, null, cache );
>> +            .EMPTY_LIST, null );
>>
>>          assertEquals( 2, lineage.size() );
>>
>>          Iterator modelIterator = lineage.modelIterator();
>>
>> -        assertEquals( 2, cache.size() );
>>          assertEquals( current.getId(), ( (Model)  
>> modelIterator.next() ).getId() );
>>          assertEquals( parent.getId(), ( (Model) modelIterator.next 
>> () ).getId() );
>>      }
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: svn commit: r509692 - in /maven/components/trunk: ./ maven-artifact-manager/src/main/resources/META-INF/plexus/ maven-build-context/src/main/java/org/apache/maven/context/ maven-build-context/src/test/java/org/apache/maven/context/ maven-core/src/main/...

Posted by Joakim Erdfelt <jo...@erdfelt.com>.
Any chance we can make this use plexus-cache?  for maven client, we can
use the simple HashMap based provider, but for larger apps (like
archiva) we can swap out the usage to a more robust cache provider
(oscache, ehcache, etc...)

- Joakim

jdcasey@apache.org wrote:
> Author: jdcasey
> Date: Tue Feb 20 10:09:53 2007
> New Revision: 509692
>
> URL: http://svn.apache.org/viewvc?view=rev&rev=509692
> Log:
> Rearranging project-builder caching so it's done externally and available for use in the model-lineage builder and during artifact resolution as well.
>
> Added:
>     maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/CacheAwareArtifactResolver.java   (with props)
>     maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/ProjectBuildCache.java   (with props)
> Modified:
>     maven/components/trunk/build.xml
>     maven/components/trunk/maven-artifact-manager/src/main/resources/META-INF/plexus/components.xml
>     maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/BuildContext.java
>     maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/DefaultBuildContext.java
>     maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/DefaultBuildContextManager.java
>     maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/ManagedBuildData.java
>     maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/SystemBuildContext.java
>     maven/components/trunk/maven-build-context/src/test/java/org/apache/maven/context/AbstractBuildContextManagerTest.java
>     maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
>     maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/ExecutionBuildContext.java
>     maven/components/trunk/maven-core/src/main/java/org/apache/maven/extension/BuildExtensionScanner.java
>     maven/components/trunk/maven-core/src/main/java/org/apache/maven/extension/DefaultBuildExtensionScanner.java
>     maven/components/trunk/maven-core/src/main/resources/META-INF/plexus/components.xml
>     maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/CustomActivatorAdvice.java
>     maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
>     maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
>     maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/ProjectBuildContext.java
>     maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/model/DefaultModelLineageBuilder.java
>     maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/model/ModelLineageBuilder.java
>     maven/components/trunk/maven-project/src/main/resources/META-INF/plexus/components.xml
>     maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/build/model/DefaultModelLineageBuilderTest.java
>
> Modified: maven/components/trunk/build.xml
> URL: http://svn.apache.org/viewvc/maven/components/trunk/build.xml?view=diff&rev=509692&r1=509691&r2=509692
> ==============================================================================
> --- maven/components/trunk/build.xml (original)
> +++ maven/components/trunk/build.xml Tue Feb 20 10:09:53 2007
> @@ -269,7 +269,9 @@
>        <classpath refid="maven.classpath"/>
>        <arg value="-e"/>
>        <arg value="-B"/>
> +<!--
>        <arg value="-X"/>
> + -->
>        <arg value="clean"/>
>        <arg value="install"/>
>      </java>
>
> Modified: maven/components/trunk/maven-artifact-manager/src/main/resources/META-INF/plexus/components.xml
> URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-artifact-manager/src/main/resources/META-INF/plexus/components.xml?view=diff&rev=509692&r1=509691&r2=509692
> ==============================================================================
> --- maven/components/trunk/maven-artifact-manager/src/main/resources/META-INF/plexus/components.xml (original)
> +++ maven/components/trunk/maven-artifact-manager/src/main/resources/META-INF/plexus/components.xml Tue Feb 20 10:09:53 2007
> @@ -109,6 +109,7 @@
>      <component>
>        <role>org.apache.maven.artifact.resolver.ArtifactResolver</role>
>        <implementation>org.apache.maven.artifact.resolver.DefaultArtifactResolver</implementation>
> +      <role-hint>default</role-hint>
>        <requirements>
>          <requirement>
>            <role>org.apache.maven.artifact.manager.ArtifactManager</role>
>
> Modified: maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/BuildContext.java
> URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/BuildContext.java?view=diff&rev=509692&r1=509691&r2=509692
> ==============================================================================
> --- maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/BuildContext.java (original)
> +++ maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/BuildContext.java Tue Feb 20 10:09:53 2007
> @@ -28,7 +28,24 @@
>      /**
>       * Add a new piece of managed build data to the build context. Managed data elements supply their
>       * own storage key.
> +     * 
> +     * @deprecated Use store(..) instead.
>       */
>      void put( ManagedBuildData managedData );
> +    
> +    /**
> +     * Add a new piece of managed build data to the build context. Managed data elements supply their
> +     * own storage key.
> +     */
> +    void store( ManagedBuildData managedData );
> +    
> +    /**
> +     * Retrieve the data map for a given type of managed build data, and use this to restore this
> +     * instance's state to that which was stored in the build context.
> +     * 
> +     * @param managedData The managed data instance to restore from the build context.
> +     * @return true if the data was retrieved from the build context, false otherwise
> +     */
> +    boolean retrieve( ManagedBuildData managedData );
>      
>  }
>
> Modified: maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/DefaultBuildContext.java
> URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/DefaultBuildContext.java?view=diff&rev=509692&r1=509691&r2=509692
> ==============================================================================
> --- maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/DefaultBuildContext.java (original)
> +++ maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/DefaultBuildContext.java Tue Feb 20 10:09:53 2007
> @@ -76,10 +76,41 @@
>      /**
>       * Add a new piece of managed data to the build context, using the key supplied by 
>       * managedData.getStorageKey().
> +     * 
> +     * @deprecated Use store(..) instead
>       */
>      public void put( ManagedBuildData managedData )
>      {
> -        contextMap.put( managedData.getStorageKey(), managedData );
> +        store( managedData );
> +    }
> +    
> +    /**
> +     * Add a new piece of managed data to the build context, using the key supplied by 
> +     * managedData.getStorageKey().
> +     */
> +    public void store( ManagedBuildData managedData )
> +    {
> +        contextMap.put( managedData.getStorageKey(), managedData.getData() );
> +    }
> +
> +    /**
> +     * Retrieve the data map for a given type of managed build data, and use this to restore this
> +     * instance's state to that which was stored in the build context.
> +     * 
> +     * @param managedData The managed data instance to restore from the build context.
> +     * @return true if the data was retrieved from the build context, false otherwise
> +     */
> +    public boolean retrieve( ManagedBuildData managedData )
> +    {
> +        Map dataMap = (Map) contextMap.get( managedData.getStorageKey() );
> +        
> +        if ( dataMap != null )
> +        {
> +            managedData.setData( dataMap );
> +            return true;
> +        }
> +        
> +        return false;
>      }
>  
>  }
>
> Modified: maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/DefaultBuildContextManager.java
> URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/DefaultBuildContextManager.java?view=diff&rev=509692&r1=509691&r2=509692
> ==============================================================================
> --- maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/DefaultBuildContextManager.java (original)
> +++ maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/DefaultBuildContextManager.java Tue Feb 20 10:09:53 2007
> @@ -1,8 +1,6 @@
>  package org.apache.maven.context;
>  
>  import org.codehaus.plexus.context.Context;
> -import org.codehaus.plexus.context.ContextException;
> -import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
>  
>  import java.util.HashMap;
>  import java.util.Map;
> @@ -14,22 +12,25 @@
>   * @author jdcasey
>   */
>  public class DefaultBuildContextManager
> -    implements BuildContextManager, Contextualizable
> +    implements BuildContextManager
>  {
>      public static final String ROLE_HINT = "default";
>      
>      protected static final String BUILD_CONTEXT_MAP_KEY = ROLE + ":" + ROLE_HINT + ":contextMap";
>      
> -    private Context context;
> +    private InheritableThreadLocal tl = new InheritableThreadLocal();
>      
>      public DefaultBuildContextManager()
>      {
>          // used for plexus initialization
>      }
>      
> +    /**
> +     * @deprecated Using ThreadLocal now, not container context, for thread safety.
> +     */
>      public DefaultBuildContextManager( Context context )
>      {
> -        this.context = context;
> +        // obsolete, does nothing...
>      }
>      
>      /**
> @@ -37,7 +38,7 @@
>       */
>      public void clearBuildContext()
>      {
> -        clearContextContainerMap();
> +        tl.set( null );
>      }
>  
>      /**
> @@ -49,7 +50,7 @@
>      {
>          Map contextMap = getContextContainerMap( create );
>          
> -        if ( !create && contextMap == null )
> +        if ( contextMap == null && !create )
>          {
>              return null;
>          }
> @@ -66,7 +67,7 @@
>      {
>          if ( context instanceof DefaultBuildContext )
>          {
> -            this.context.put( BUILD_CONTEXT_MAP_KEY, ((DefaultBuildContext)context).getContextMap() );
> +            tl.set( ((DefaultBuildContext)context).getContextMap() );
>          }
>          else
>          {
> @@ -76,25 +77,12 @@
>  
>      protected Map getContextContainerMap( boolean create )
>      {
> -        Map containerMap = null;
> +        Map containerMap = (Map) tl.get();
>  
> -        if ( context.contains( BUILD_CONTEXT_MAP_KEY ) )
> -        {
> -            try
> -            {
> -                containerMap = (Map) context.get( BUILD_CONTEXT_MAP_KEY );
> -            }
> -            catch ( ContextException e )
> -            {
> -                throw new IllegalStateException( "Failed to retrieve BuildAdvisor "
> -                                + "serialization map from context, though the context claims it exists. Error: "
> -                                + e.getMessage() );
> -            }
> -        }
> -        else if ( create )
> +        if ( containerMap == null && create )
>          {
>              containerMap = new HashMap();
> -            context.put( BUILD_CONTEXT_MAP_KEY, containerMap );
> +            tl.set( containerMap );
>          }
>  
>          return containerMap;
> @@ -111,20 +99,12 @@
>      }
>  
>      /**
> -     * Retrieve the container context for storing the BuildContext data.
> +     * @deprecated Using ThreadLocal now, not container context, for thread safety.
>       */
> -    public void contextualize( Context context )
> -        throws ContextException
> -    {
> -        this.context = context;
> -    }
> -
>      public Context reorientToContext( Context context )
>      {
> -        Context oldContext = this.context;
> -        this.context = context;
> -        
> -        return oldContext;
> +        // obsolete, does nothing...
> +        return context;
>      }
>  
>  }
>
> Modified: maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/ManagedBuildData.java
> URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/ManagedBuildData.java?view=diff&rev=509692&r1=509691&r2=509692
> ==============================================================================
> --- maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/ManagedBuildData.java (original)
> +++ maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/ManagedBuildData.java Tue Feb 20 10:09:53 2007
> @@ -1,5 +1,7 @@
>  package org.apache.maven.context;
>  
> +import java.util.Map;
> +
>  /**
>   * Management interface for things that are meant to be stored/retrieved from the Maven BuildContext
>   * natively. Such things need to give the BuildContextManager a key for mapping it into the context.
> @@ -17,5 +19,21 @@
>       * @return The BuildContext mapping key.
>       */
>      String getStorageKey();
> +
> +    /**
> +     * Provides a way for a complex object to serialize itself to primitives for storage in the
> +     * build context, so the same class loaded from different classloaders (as in the case of plugin
> +     * dependencies) don't incur a ClassCastException when trying to retrieve stored information.
> +     * 
> +     * @return The object's data in primitive (shared classes, like Strings) form, keyed for
> +     *   retrieval.
> +     */
> +    Map getData();
> +    
> +    /**
> +     * Restore the object's state from the primitives stored in the build context.
> +     * @param data The map of primitives that were stored in the build context
> +     */
> +    void setData( Map data );
>  
>  }
>
> Modified: maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/SystemBuildContext.java
> URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/SystemBuildContext.java?view=diff&rev=509692&r1=509691&r2=509692
> ==============================================================================
> --- maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/SystemBuildContext.java (original)
> +++ maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/SystemBuildContext.java Tue Feb 20 10:09:53 2007
> @@ -1,5 +1,7 @@
>  package org.apache.maven.context;
>  
> +import java.util.HashMap;
> +import java.util.Map;
>  import java.util.Properties;
>  
>  public class SystemBuildContext
> @@ -7,6 +9,10 @@
>  {
>      
>      public static final String BUILD_CONTEXT_KEY = SystemBuildContext.class.getName();
> +
> +    private static final String SYSTEM_PROPERTIES_KEY = "system-properties";
> +
> +    private static final String ENVIRONMENT_VARIABLES_KEY = "environment-variables";
>      
>      private Properties systemProperties;
>      private Properties envars;
> @@ -50,11 +56,16 @@
>      {
>          BuildContext buildContext = buildContextManager.readBuildContext( false );
>          
> -        SystemBuildContext systemContext = null;
> +        SystemBuildContext systemContext = new SystemBuildContext();
>          
>          if ( buildContext != null )
>          {
> -            systemContext = (SystemBuildContext) buildContext.get( BUILD_CONTEXT_KEY );
> +            SystemBuildContext ctx = new SystemBuildContext();
> +            
> +            if ( buildContext.retrieve( ctx ) || create )
> +            {
> +                systemContext = ctx;
> +            }
>          }
>          
>          if ( create && systemContext == null )
> @@ -69,8 +80,23 @@
>      {
>          BuildContext buildContext = buildContextManager.readBuildContext( true );
>          
> -        buildContext.put( this );
> +        buildContext.store( this );
>          
>          buildContextManager.storeBuildContext( buildContext );
> +    }
> +
> +    public Map getData()
> +    {
> +        Map data = new HashMap( 2 );
> +        data.put( SYSTEM_PROPERTIES_KEY, systemProperties );
> +        data.put( ENVIRONMENT_VARIABLES_KEY, envars );
> +        
> +        return data;
> +    }
> +
> +    public void setData( Map data )
> +    {
> +        this.systemProperties = (Properties) data.get( SYSTEM_PROPERTIES_KEY );
> +        this.envars = (Properties) data.get( ENVIRONMENT_VARIABLES_KEY );
>      }
>  }
>
> Modified: maven/components/trunk/maven-build-context/src/test/java/org/apache/maven/context/AbstractBuildContextManagerTest.java
> URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-build-context/src/test/java/org/apache/maven/context/AbstractBuildContextManagerTest.java?view=diff&rev=509692&r1=509691&r2=509692
> ==============================================================================
> --- maven/components/trunk/maven-build-context/src/test/java/org/apache/maven/context/AbstractBuildContextManagerTest.java (original)
> +++ maven/components/trunk/maven-build-context/src/test/java/org/apache/maven/context/AbstractBuildContextManagerTest.java Tue Feb 20 10:09:53 2007
> @@ -71,7 +71,7 @@
>          
>          BuildContext ctx3 = mgr.readBuildContext( false );
>          
> -        assertNull( ctx3.get( key ) );
> +        assertNull( ctx3 );
>      }
>  
>  }
>
> Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
> URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java?view=diff&rev=509692&r1=509691&r2=509692
> ==============================================================================
> --- maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java (original)
> +++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java Tue Feb 20 10:09:53 2007
> @@ -31,7 +31,6 @@
>  import org.apache.maven.execution.ReactorManager;
>  import org.apache.maven.execution.RuntimeInformation;
>  import org.apache.maven.extension.BuildExtensionScanner;
> -import org.apache.maven.extension.ExtensionManager;
>  import org.apache.maven.extension.ExtensionScanningException;
>  import org.apache.maven.lifecycle.LifecycleExecutor;
>  import org.apache.maven.monitor.event.DefaultEventDispatcher;
> @@ -44,7 +43,6 @@
>  import org.apache.maven.project.MavenProject;
>  import org.apache.maven.project.MavenProjectBuilder;
>  import org.apache.maven.project.ProjectBuildingException;
> -import org.apache.maven.project.build.model.ModelLineageBuilder;
>  import org.apache.maven.reactor.MavenExecutionException;
>  import org.apache.maven.settings.Settings;
>  import org.apache.maven.usability.diagnostics.ErrorDiagnostics;
> @@ -64,10 +62,8 @@
>  import java.util.ArrayList;
>  import java.util.Collections;
>  import java.util.Date;
> -import java.util.HashMap;
>  import java.util.Iterator;
>  import java.util.List;
> -import java.util.Map;
>  import java.util.TimeZone;
>  
>  /**
> @@ -347,15 +343,13 @@
>          
>          // TODO: We should probably do this discovery just-in-time, if we can move to building project
>          // instances just-in-time.
> -        Map cache = new HashMap();
> -        
>          for ( Iterator it = files.iterator(); it.hasNext(); )
>          {
>              File pom = (File) it.next();
>  
>              try
>              {
> -                buildExtensionScanner.scanForBuildExtensions( pom, request.getLocalRepository(), globalProfileManager, cache );
> +                buildExtensionScanner.scanForBuildExtensions( pom, request.getLocalRepository(), globalProfileManager );
>              }
>              catch ( ExtensionScanningException e )
>              {
>
> Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/ExecutionBuildContext.java
> URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/ExecutionBuildContext.java?view=diff&rev=509692&r1=509691&r2=509692
> ==============================================================================
> --- maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/ExecutionBuildContext.java (original)
> +++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/ExecutionBuildContext.java Tue Feb 20 10:09:53 2007
> @@ -11,6 +11,7 @@
>  import java.util.Collections;
>  import java.util.Date;
>  import java.util.List;
> +import java.util.Map;
>  import java.util.Properties;
>  
>  /*
> @@ -39,7 +40,13 @@
>      
>      public static final String BUILD_CONTEXT_KEY = ExecutionBuildContext.class.getName();
>      
> -    private final MavenExecutionRequest request;
> +    private static final String REQUEST_KEY = "request";
> +    
> +    private MavenExecutionRequest request;
> +    
> +    private ExecutionBuildContext()
> +    {
> +    }
>  
>      public ExecutionBuildContext( MavenExecutionRequest request )
>      {
> @@ -195,11 +202,14 @@
>      {
>          BuildContext buildContext = buildContextManager.readBuildContext( false );
>          
> -        ExecutionBuildContext executionContext = null;
> +        ExecutionBuildContext executionContext = new ExecutionBuildContext();
>          
>          if ( buildContext != null )
>          {
> -            executionContext = (ExecutionBuildContext) buildContext.get( BUILD_CONTEXT_KEY );
> +            if ( !buildContext.retrieve( executionContext ) )
> +            {
> +                return null;
> +            }
>          }
>          
>          return executionContext;
> @@ -209,8 +219,18 @@
>      {
>          BuildContext buildContext = buildContextManager.readBuildContext( true );
>          
> -        buildContext.put( this );
> +        buildContext.store( this );
>          
>          buildContextManager.storeBuildContext( buildContext );
> +    }
> +
> +    public Map getData()
> +    {
> +        return Collections.singletonMap( REQUEST_KEY, request );
> +    }
> +
> +    public void setData( Map data )
> +    {
> +        this.request = (MavenExecutionRequest) data.get( REQUEST_KEY );
>      }
>  }
>
> Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/extension/BuildExtensionScanner.java
> URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/extension/BuildExtensionScanner.java?view=diff&rev=509692&r1=509691&r2=509692
> ==============================================================================
> --- maven/components/trunk/maven-core/src/main/java/org/apache/maven/extension/BuildExtensionScanner.java (original)
> +++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/extension/BuildExtensionScanner.java Tue Feb 20 10:09:53 2007
> @@ -4,14 +4,13 @@
>  import org.apache.maven.profiles.ProfileManager;
>  
>  import java.io.File;
> -import java.util.Map;
>  
>  public interface BuildExtensionScanner
>  {
>      
>      String ROLE = BuildExtensionScanner.class.getName();
>      
> -    void scanForBuildExtensions( File pom, ArtifactRepository localRepository, ProfileManager globalProfileManager, Map pomFilesById )
> +    void scanForBuildExtensions( File pom, ArtifactRepository localRepository, ProfileManager globalProfileManager )
>          throws ExtensionScanningException;
>  
>  }
>
> Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/extension/DefaultBuildExtensionScanner.java
> URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/extension/DefaultBuildExtensionScanner.java?view=diff&rev=509692&r1=509691&r2=509692
> ==============================================================================
> --- maven/components/trunk/maven-core/src/main/java/org/apache/maven/extension/DefaultBuildExtensionScanner.java (original)
> +++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/extension/DefaultBuildExtensionScanner.java Tue Feb 20 10:09:53 2007
> @@ -8,6 +8,7 @@
>  import org.apache.maven.model.Build;
>  import org.apache.maven.model.Extension;
>  import org.apache.maven.model.Model;
> +import org.apache.maven.model.Parent;
>  import org.apache.maven.profiles.ProfileManager;
>  import org.apache.maven.profiles.activation.CustomActivatorAdvice;
>  import org.apache.maven.project.MavenProject;
> @@ -25,6 +26,7 @@
>  
>  import java.io.File;
>  import java.io.IOException;
> +import java.util.ArrayList;
>  import java.util.HashMap;
>  import java.util.Iterator;
>  import java.util.List;
> @@ -48,9 +50,17 @@
>      private ModelInterpolator modelInterpolator;
>  
>      public void scanForBuildExtensions( File pom, ArtifactRepository localRepository,
> -                                        ProfileManager globalProfileManager, Map pomFilesById )
> +                                        ProfileManager globalProfileManager )
>          throws ExtensionScanningException
>      {
> +        scanInternal( pom, localRepository, globalProfileManager, new ArrayList() );
> +    }
> +    
> +    private void scanInternal( File pom, ArtifactRepository localRepository, ProfileManager globalProfileManager,
> +                               List visitedModelIds )
> +        throws ExtensionScanningException
> +    {
> +        
>          // setup the CustomActivatorAdvice to fail quietly while we discover extensions...then, we'll
>          // reset it.
>          CustomActivatorAdvice activatorAdvice = CustomActivatorAdvice.getCustomActivatorAdvice( buildContextManager );
> @@ -64,15 +74,26 @@
>              getLogger().debug( "Pre-scanning POM lineage of: " + pom + " for build extensions." );
>  
>              ModelLineage lineage = buildModelLineage( pom, localRepository, originalRemoteRepositories,
> -                                                      globalProfileManager, pomFilesById );
> +                                                      globalProfileManager );
>  
>              Map inheritedInterpolationValues = new HashMap();
>              
>              for ( ModelLineageIterator lineageIterator = lineage.reversedLineageIterator(); lineageIterator.hasNext(); )
>              {
>                  Model model = (Model) lineageIterator.next();
> +                String key = createKey( model );
> +                
> +                if ( visitedModelIds.contains( key ) )
> +                {
> +                    getLogger().debug( "Already visited: " + key + "; continuing." );
> +                    continue;
> +                }
> +                
> +                visitedModelIds.add( key );
> +                
> +                File modelPom = lineageIterator.getPOMFile();
>  
> -                getLogger().debug( "Checking: " + model.getId() + " for extensions." );
> +                getLogger().debug( "Checking: " + model.getId() + " for extensions. (It has " + model.getModules().size() + " modules.)" );
>                  
>                  if ( inheritedInterpolationValues == null )
>                  {
> @@ -83,8 +104,7 @@
>  
>                  checkModelBuildForExtensions( model, localRepository, lineageIterator.getArtifactRepositories() );
>  
> -                checkModulesForExtensions( pom, model, localRepository, originalRemoteRepositories, globalProfileManager,
> -                                           pomFilesById );
> +                checkModulesForExtensions( modelPom, model, localRepository, originalRemoteRepositories, globalProfileManager, visitedModelIds );
>                  
>                  Properties modelProps = model.getProperties();
>                  if ( modelProps != null )
> @@ -108,9 +128,24 @@
>          }
>      }
>  
> +    private String createKey( Model model )
> +    {
> +        Parent parent = model.getParent();
> +        
> +        String groupId = model.getGroupId();
> +        if ( groupId == null )
> +        {
> +            groupId = parent.getGroupId();
> +        }
> +        
> +        String artifactId = model.getArtifactId();
> +        
> +        return groupId + ":" + artifactId;
> +    }
> +
>      private void checkModulesForExtensions( File containingPom, Model model, ArtifactRepository localRepository,
>                                              List originalRemoteRepositories, ProfileManager globalProfileManager,
> -                                            Map pomFilesById )
> +                                            List visitedModelIds )
>          throws ExtensionScanningException
>      {
>          // FIXME: This gets a little sticky, because modules can be added by profiles that require
> @@ -120,6 +155,7 @@
>          if ( modules != null )
>          {
>              File basedir = containingPom.getParentFile();
> +            getLogger().debug( "Basedir is: " + basedir );
>  
>              for ( Iterator it = modules.iterator(); it.hasNext(); )
>              {
> @@ -170,11 +206,11 @@
>                  {
>                      getLogger().debug(
>                                         "Cannot find POM for module: " + moduleSubpath
> -                                           + "; continuing scan with next module." );
> +                                           + "; continuing scan with next module. (Full path was: " + modulePomDirectory + ")" );
>                      continue;
>                  }
>  
> -                scanForBuildExtensions( modulePomDirectory, localRepository, globalProfileManager, pomFilesById );
> +                scanInternal( modulePomDirectory, localRepository, globalProfileManager, visitedModelIds );
>              }
>          }
>      }
> @@ -226,8 +262,7 @@
>      }
>  
>      private ModelLineage buildModelLineage( File pom, ArtifactRepository localRepository,
> -                                            List originalRemoteRepositories, ProfileManager globalProfileManager,
> -                                            Map cache )
> +                                            List originalRemoteRepositories, ProfileManager globalProfileManager )
>          throws ExtensionScanningException
>      {
>          ModelLineage lineage;
> @@ -236,7 +271,7 @@
>              getLogger().debug( "Building model-lineage for: " + pom + " to pre-scan for extensions." );
>  
>              lineage = modelLineageBuilder.buildModelLineage( pom, localRepository, originalRemoteRepositories,
> -                                                             globalProfileManager, cache );
> +                                                             globalProfileManager );
>          }
>          catch ( ProjectBuildingException e )
>          {
>
> Modified: maven/components/trunk/maven-core/src/main/resources/META-INF/plexus/components.xml
> URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/resources/META-INF/plexus/components.xml?view=diff&rev=509692&r1=509691&r2=509692
> ==============================================================================
> --- maven/components/trunk/maven-core/src/main/resources/META-INF/plexus/components.xml (original)
> +++ maven/components/trunk/maven-core/src/main/resources/META-INF/plexus/components.xml Tue Feb 20 10:09:53 2007
> @@ -50,6 +50,7 @@
>          </requirement>
>          <requirement>
>            <role>org.apache.maven.artifact.resolver.ArtifactResolver</role>
> +          <role-hint>project-cache-aware</role-hint>
>          </requirement>
>          <requirement>
>            <role>org.apache.maven.artifact.metadata.ArtifactMetadataSource</role>
> @@ -78,6 +79,7 @@
>          </requirement>
>          <requirement>
>            <role>org.apache.maven.artifact.resolver.ArtifactResolver</role>
> +          <role-hint>project-cache-aware</role-hint>
>          </requirement>
>          <requirement>
>            <role>org.apache.maven.artifact.metadata.ArtifactMetadataSource</role>
>
> Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/CustomActivatorAdvice.java
> URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/CustomActivatorAdvice.java?view=diff&rev=509692&r1=509691&r2=509692
> ==============================================================================
> --- maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/CustomActivatorAdvice.java (original)
> +++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/CustomActivatorAdvice.java Tue Feb 20 10:09:53 2007
> @@ -4,6 +4,9 @@
>  import org.apache.maven.context.BuildContextManager;
>  import org.apache.maven.context.ManagedBuildData;
>  
> +import java.util.Collections;
> +import java.util.Map;
> +
>  /**
>   * Advice for the custom profile activator, which tells how to handle cases where custom activators
>   * cannot be found or configured. This is used to suppress missing activators when pre-scanning for
> @@ -17,6 +20,8 @@
>      
>      public static final String BUILD_CONTEXT_KEY = CustomActivatorAdvice.class.getName();
>      
> +    private static final String FAIL_QUIETLY_KEY = "fail-quietly";
> +    
>      private static final boolean DEFAULT_FAIL_QUIETLY = false;
>      
>      /**
> @@ -54,16 +59,11 @@
>      {
>          BuildContext buildContext = buildContextManager.readBuildContext( false );
>          
> -        CustomActivatorAdvice advice = null;
> +        CustomActivatorAdvice advice = new CustomActivatorAdvice();
>          
>          if ( buildContext != null )
>          {
> -            advice = (CustomActivatorAdvice) buildContext.get( BUILD_CONTEXT_KEY );
> -        }
> -        
> -        if ( advice == null )
> -        {
> -            advice = new CustomActivatorAdvice();
> +            buildContext.retrieve( advice );
>          }
>          
>          return advice;
> @@ -73,8 +73,18 @@
>      {
>          BuildContext buildContext = buildContextManager.readBuildContext( true );
>          
> -        buildContext.put( this );
> +        buildContext.store( this );
>          
>          buildContextManager.storeBuildContext( buildContext );
> +    }
> +
> +    public Map getData()
> +    {
> +        return Collections.singletonMap( FAIL_QUIETLY_KEY, Boolean.valueOf( failQuietly ) );
> +    }
> +
> +    public void setData( Map data )
> +    {
> +        this.failQuietly = ((Boolean) data.get( FAIL_QUIETLY_KEY )).booleanValue();
>      }
>  }
>
> Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
> URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java?view=diff&rev=509692&r1=509691&r2=509692
> ==============================================================================
> --- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java (original)
> +++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java Tue Feb 20 10:09:53 2007
> @@ -23,7 +23,6 @@
>  import org.apache.maven.artifact.InvalidRepositoryException;
>  import org.apache.maven.artifact.factory.ArtifactFactory;
>  import org.apache.maven.artifact.manager.ArtifactManager;
> -import org.apache.maven.artifact.manager.WagonManager;
>  import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
>  import org.apache.maven.artifact.repository.ArtifactRepository;
>  import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
> @@ -48,6 +47,7 @@
>  import org.apache.maven.profiles.ProfileManager;
>  import org.apache.maven.profiles.activation.ProfileActivationException;
>  import org.apache.maven.project.artifact.InvalidDependencyVersionException;
> +import org.apache.maven.project.build.ProjectBuildCache;
>  import org.apache.maven.project.build.ProjectBuildContext;
>  import org.apache.maven.project.build.model.DefaultModelLineage;
>  import org.apache.maven.project.build.model.ModelLineage;
> @@ -151,10 +151,6 @@
>  
>      private ModelValidator validator;
>      
> -    private Map processedProjectCache = new HashMap();
> -    
> -    private Map cachedPomFilesByModelId = new HashMap();
> -
>      // TODO: make it a component
>      private MavenXpp3Reader modelReader;
>  
> @@ -220,9 +216,9 @@
>                                               boolean allowStubModel )
>          throws ProjectBuildingException
>      {
> -        String cacheKey = createCacheKey( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion() );
> -
> -        MavenProject project = (MavenProject) processedProjectCache.get( cacheKey );
> +        ProjectBuildCache projectBuildCache = ProjectBuildCache.read( buildContextManager );
> +        
> +        MavenProject project = (MavenProject) projectBuildCache.getCachedProject( artifact );
>  
>          if ( project != null )
>          {
> @@ -753,7 +749,9 @@
>              throw new InvalidProjectModelException( projectId, pomLocation, e.getMessage(), e );
>          }
>  
> -        processedProjectCache.put( createCacheKey( project.getGroupId(), project.getArtifactId(), project.getVersion() ), project );
> +        ProjectBuildCache projectBuildCache = ProjectBuildCache.read( buildContextManager );
> +        projectBuildCache.cacheProject( project );
> +        projectBuildCache.store( buildContextManager );
>  
>          // jvz:note
>          // this only happens if we are building from a source file
> @@ -778,9 +776,7 @@
>          
>          if ( rawParent != null )
>          {
> -            String cacheKey = createCacheKey( rawParent.getGroupId(), rawParent.getArtifactId(), rawParent.getVersion() );
> -            
> -            MavenProject processedParent = (MavenProject) processedProjectCache.get( cacheKey );
> +            MavenProject processedParent = (MavenProject) projectBuildCache.getCachedProject( rawParent );
>              
>              // yeah, this null check might be a bit paranoid, but better safe than sorry...
>              if ( processedParent != null )
> @@ -1012,7 +1008,7 @@
>          ModelLineage modelLineage = new DefaultModelLineage();
>          modelLineage.setOrigin( model, new File( projectDir, "pom.xml" ), new ArrayList( aggregatedRemoteWagonRepositories ) );
>          
> -        modelLineageBuilder.resumeBuildingModelLineage( modelLineage, localRepository, externalProfileManager, cachedPomFilesByModelId );
> +        modelLineageBuilder.resumeBuildingModelLineage( modelLineage, localRepository, externalProfileManager );
>          
>          ProjectBuildContext projectContext = ProjectBuildContext.getProjectBuildContext( buildContextManager, true );
>          
>
> Added: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/CacheAwareArtifactResolver.java
> URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/CacheAwareArtifactResolver.java?view=auto&rev=509692
> ==============================================================================
> --- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/CacheAwareArtifactResolver.java (added)
> +++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/CacheAwareArtifactResolver.java Tue Feb 20 10:09:53 2007
> @@ -0,0 +1,80 @@
> +package org.apache.maven.project.artifact;
> +
> +import org.apache.maven.artifact.Artifact;
> +import org.apache.maven.artifact.handler.ArtifactHandler;
> +import org.apache.maven.artifact.repository.ArtifactRepository;
> +import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
> +import org.apache.maven.artifact.resolver.ArtifactResolutionException;
> +import org.apache.maven.artifact.resolver.ArtifactResolver;
> +import org.apache.maven.artifact.resolver.DefaultArtifactResolver;
> +import org.apache.maven.context.BuildContextManager;
> +import org.apache.maven.project.MavenProject;
> +import org.apache.maven.project.build.ProjectBuildCache;
> +
> +import java.io.File;
> +import java.util.List;
> +
> +public class CacheAwareArtifactResolver
> +    extends DefaultArtifactResolver
> +{
> +    
> +    private ArtifactResolver delegate;
> +    
> +    private BuildContextManager buildContextManager;
> +
> +    public void resolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository )
> +        throws ArtifactResolutionException, ArtifactNotFoundException
> +    {
> +        resolveFromCache( artifact );
> +        
> +        if ( !artifact.isResolved() )
> +        {
> +            delegate.resolve( artifact, remoteRepositories, localRepository );
> +        }
> +    }
> +
> +    public void resolveAlways( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository )
> +        throws ArtifactResolutionException, ArtifactNotFoundException
> +    {
> +        resolveFromCache( artifact );
> +        
> +        if ( !artifact.isResolved() )
> +        {
> +            delegate.resolveAlways( artifact, remoteRepositories, localRepository );
> +        }
> +    }
> +
> +    private void resolveFromCache( Artifact artifact )
> +    {
> +        ProjectBuildCache cache = ProjectBuildCache.read( buildContextManager );
> +        
> +        if ( "pom".equals( artifact.getType() ) )
> +        {
> +            File pomFile = cache.getCachedModelFile( artifact );
> +            
> +            if ( pomFile != null )
> +            {
> +                artifact.setFile( pomFile );
> +                artifact.setResolved( true );
> +            }
> +        }
> +        // currently, artifacts with classifiers are not really supported as the main project artifact...
> +        else if ( artifact.getClassifier() == null )
> +        {
> +            MavenProject project = cache.getCachedProject( artifact );
> +            ArtifactHandler handler = artifact.getArtifactHandler();
> +            
> +            if ( project != null && handler.getPackaging().equals( project.getPackaging() ) )
> +            {
> +                File projectArtifactFile = project.getArtifact().getFile();
> +                
> +                if ( projectArtifactFile != null )
> +                {
> +                    artifact.setFile( projectArtifactFile );
> +                    artifact.setResolved( true );
> +                }
> +            }
> +        }
> +    }
> +
> +}
>
> Propchange: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/CacheAwareArtifactResolver.java
> ------------------------------------------------------------------------------
>     svn:eol-style = native
>
> Propchange: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/CacheAwareArtifactResolver.java
> ------------------------------------------------------------------------------
>     svn:keywords = "Author Date Id Revision"
>
> Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
> URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java?view=diff&rev=509692&r1=509691&r2=509692
> ==============================================================================
> --- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java (original)
> +++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java Tue Feb 20 10:09:53 2007
> @@ -33,6 +33,7 @@
>  import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
>  import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
>  import org.apache.maven.artifact.versioning.VersionRange;
> +import org.apache.maven.context.BuildContextManager;
>  import org.apache.maven.model.Dependency;
>  import org.apache.maven.model.DistributionManagement;
>  import org.apache.maven.model.Exclusion;
> @@ -41,6 +42,7 @@
>  import org.apache.maven.project.MavenProject;
>  import org.apache.maven.project.MavenProjectBuilder;
>  import org.apache.maven.project.ProjectBuildingException;
> +import org.apache.maven.project.build.ProjectBuildCache;
>  import org.apache.maven.project.validation.ModelValidationResult;
>  import org.codehaus.plexus.logging.AbstractLogEnabled;
>  import org.codehaus.plexus.util.StringUtils;
> @@ -69,6 +71,8 @@
>      private ArtifactFactory artifactFactory;
>  
>      private RepositoryMetadataManager repositoryMetadataManager;
> +    
> +    private BuildContextManager buildContextManager;
>  
>      // lazily instantiated and cached.
>      private MavenProject superProject;
> @@ -81,6 +85,8 @@
>      public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories )
>          throws ArtifactMetadataRetrievalException
>      {
> +        ProjectBuildCache cache = ProjectBuildCache.read( buildContextManager );
> +        
>          MavenProject project = null;
>  
>          Artifact pomArtifact;
> @@ -97,40 +103,46 @@
>              }
>              else
>              {
> -                try
> +                project = cache.getCachedProject( artifact );
> +                
> +                if ( project == null )
>                  {
> -                    project = mavenProjectBuilder.buildFromRepository( pomArtifact, remoteRepositories, localRepository,
> -                                                                       true );
> -                }
> -                catch ( InvalidProjectModelException e )
> -                {
> -                    getLogger().warn( "POM for \'" + pomArtifact +
> -                        "\' is invalid. It will be ignored for artifact resolution. Reason: " + e.getMessage() );
> -
> -                    if ( getLogger().isDebugEnabled() )
> +                    try
>                      {
> -                        getLogger().debug( "Reason: " + e.getMessage() );
> -                        
> -                        ModelValidationResult validationResult = e.getValidationResult();
> +                        project = mavenProjectBuilder.buildFromRepository( pomArtifact, remoteRepositories, localRepository,
> +                                                                           true );
> +                    }
> +                    catch ( InvalidProjectModelException e )
> +                    {
> +                        getLogger().warn( "POM for \'" + pomArtifact +
> +                            "\' is invalid. It will be ignored for artifact resolution. Reason: " + e.getMessage() );
>  
> -                        if ( validationResult != null )
> +                        if ( getLogger().isDebugEnabled() )
>                          {
> -                            getLogger().debug( "\nValidation Errors:" );
> -                            for ( Iterator i = validationResult.getMessages().iterator(); i.hasNext(); )
> +                            getLogger().debug( "Reason: " + e.getMessage() );
> +                            
> +                            ModelValidationResult validationResult = e.getValidationResult();
> +
> +                            if ( validationResult != null )
>                              {
> -                                getLogger().debug( i.next().toString() );
> +                                getLogger().debug( "\nValidation Errors:" );
> +                                for ( Iterator i = validationResult.getMessages().iterator(); i.hasNext(); )
> +                                {
> +                                    getLogger().debug( i.next().toString() );
> +                                }
> +                                getLogger().debug( "\n" );
>                              }
> -                            getLogger().debug( "\n" );
>                          }
> -                    }
>  
> -                    project = null;
> -                }
> -                catch ( ProjectBuildingException e )
> -                {
> -                    throw new ArtifactMetadataRetrievalException( "Unable to read the metadata file for artifact '" +
> -                        artifact.getDependencyConflictId() + "': " + e.getMessage(), e );
> +                        project = null;
> +                    }
> +                    catch ( ProjectBuildingException e )
> +                    {
> +                        throw new ArtifactMetadataRetrievalException( "Unable to read the metadata file for artifact '" +
> +                            artifact.getDependencyConflictId() + "': " + e.getMessage(), e );
> +                    }
>                  }
> +                
>  
>                  if ( project != null )
>                  {
> @@ -176,13 +188,13 @@
>  
>                          if ( artifact.getDependencyTrail() != null && artifact.getDependencyTrail().size() == 1 )
>                          {
> -                            getLogger().warn( "While downloading " + pomArtifact.getGroupId() + ":" +
> -                                pomArtifact.getArtifactId() + ":" + pomArtifact.getVersion() + message + "\n" );
> +                            getLogger().warn( "While downloading " + artifact.getGroupId() + ":" +
> +                                artifact.getArtifactId() + ":" + artifact.getVersion() + message + "\n" );
>                          }
>                          else
>                          {
> -                            getLogger().debug( "While downloading " + pomArtifact.getGroupId() + ":" +
> -                                pomArtifact.getArtifactId() + ":" + pomArtifact.getVersion() + message + "\n" );
> +                            getLogger().debug( "While downloading " + artifact.getGroupId() + ":" +
> +                                artifact.getArtifactId() + ":" + artifact.getVersion() + message + "\n" );
>                          }
>                      }
>                      else
>
> Added: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/ProjectBuildCache.java
> URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/ProjectBuildCache.java?view=auto&rev=509692
> ==============================================================================
> --- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/ProjectBuildCache.java (added)
> +++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/ProjectBuildCache.java Tue Feb 20 10:09:53 2007
> @@ -0,0 +1,181 @@
> +package org.apache.maven.project.build;
> +
> +import org.apache.maven.artifact.Artifact;
> +import org.apache.maven.context.BuildContext;
> +import org.apache.maven.context.BuildContextManager;
> +import org.apache.maven.context.ManagedBuildData;
> +import org.apache.maven.model.Model;
> +import org.apache.maven.model.Parent;
> +import org.apache.maven.project.MavenProject;
> +
> +import java.io.File;
> +import java.util.HashMap;
> +import java.util.Map;
> +
> +/**
> + * This cache is meant to provide a reference of the project instances that are in the current build
> + * in order to avoid storing a hidden caching mechanism in the project builder, and avoid the need
> + * to store inter-project references as such in MavenProject instances. An ArtifactResolver instance
> + * will be used that can utilize this cache, but will also wrap the "default" ArtifactResolver
> + * instance, so that can be used as a target for replacement implementations.
> + * 
> + * To retrieve from the build context: buildContext.retrieve( new ProjectBuildCache( false ) );
> + * 
> + * @author jdcasey
> + */
> +public class ProjectBuildCache
> +    implements ManagedBuildData
> +{
> +    
> +    private static final String BUILD_CONTEXT_KEY = ProjectBuildCache.class.getName();
> +    
> +    private static final String PROJECT_CACHE = "project-cache";
> +    
> +    private static final String POM_FILE_CACHE = "pom-file-cache";
> +    
> +    private Map projectCache;
> +    
> +    private Map pomFileCache;
> +    
> +    public ProjectBuildCache()
> +    {
> +        this( true );
> +    }
> +    
> +    /**
> +     * @param liveInstance If false, this instance's state is meant to be retrieved from the build
> +     *   context. If true, this instance can serve as the authoritative instance where the cache is
> +     *   established.
> +     */
> +    public ProjectBuildCache( boolean liveInstance )
> +    {
> +        if ( liveInstance )
> +        {
> +            projectCache = new HashMap();
> +            pomFileCache = new HashMap();
> +        }
> +    }
> +    
> +    public void cacheProject( MavenProject project )
> +    {
> +        projectCache.put( generateCacheKey( project ), project );
> +    }
> +    
> +    public MavenProject getCachedProject( String groupId, String artifactId, String version )
> +    {
> +        return (MavenProject) projectCache.get( generateCacheKey( groupId, artifactId, version ) );
> +    }
> +    
> +    public MavenProject getCachedProject( Artifact artifact )
> +    {
> +        return (MavenProject) projectCache.get( generateCacheKey( artifact ) );
> +    }
> +    
> +    public MavenProject getCachedProject( MavenProject exampleInstance )
> +    {
> +        return (MavenProject) projectCache.get( generateCacheKey( exampleInstance ) );
> +    }
> +
> +    public void cacheModelFileForModel( File modelFile, Model model )
> +    {
> +        pomFileCache.put( generateCacheKey( model ), modelFile );
> +    }
> +    
> +    public File getCachedModelFile( Artifact artifact )
> +    {
> +        return (File) pomFileCache.get( generateCacheKey( artifact ) );
> +    }
> +
> +    public File getCachedModelFile( Parent parent )
> +    {
> +        return (File) pomFileCache.get( generateCacheKey( parent ) );
> +    }
> +
> +    public File getCachedModelFile( String groupId, String artifactId, String version )
> +    {
> +        return (File) pomFileCache.get( generateCacheKey( groupId, artifactId, version ) );
> +    }
> +
> +    public Map getData()
> +    {
> +        Map data = new HashMap( 2 );
> +        
> +        data.put( PROJECT_CACHE, projectCache );
> +        data.put( POM_FILE_CACHE, pomFileCache );
> +        
> +        return data;
> +    }
> +
> +    public String getStorageKey()
> +    {
> +        return BUILD_CONTEXT_KEY;
> +    }
> +
> +    public void setData( Map data )
> +    {
> +        this.projectCache = (Map) data.get( PROJECT_CACHE );
> +        this.pomFileCache = (Map) data.get( POM_FILE_CACHE );
> +    }
> +
> +    public void store( BuildContextManager buildContextManager )
> +    {
> +        BuildContext buildContext = buildContextManager.readBuildContext( true );
> +        buildContext.store( this );
> +        buildContextManager.storeBuildContext( buildContext );
> +    }
> +
> +    public static ProjectBuildCache read( BuildContextManager buildContextManager )
> +    {
> +        BuildContext buildContext = buildContextManager.readBuildContext( true );
> +        
> +        ProjectBuildCache cache = new ProjectBuildCache();
> +        
> +        buildContext.retrieve( cache );
> +        
> +        return cache;
> +    }
> +
> +    private static String generateCacheKey( Model model )
> +    {
> +        Parent modelParent = model.getParent();
> +
> +        String groupId = model.getGroupId();
> +
> +        if ( groupId == null && modelParent != null )
> +        {
> +            groupId = modelParent.getGroupId();
> +        }
> +
> +        String artifactId = model.getArtifactId();
> +
> +        String version = model.getVersion();
> +
> +        if ( version == null && modelParent != null )
> +        {
> +            version = modelParent.getVersion();
> +        }
> +
> +        return generateCacheKey( groupId, artifactId, version );
> +    }
> +    
> +    private static String generateCacheKey( Parent parent )
> +    {
> +        return generateCacheKey( parent.getGroupId(), parent.getArtifactId(), parent.getVersion() );
> +    }
> +    
> +    private static String generateCacheKey( Artifact artifact )
> +    {
> +        return generateCacheKey( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion() );
> +    }
> +    
> +    private static String generateCacheKey( MavenProject project )
> +    {
> +        return generateCacheKey( project.getGroupId(), project.getArtifactId(), project.getVersion() );
> +    }
> +    
> +    private static String generateCacheKey( String groupId, String artifactId, String version )
> +    {
> +        return groupId + ":" + artifactId + ":" + version;
> +    }
> +
> +}
>
> Propchange: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/ProjectBuildCache.java
> ------------------------------------------------------------------------------
>     svn:eol-style = native
>
> Propchange: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/ProjectBuildCache.java
> ------------------------------------------------------------------------------
>     svn:keywords = "Author Date Id Revision"
>
> Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/ProjectBuildContext.java
> URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/ProjectBuildContext.java?view=diff&rev=509692&r1=509691&r2=509692
> ==============================================================================
> --- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/ProjectBuildContext.java (original)
> +++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/ProjectBuildContext.java Tue Feb 20 10:09:53 2007
> @@ -6,6 +6,9 @@
>  import org.apache.maven.project.MavenProject;
>  import org.apache.maven.project.build.model.ModelLineage;
>  
> +import java.util.HashMap;
> +import java.util.Map;
> +
>  /*
>   * Copyright 2001-2005 The Apache Software Foundation.
>   *
> @@ -34,6 +37,10 @@
>  {
>      
>      public static final String BUILD_CONTEXT_KEY = ProjectBuildContext.class.getName();
> +
> +    private static final String MODEL_LINEAGE = "model-lineage";
> +
> +    private static final String CURRENT_PROJECT = "current-project";
>      
>      private ModelLineage modelLineage;
>      
> @@ -72,16 +79,14 @@
>      {
>          BuildContext buildContext = buildContextManager.readBuildContext( false );
>          
> -        ProjectBuildContext projectContext = null;
> +        ProjectBuildContext projectContext = new ProjectBuildContext();
>          
>          if ( buildContext != null )
>          {
> -            projectContext = (ProjectBuildContext) buildContext.get( BUILD_CONTEXT_KEY );
> -        }
> -        
> -        if ( create && projectContext == null )
> -        {
> -            projectContext = new ProjectBuildContext();
> +            if ( !buildContext.retrieve( projectContext ) && !create )
> +            {
> +                return null;
> +            }
>          }
>          
>          return projectContext;
> @@ -91,8 +96,24 @@
>      {
>          BuildContext buildContext = buildContextManager.readBuildContext( true );
>          
> -        buildContext.put( this );
> +        buildContext.store( this );
>          
>          buildContextManager.storeBuildContext( buildContext );
> +    }
> +
> +    public Map getData()
> +    {
> +        Map data = new HashMap( 2 );
> +        
> +        data.put( MODEL_LINEAGE, modelLineage );
> +        data.put( CURRENT_PROJECT, currentProject );
> +        
> +        return data;
> +    }
> +
> +    public void setData( Map data )
> +    {
> +        this.modelLineage = (ModelLineage) data.get( MODEL_LINEAGE );
> +        this.currentProject = (MavenProject) data.get( CURRENT_PROJECT );
>      }
>  }
>
> Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/model/DefaultModelLineageBuilder.java
> URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/model/DefaultModelLineageBuilder.java?view=diff&rev=509692&r1=509691&r2=509692
> ==============================================================================
> --- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/model/DefaultModelLineageBuilder.java (original)
> +++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/model/DefaultModelLineageBuilder.java Tue Feb 20 10:09:53 2007
> @@ -8,11 +8,13 @@
>  import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
>  import org.apache.maven.artifact.resolver.ArtifactResolutionException;
>  import org.apache.maven.artifact.resolver.ArtifactResolver;
> +import org.apache.maven.context.BuildContextManager;
>  import org.apache.maven.model.Model;
>  import org.apache.maven.model.Parent;
>  import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
>  import org.apache.maven.profiles.ProfileManager;
>  import org.apache.maven.project.ProjectBuildingException;
> +import org.apache.maven.project.build.ProjectBuildCache;
>  import org.apache.maven.project.build.profile.ProfileAdvisor;
>  import org.codehaus.plexus.logging.LogEnabled;
>  import org.codehaus.plexus.logging.Logger;
> @@ -28,7 +30,6 @@
>  import java.util.Collections;
>  import java.util.LinkedHashSet;
>  import java.util.List;
> -import java.util.Map;
>  import java.util.Set;
>  
>  /**
> @@ -47,6 +48,8 @@
>      private MavenTools mavenTools;
>  
>      private ProfileAdvisor profileAdvisor;
> +    
> +    private BuildContextManager buildContextManager;
>  
>      private Logger logger;
>  
> @@ -54,19 +57,22 @@
>      {
>      }
>  
> -    public DefaultModelLineageBuilder( ArtifactResolver resolver, ArtifactFactory artifactFactory )
> +    public DefaultModelLineageBuilder( ArtifactResolver resolver, ArtifactFactory artifactFactory, BuildContextManager buildContextManager )
>      {
>          this.artifactResolver = resolver;
>          this.artifactFactory = artifactFactory;
> +        this.buildContextManager = buildContextManager;
>      }
>  
>      /**
>       * @see org.apache.maven.project.build.model.ModelLineageBuilder#buildModelLineage(java.io.File, org.apache.maven.artifact.repository.ArtifactRepository, java.util.List)
>       */
>      public ModelLineage buildModelLineage( File pom, ArtifactRepository localRepository, List remoteRepositories,
> -                                           ProfileManager profileManager, Map cachedPomFilesByModelId )
> +                                           ProfileManager profileManager )
>          throws ProjectBuildingException
>      {
> +        ProjectBuildCache projectBuildCache = ProjectBuildCache.read( buildContextManager );
> +        
>          ModelLineage lineage = new DefaultModelLineage();
>  
>          File pomFile = pom;
> @@ -75,7 +81,7 @@
>  
>          while ( pomFile != null )
>          {
> -            Model model = readModel( pomFile, cachedPomFilesByModelId );
> +            Model model = readModel( pomFile, projectBuildCache );
>  
>              if ( lineage.size() == 0 )
>              {
> @@ -89,16 +95,18 @@
>              currentRemoteRepositories = updateRepositorySet( model, currentRemoteRepositories, pomFile, profileManager );
>  
>              pomFile = resolveParentPom( model, currentRemoteRepositories, localRepository, pomFile,
> -                                        cachedPomFilesByModelId );
> +                                        projectBuildCache );
>          }
>  
>          return lineage;
>      }
>  
>      public void resumeBuildingModelLineage( ModelLineage lineage, ArtifactRepository localRepository,
> -                                            ProfileManager profileManager, Map cachedPomFilesByModelId )
> +                                            ProfileManager profileManager )
>          throws ProjectBuildingException
>      {
> +        ProjectBuildCache projectBuildCache = ProjectBuildCache.read( buildContextManager );
> +        
>          File pomFile = lineage.getDeepestFile();
>          List currentRemoteRepositories = lineage.getDeepestArtifactRepositoryList();
>  
> @@ -110,11 +118,11 @@
>          Model model = lineage.getDeepestModel();
>  
>          // use the above information to re-bootstrap the resolution chain...
> -        pomFile = resolveParentPom( model, currentRemoteRepositories, localRepository, pomFile, cachedPomFilesByModelId );
> +        pomFile = resolveParentPom( model, currentRemoteRepositories, localRepository, pomFile, projectBuildCache );
>  
>          while ( pomFile != null )
>          {
> -            model = readModel( pomFile, cachedPomFilesByModelId );
> +            model = readModel( pomFile, projectBuildCache );
>  
>              if ( lineage.size() == 0 )
>              {
> @@ -128,7 +136,7 @@
>              currentRemoteRepositories = updateRepositorySet( model, currentRemoteRepositories, pomFile, profileManager );
>  
>              pomFile = resolveParentPom( model, currentRemoteRepositories, localRepository, pomFile,
> -                                        cachedPomFilesByModelId );
> +                                        projectBuildCache );
>          }
>      }
>  
> @@ -146,10 +154,10 @@
>       * Read the Model instance from the given POM file, and cache it in the given Map before 
>       * returning it.
>       */
> -    private Model readModel( File pomFile, Map cachedPomFilesByModelId )
> +    private Model readModel( File pomFile, ProjectBuildCache projectBuildCache )
>          throws ProjectBuildingException
>      {
> -        return readModel( pomFile, cachedPomFilesByModelId, false );
> +        return readModel( pomFile, projectBuildCache, false );
>      }
>  
>      /**
> @@ -157,7 +165,7 @@
>       * Model instance in the given Map before returning it. The skipCache flag controls whether the
>       * Model instance is actually cached.
>       */
> -    private Model readModel( File pom, Map cachedPomFilesByModelId, boolean skipCache )
> +    private Model readModel( File pom, ProjectBuildCache projectBuildCache, boolean skipCache )
>          throws ProjectBuildingException
>      {
>          File pomFile = pom;
> @@ -190,7 +198,8 @@
>  
>          if ( !skipCache )
>          {
> -            cachedPomFilesByModelId.put( createCacheKey( model, pomFile ), pomFile );
> +            projectBuildCache.cacheModelFileForModel( pomFile, model );
> +            projectBuildCache.store( buildContextManager );
>          }
>  
>          return model;
> @@ -265,10 +274,10 @@
>      /**
>       * Pull the parent specification out of the given model, construct an Artifact instance, and
>       * resolve that artifact...then, return the resolved POM file for the parent.
> -     * @param cachedModelsById 
> +     * @param projectBuildCache 
>       */
>      private File resolveParentPom( Model model, List remoteRepositories, ArtifactRepository localRepository,
> -                                   File modelPomFile, Map cachedModelsById )
> +                                   File modelPomFile, ProjectBuildCache projectBuildCache )
>          throws ProjectBuildingException
>      {
>          Parent modelParent = model.getParent();
> @@ -279,11 +288,9 @@
>          {
>              validateParentDeclaration( modelParent, model );
>  
> -            String cacheKey = createCacheKey( modelParent );
> -            
>  //            getLogger().debug( "Looking for cached parent POM under: " + cacheKey );
>              
> -            pomFile = (File) cachedModelsById.get( cacheKey );
> +            pomFile = (File) projectBuildCache.getCachedModelFile( modelParent );
>  
>              if ( pomFile == null )
>              {
> @@ -297,42 +304,6 @@
>          }
>  
>          return pomFile;
> -    }
> -
> -    private String createCacheKey( Parent modelParent )
> -    {
> -        return modelParent.getGroupId() + ":" + modelParent.getArtifactId() + ":" + modelParent.getVersion();
> -    }
> -
> -    private String createCacheKey( Model model, File pomFile )
> -        throws ProjectBuildingException
> -    {
> -        Parent modelParent = model.getParent();
> -
> -        String groupId = model.getGroupId();
> -
> -        if ( groupId == null && modelParent != null )
> -        {
> -            groupId = modelParent.getGroupId();
> -        }
> -
> -        String artifactId = model.getArtifactId();
> -
> -        String version = model.getVersion();
> -
> -        if ( version == null && modelParent != null )
> -        {
> -            version = modelParent.getVersion();
> -        }
> -
> -        if ( groupId == null || version == null )
> -        {
> -            throw new ProjectBuildingException( model.getId(),
> -                                                "Invalid model. Must either specify groupId and version directly, or specify a parent groupId and version.\nIn POM: "
> -                                                    + pomFile );
> -        }
> -
> -        return groupId + ":" + artifactId + ":" + version;
>      }
>  
>      private void validateParentDeclaration( Parent modelParent, Model model )
>
> Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/model/ModelLineageBuilder.java
> URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/model/ModelLineageBuilder.java?view=diff&rev=509692&r1=509691&r2=509692
> ==============================================================================
> --- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/model/ModelLineageBuilder.java (original)
> +++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/model/ModelLineageBuilder.java Tue Feb 20 10:09:53 2007
> @@ -6,7 +6,6 @@
>  
>  import java.io.File;
>  import java.util.List;
> -import java.util.Map;
>  
>  /**
>   * Builds the lineage of Model instances, starting from a given POM file, and stretching back through
> @@ -32,12 +31,9 @@
>       *   should be resolved
>       * @param profileManager The profile manager containing information about global profiles to be
>       *   applied (from settings.xml, for instance)
> -     * @param cachedPomFilesByModelId A "global" cache of Model source files, partially for 
> -     *   optimization, and partially for loading Models that are unavailable in the repository and 
> -     *   have an incorrect relativePath
>       */
>      ModelLineage buildModelLineage( File pom, ArtifactRepository localRepository, List remoteRepositories,
> -                                    ProfileManager profileManager, Map cachedPomFilesByModelId )
> +                                    ProfileManager profileManager )
>          throws ProjectBuildingException;
>  
>      /**
> @@ -48,12 +44,9 @@
>       * @param localRepository The local repository against which parent POMs should be resolved
>       * @param profileManager The profile manager containing information about global profiles to be
>       *   applied (from settings.xml, for instance)
> -     * @param cachedPomFilesByModelId A "global" cache of Model source files, partially for 
> -     *   optimization, and partially for loading Models that are unavailable in the repository and 
> -     *   have an incorrect relativePath
>       */
>      void resumeBuildingModelLineage( ModelLineage lineage, ArtifactRepository localRepository,
> -                                     ProfileManager profileManager, Map cachedPomFilesByModelId )
> +                                     ProfileManager profileManager )
>          throws ProjectBuildingException;
>  
>  }
>
> Modified: maven/components/trunk/maven-project/src/main/resources/META-INF/plexus/components.xml
> URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/resources/META-INF/plexus/components.xml?view=diff&rev=509692&r1=509691&r2=509692
> ==============================================================================
> --- maven/components/trunk/maven-project/src/main/resources/META-INF/plexus/components.xml (original)
> +++ maven/components/trunk/maven-project/src/main/resources/META-INF/plexus/components.xml Tue Feb 20 10:09:53 2007
> @@ -1,5 +1,38 @@
>  <component-set>
>    <components>
> +    <!--
> +     |
> +     | Resolver
> +     |
> +     -->
> +    <component>
> +      <role>org.apache.maven.artifact.resolver.ArtifactResolver</role>
> +      <implementation>org.apache.maven.project.artifact.CacheAwareArtifactResolver</implementation>
> +      <role-hint>project-cache-aware</role-hint>
> +      <requirements>
> +        <requirement>
> +          <role>org.apache.maven.artifact.manager.ArtifactManager</role>
> +        </requirement>
> +        <requirement>
> +          <role>org.apache.maven.artifact.transform.ArtifactTransformationManager</role>
> +        </requirement>
> +        <requirement>
> +          <role>org.apache.maven.artifact.factory.ArtifactFactory</role>
> +        </requirement>
> +        <requirement>
> +          <role>org.apache.maven.artifact.resolver.ArtifactCollector</role>
> +        </requirement>
> +        <requirement>
> +          <role>org.apache.maven.artifact.resolver.ArtifactResolver</role>
> +          <role-hint>default</role-hint>
> +        </requirement>
> +        <requirement>
> +          <role>org.apache.maven.context.BuildContextManager</role>
> +          <role-hint>default</role-hint>
> +        </requirement>
> +      </requirements>
> +    </component>
> +
>      <component>
>        <role>org.apache.maven.project.build.profile.ProfileAdvisor</role>
>        <role-hint>default</role-hint>
> @@ -37,6 +70,11 @@
>          </requirement>
>          <requirement>
>            <role>org.apache.maven.artifact.resolver.ArtifactResolver</role>
> +          <role-hint>project-cache-aware</role-hint>
> +        </requirement>
> +        <requirement>
> +          <role>org.apache.maven.context.BuildContextManager</role>
> +          <role-hint>default</role-hint>
>          </requirement>
>        </requirements>
>      </component>
> @@ -264,6 +302,10 @@
>          </requirement>
>          <requirement>
>            <role>org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager</role>
> +        </requirement>
> +        <requirement>
> +          <role>org.apache.maven.context.BuildContextManager</role>
> +          <role-hint>default</role-hint>
>          </requirement>
>        </requirements>
>      </component>
>
> Modified: maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/build/model/DefaultModelLineageBuilderTest.java
> URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/build/model/DefaultModelLineageBuilderTest.java?view=diff&rev=509692&r1=509691&r2=509692
> ==============================================================================
> --- maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/build/model/DefaultModelLineageBuilderTest.java (original)
> +++ maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/build/model/DefaultModelLineageBuilderTest.java Tue Feb 20 10:09:53 2007
> @@ -3,10 +3,12 @@
>  import org.apache.maven.artifact.repository.ArtifactRepository;
>  import org.apache.maven.artifact.repository.DefaultArtifactRepository;
>  import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
> +import org.apache.maven.context.BuildContextManager;
>  import org.apache.maven.model.Model;
>  import org.apache.maven.model.Parent;
>  import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
>  import org.apache.maven.project.ProjectBuildingException;
> +import org.apache.maven.project.build.ProjectBuildCache;
>  import org.codehaus.plexus.PlexusTestCase;
>  import org.codehaus.plexus.logging.Logger;
>  import org.codehaus.plexus.util.FileUtils;
> @@ -16,9 +18,7 @@
>  import java.io.FileWriter;
>  import java.io.IOException;
>  import java.util.Collections;
> -import java.util.HashMap;
>  import java.util.Iterator;
> -import java.util.Map;
>  
>  public class DefaultModelLineageBuilderTest
>      extends PlexusTestCase
> @@ -68,7 +68,7 @@
>              IOUtil.close( writer );
>          }
>  
> -        ModelLineage lineage = modelLineageBuilder.buildModelLineage( pomFile, null, null, null, new HashMap() );
> +        ModelLineage lineage = modelLineageBuilder.buildModelLineage( pomFile, null, null, null );
>  
>          assertEquals( 1, lineage.size() );
>  
> @@ -126,7 +126,7 @@
>              .toExternalForm(), defaultLayout );
>  
>          ModelLineage lineage = modelLineageBuilder.buildModelLineage( currentPOM, localRepository,
> -                                                                      Collections.EMPTY_LIST, null, new HashMap() );
> +                                                                      Collections.EMPTY_LIST, null );
>  
>          assertEquals( 3, lineage.size() );
>  
> @@ -198,7 +198,7 @@
>              .toExternalForm(), defaultLayout );
>  
>          ModelLineage lineage = modelLineageBuilder.buildModelLineage( currentPOM, localRepository, Collections
> -            .singletonList( remoteRepository ), null, new HashMap() );
> +            .singletonList( remoteRepository ), null );
>  
>          assertEquals( 3, lineage.size() );
>  
> @@ -253,7 +253,7 @@
>              .toExternalForm(), defaultLayout );
>  
>          ModelLineage lineage = modelLineageBuilder.buildModelLineage( currentPOM, localRepository,
> -                                                                      Collections.EMPTY_LIST, null, new HashMap() );
> +                                                                      Collections.EMPTY_LIST, null );
>  
>          assertEquals( 2, lineage.size() );
>  
> @@ -303,7 +303,7 @@
>      }
>  
>      public void testReadPOMWithParentInOtherLocalFileWithBadRelativePath()
> -        throws IOException, ProjectBuildingException
> +        throws Exception
>      {
>          // 1. create the parent model in a "local" POM file.
>          File parentPOM = File.createTempFile( "DefaultModelLineageBuilder.test.", ".pom" );
> @@ -314,8 +314,11 @@
>          // 4. write the parent model to the local repo directory
>          writeModel( parent, parentPOM );
>          
> -        Map cache = new HashMap();
> -        cache.put( "group:parent:1", parentPOM );
> +        BuildContextManager buildContextManager = (BuildContextManager) lookup( BuildContextManager.ROLE, "default" );
> +        
> +        ProjectBuildCache cache = ProjectBuildCache.read( buildContextManager );
> +        cache.cacheModelFileForModel( parentPOM, parent );
> +        cache.store( buildContextManager );
>  
>          // 5. create the current pom with a parent-ref on the parent model
>          Model current = createModel( "group", "current", "1" );
> @@ -336,13 +339,12 @@
>  
>          // 7. build the lineage.
>          ModelLineage lineage = modelLineageBuilder.buildModelLineage( currentPOM, null, Collections
> -            .EMPTY_LIST, null, cache );
> +            .EMPTY_LIST, null );
>  
>          assertEquals( 2, lineage.size() );
>  
>          Iterator modelIterator = lineage.modelIterator();
>  
> -        assertEquals( 2, cache.size() );
>          assertEquals( current.getId(), ( (Model) modelIterator.next() ).getId() );
>          assertEquals( parent.getId(), ( (Model) modelIterator.next() ).getId() );
>      }
>
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org