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/01/19 20:15:21 UTC

svn commit: r497911 [1/2] - in /maven/components/trunk: ./ maven-build-context/ maven-build-context/src/ maven-build-context/src/main/ maven-build-context/src/main/java/ maven-build-context/src/main/java/org/ maven-build-context/src/main/java/org/apach...

Author: jdcasey
Date: Fri Jan 19 11:15:18 2007
New Revision: 497911

URL: http://svn.apache.org/viewvc?view=rev&rev=497911
Log:
Adding the notion of a build-context, and several build-context classes that can be used: ProjectBuildContext, which contains lineage and current-project info, ExecutionBuildContext, which contains the information in the original MavenExecutionRequest, and SystemBuildContext, which contains things like System properties...these use the BuildContextManager to store and retrieve their info from the core container's Context object.

Added:
    maven/components/trunk/maven-build-context/
    maven/components/trunk/maven-build-context/pom.xml   (with props)
    maven/components/trunk/maven-build-context/src/
    maven/components/trunk/maven-build-context/src/main/
    maven/components/trunk/maven-build-context/src/main/java/
    maven/components/trunk/maven-build-context/src/main/java/org/
    maven/components/trunk/maven-build-context/src/main/java/org/apache/
    maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/
    maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/
    maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/BuildContext.java   (with props)
    maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/BuildContextManager.java   (with props)
    maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/DefaultBuildContext.java   (with props)
    maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/DefaultBuildContextManager.java   (with props)
    maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/ManagedBuildData.java   (with props)
    maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/SystemBuildContext.java   (with props)
    maven/components/trunk/maven-build-context/src/main/resources/
    maven/components/trunk/maven-build-context/src/main/resources/META-INF/
    maven/components/trunk/maven-build-context/src/main/resources/META-INF/plexus/
    maven/components/trunk/maven-build-context/src/main/resources/META-INF/plexus/components.xml   (with props)
    maven/components/trunk/maven-build-context/src/test/
    maven/components/trunk/maven-build-context/src/test/java/
    maven/components/trunk/maven-build-context/src/test/java/org/
    maven/components/trunk/maven-build-context/src/test/java/org/apache/
    maven/components/trunk/maven-build-context/src/test/java/org/apache/maven/
    maven/components/trunk/maven-build-context/src/test/java/org/apache/maven/context/
    maven/components/trunk/maven-build-context/src/test/java/org/apache/maven/context/AbstractBuildContextManagerTest.java   (with props)
    maven/components/trunk/maven-build-context/src/test/java/org/apache/maven/context/AbstractBuildContextTest.java   (with props)
    maven/components/trunk/maven-build-context/src/test/java/org/apache/maven/context/DefaultBuildContextManagerTest.java   (with props)
    maven/components/trunk/maven-build-context/src/test/java/org/apache/maven/context/DefaultBuildContextTest.java   (with props)
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/ExecutionBuildContext.java   (with props)
    maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/CustomActivator.java   (with props)
    maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/CustomActivatorExpressionEvaluator.java   (with props)
    maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/ProjectBuildContext.java   (with props)
    maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/model/ModelLineageIterator.java   (with props)
Modified:
    maven/components/trunk/maven-core/pom.xml
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
    maven/components/trunk/maven-core/src/main/resources/META-INF/plexus/components.xml
    maven/components/trunk/maven-model/maven.mdo
    maven/components/trunk/maven-project/pom.xml
    maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/DetectedProfileActivator.java
    maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/FileProfileActivator.java
    maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/JdkPrefixProfileActivator.java
    maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/SystemPropertyProfileActivator.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/build/model/DefaultModelLineage.java
    maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/model/ModelLineage.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/profiles/DefaultProfileManagerTest.java
    maven/components/trunk/maven-project/src/test/java/org/apache/maven/profiles/activation/SystemPropertyProfileActivatorTest.java
    maven/components/trunk/maven-project/src/test/java/org/apache/maven/project/build/model/AbstractModelLineageTest.java
    maven/components/trunk/maven-project/src/test/resources/org/apache/maven/project/ProjectClasspathTest.xml
    maven/components/trunk/maven-project/src/test/resources/org/apache/maven/project/canonical/CanonicalProjectBuilderTest.xml
    maven/components/trunk/pom.xml

Added: maven/components/trunk/maven-build-context/pom.xml
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-build-context/pom.xml?view=auto&rev=497911
==============================================================================
--- maven/components/trunk/maven-build-context/pom.xml (added)
+++ maven/components/trunk/maven-build-context/pom.xml Fri Jan 19 11:15:18 2007
@@ -0,0 +1,25 @@
+<?xml version="1.0"?><project>
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <artifactId>maven</artifactId>
+    <groupId>org.apache.maven</groupId>
+    <version>2.1-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>maven-build-context</artifactId>
+  <name>Maven Build Context</name>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-container-default</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+</project>

Propchange: maven/components/trunk/maven-build-context/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-build-context/pom.xml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: 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=auto&rev=497911
==============================================================================
--- maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/BuildContext.java (added)
+++ maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/BuildContext.java Fri Jan 19 11:15:18 2007
@@ -0,0 +1,34 @@
+package org.apache.maven.context;
+
+/**
+ * Basic data bus for Maven builds, through which the various subsystems can communicate with one
+ * another without causing bloat in the APIs.
+ * 
+ * @author jdcasey
+ *
+ */
+public interface BuildContext
+{
+
+    /**
+     * Add a new piece of data to the build context.
+     */
+    void put( Object key, Object value );
+    
+    /**
+     * Retrieve something previously stored in the build context, or null if the key doesn't exist.
+     */
+    Object get( Object key );
+    
+    /**
+     * Remove a mapped data element from the build context, returning the Object removed, if any.
+     */
+    Object delete( Object key );
+    
+    /**
+     * Add a new piece of managed build data to the build context. Managed data elements supply their
+     * own storage key.
+     */
+    void put( ManagedBuildData managedData );
+    
+}

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

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

Added: maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/BuildContextManager.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/BuildContextManager.java?view=auto&rev=497911
==============================================================================
--- maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/BuildContextManager.java (added)
+++ maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/BuildContextManager.java Fri Jan 19 11:15:18 2007
@@ -0,0 +1,34 @@
+package org.apache.maven.context;
+
+/**
+ * Manager interface used to store, read, and clear the BuildContext out of the container.
+ * 
+ * @author jdcasey
+ */
+public interface BuildContextManager
+{
+    
+    String ROLE = BuildContextManager.class.getName();
+    
+    /**
+     * Create a new instance of BuildContext
+     */
+    BuildContext newUnstoredInstance();
+    
+    /**
+     * Read the BuildContext from the container. If it doesn't already exist, optionally create it.
+     */
+    BuildContext readBuildContext( boolean create );
+    
+    /**
+     * Store the BuildContext in the container context.
+     */
+    void storeBuildContext( BuildContext context );
+    
+    /**
+     * Clear the contents of the BuildContext, both in the current instance, and in the container
+     * context.
+     */
+    void clearBuildContext();
+    
+}

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

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

Added: 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=auto&rev=497911
==============================================================================
--- maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/DefaultBuildContext.java (added)
+++ maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/DefaultBuildContext.java Fri Jan 19 11:15:18 2007
@@ -0,0 +1,85 @@
+package org.apache.maven.context;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * Default implementation of BuildContext, for use with the DefaultBuildContextManager. This 
+ * implementation uses a Map for its backing store, and if constructed with no parameters, will use
+ * a LinkedHashMap.
+ * 
+ * @author jdcasey
+ *
+ */
+public class DefaultBuildContext
+    implements BuildContext
+{
+    
+    private final Map contextMap;
+
+    /**
+     * Construct a new build context, using the supplied map as the backing store. NOTE: The 
+     * supplied map will be copied.
+     */
+    public DefaultBuildContext( Map contextMap )
+    {
+        if ( contextMap == null )
+        {
+            throw new NullPointerException( "DefaultBuildContext requires a non-null contextMap parameter, or no parameter at all." );
+        }
+        
+        this.contextMap = contextMap;
+    }
+    
+    /**
+     * Construct a new build context, using a new instance of LinkedHashMap.
+     */
+    public DefaultBuildContext()
+    {
+        this.contextMap = new LinkedHashMap();
+    }
+
+    /**
+     * Remove the object mapped to 'key' from the build context. If there was such a mapping, return
+     * the value mapped to the key.
+     */
+    public Object delete( Object key )
+    {
+        return contextMap.remove( key );
+    }
+
+    /**
+     * Retrieve the object mapped to 'key', or null if the mapping doesn't exist. Mapping 'key' to
+     * null should also be possible, but will be indistinguishable from a missing mapping.
+     */
+    public Object get( Object key )
+    {
+        return contextMap.get( key );
+    }
+
+    /**
+     * Add a new data mapping to the build context.
+     */
+    public void put( Object key, Object value )
+    {
+        contextMap.put( key, value );
+    }
+
+    /**
+     * Return the Map used to store data elements, for storage by the DefaultBuildContextManager.
+     */
+    Object getContextMap()
+    {
+        return contextMap;
+    }
+
+    /**
+     * Add a new piece of managed data to the build context, using the key supplied by 
+     * managedData.getStorageKey().
+     */
+    public void put( ManagedBuildData managedData )
+    {
+        contextMap.put( managedData.getStorageKey(), managedData );
+    }
+
+}

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

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

Added: 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=auto&rev=497911
==============================================================================
--- maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/DefaultBuildContextManager.java (added)
+++ maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/DefaultBuildContextManager.java Fri Jan 19 11:15:18 2007
@@ -0,0 +1,121 @@
+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;
+
+/**
+ * Default implementation of the BuildContextManager, which handles instances of DefaultBuildContext.
+ * 
+ * @plexus.component role="org.apache.maven.context.BuildContextManager" role-hint="default"
+ * @author jdcasey
+ */
+public class DefaultBuildContextManager
+    implements BuildContextManager, Contextualizable
+{
+    public static final String ROLE_HINT = "default";
+    
+    protected static final String BUILD_CONTEXT_MAP_KEY = "org.apache.maven.context:DefaultBuildContextManager:contextMap";
+    
+    private Context context;
+    
+    /**
+     * Create a new instance of DefaultBuildContext, and return it. Each method call creates a brand
+     * new instance.
+     */
+    public BuildContext newUnstoredInstance()
+    {
+        return new DefaultBuildContext();
+    }
+
+    /**
+     * Clear the contents of the build context inside the container context.
+     */
+    public void clearBuildContext()
+    {
+        clearContextContainerMap();
+    }
+
+    /**
+     * Retrieve the current BuildContext out of the container context.
+     * 
+     * @param create Whether to create the BuildContext if it doesn't exist in the container
+     */
+    public BuildContext readBuildContext( boolean create )
+    {
+        Map contextMap = getContextContainerMap( create );
+        
+        if ( !create && contextMap == null )
+        {
+            return null;
+        }
+        else
+        {
+            return new DefaultBuildContext( contextMap );
+        }
+    }
+
+    /**
+     * Store the given BuildContext inside the container.
+     */
+    public void storeBuildContext( BuildContext context )
+    {
+        if ( context instanceof DefaultBuildContext )
+        {
+            this.context.put( BUILD_CONTEXT_MAP_KEY, ((DefaultBuildContext)context).getContextMap() );
+        }
+        else
+        {
+            throw new IllegalArgumentException( this.getClass().getName() + " does not know how to store a context of type: " + context.getClass().getName() );
+        }
+    }
+
+    protected Map getContextContainerMap( boolean create )
+    {
+        Map containerMap = null;
+
+        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 )
+        {
+            containerMap = new HashMap();
+            context.put( BUILD_CONTEXT_MAP_KEY, containerMap );
+        }
+
+        return containerMap;
+    }
+
+    protected void clearContextContainerMap()
+    {
+        Map containerMap = getContextContainerMap( false );
+
+        if ( containerMap != null )
+        {
+            containerMap.clear();
+        }
+    }
+
+    /**
+     * Retrieve the container context for storing the BuildContext data.
+     */
+    public void contextualize( Context context )
+        throws ContextException
+    {
+        this.context = context;
+    }
+
+}

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

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

Added: 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=auto&rev=497911
==============================================================================
--- maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/ManagedBuildData.java (added)
+++ maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/ManagedBuildData.java Fri Jan 19 11:15:18 2007
@@ -0,0 +1,21 @@
+package org.apache.maven.context;
+
+/**
+ * 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.
+ * 
+ * @author jdcasey
+ *
+ */
+public interface ManagedBuildData
+{
+    
+    /**
+     * Retrieve the context key under which this instance of managed data should be stored in the
+     * BuildContext instance.
+     * 
+     * @return The BuildContext mapping key.
+     */
+    String getStorageKey();
+
+}

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

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

Added: 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=auto&rev=497911
==============================================================================
--- maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/SystemBuildContext.java (added)
+++ maven/components/trunk/maven-build-context/src/main/java/org/apache/maven/context/SystemBuildContext.java Fri Jan 19 11:15:18 2007
@@ -0,0 +1,76 @@
+package org.apache.maven.context;
+
+import java.util.Properties;
+
+public class SystemBuildContext
+    implements ManagedBuildData
+{
+    
+    public static final String BUILD_CONTEXT_KEY = SystemBuildContext.class.getName();
+    
+    private Properties systemProperties;
+    private Properties envars;
+    
+    public SystemBuildContext()
+    {
+        this.systemProperties = System.getProperties();
+    }
+    
+    public void setEnvironmentVariables( Properties envars )
+    {
+        this.envars = envars;
+    }
+    
+    public Properties getEnvironmentVariables()
+    {
+        return envars;
+    }
+    
+    public void setSystemProperties( Properties systemProperties )
+    {
+        this.systemProperties = systemProperties;
+    }
+    
+    public Properties getSystemProperties()
+    {
+        return systemProperties;
+    }
+    
+    public String getSystemProperty( String name )
+    {
+        return systemProperties == null ? null : systemProperties.getProperty( name );
+    }
+
+    public String getStorageKey()
+    {
+        return BUILD_CONTEXT_KEY;
+    }
+
+    public static SystemBuildContext getSystemBuildContext( BuildContextManager buildContextManager, boolean create )
+    {
+        BuildContext buildContext = buildContextManager.readBuildContext( false );
+        
+        SystemBuildContext systemContext = null;
+        
+        if ( buildContext != null )
+        {
+            systemContext = (SystemBuildContext) buildContext.get( BUILD_CONTEXT_KEY );
+        }
+        
+        if ( create && systemContext == null )
+        {
+            systemContext = new SystemBuildContext();
+        }
+        
+        return systemContext;
+    }
+    
+    public void store( BuildContextManager buildContextManager )
+    {
+        BuildContext buildContext = buildContextManager.readBuildContext( true );
+        
+        buildContext.put( this );
+        
+        buildContextManager.storeBuildContext( buildContext );
+    }
+}

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

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

Added: maven/components/trunk/maven-build-context/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-build-context/src/main/resources/META-INF/plexus/components.xml?view=auto&rev=497911
==============================================================================
--- maven/components/trunk/maven-build-context/src/main/resources/META-INF/plexus/components.xml (added)
+++ maven/components/trunk/maven-build-context/src/main/resources/META-INF/plexus/components.xml Fri Jan 19 11:15:18 2007
@@ -0,0 +1,9 @@
+<component-set>
+  <components>
+    <component>
+      <role>org.apache.maven.context.BuildContextManager</role>
+      <role-hint>default</role-hint>
+      <implementation>org.apache.maven.context.DefaultBuildContextManager</implementation>
+    </component>
+  </components>
+</component-set>
\ No newline at end of file

Propchange: maven/components/trunk/maven-build-context/src/main/resources/META-INF/plexus/components.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-build-context/src/main/resources/META-INF/plexus/components.xml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: 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=auto&rev=497911
==============================================================================
--- maven/components/trunk/maven-build-context/src/test/java/org/apache/maven/context/AbstractBuildContextManagerTest.java (added)
+++ maven/components/trunk/maven-build-context/src/test/java/org/apache/maven/context/AbstractBuildContextManagerTest.java Fri Jan 19 11:15:18 2007
@@ -0,0 +1,93 @@
+package org.apache.maven.context;
+
+import org.codehaus.plexus.PlexusTestCase;
+
+public abstract class AbstractBuildContextManagerTest
+    extends PlexusTestCase
+{
+    private BuildContextManager mgr;
+    
+    protected abstract String getRoleHintBeforeSetUp();
+    
+    protected BuildContextManager getBuildContextManager()
+    {
+        return mgr;
+    }
+    
+    public void setUp() throws Exception
+    {
+        super.setUp();
+        
+        mgr = (BuildContextManager) lookup( BuildContextManager.ROLE, getRoleHintBeforeSetUp() );
+    }
+    
+    public void testNewUnstoredInstance_ShouldReturnValidContextInstance()
+    {
+        BuildContext context = mgr.newUnstoredInstance();
+        
+        assertNotNull( context );
+        
+        String key = "key";
+        String value = "value";
+        
+        context.put( key, value );
+        
+        assertEquals( value, context.get( key ) );
+        
+        context.delete( key );
+        
+        assertNull( context.get( key ) );
+    }
+
+    public void testNewUnstoredInstance_SuccessiveCallsShouldReturnDistinctContextInstances()
+    {
+        BuildContext context = mgr.newUnstoredInstance();
+        BuildContext context2 = mgr.newUnstoredInstance();
+        
+        assertNotNull( context );
+        assertNotNull( context2 );
+        assertNotSame( context, context2 );
+    }
+    
+    public void testStoreAndRead_ShouldRetrieveStoredValueAfterRead()
+    {
+        BuildContext ctx = mgr.newUnstoredInstance();
+        
+        String key = "key";
+        String value = "value";
+        
+        ctx.put( key, value );
+        
+        mgr.storeBuildContext( ctx );
+        
+        BuildContext ctx2 = mgr.readBuildContext( false );
+        
+        assertNotNull( ctx2 );
+        assertEquals( value, ctx2.get( key ) );
+    }
+
+    public void testStoreAndClear_ShouldNotRetrieveStoredValueAfterClear()
+    {
+        BuildContext ctx = mgr.newUnstoredInstance();
+        
+        String key = "key";
+        String value = "value";
+        
+        ctx.put( key, value );
+        
+        mgr.storeBuildContext( ctx );
+        
+        // verify that we can get the value back out.
+        BuildContext ctx2 = mgr.readBuildContext( false );
+        
+        assertNotNull( ctx2 );
+        assertEquals( value, ctx2.get( key ) );
+        
+        mgr.clearBuildContext();
+        
+        BuildContext ctx3 = mgr.readBuildContext( false );
+        
+        assertNull( ctx3.get( key ) );
+    }
+
+}

Propchange: maven/components/trunk/maven-build-context/src/test/java/org/apache/maven/context/AbstractBuildContextManagerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-build-context/src/test/java/org/apache/maven/context/AbstractBuildContextManagerTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/components/trunk/maven-build-context/src/test/java/org/apache/maven/context/AbstractBuildContextTest.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-build-context/src/test/java/org/apache/maven/context/AbstractBuildContextTest.java?view=auto&rev=497911
==============================================================================
--- maven/components/trunk/maven-build-context/src/test/java/org/apache/maven/context/AbstractBuildContextTest.java (added)
+++ maven/components/trunk/maven-build-context/src/test/java/org/apache/maven/context/AbstractBuildContextTest.java Fri Jan 19 11:15:18 2007
@@ -0,0 +1,61 @@
+package org.apache.maven.context;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+public abstract class AbstractBuildContextTest
+    extends TestCase
+{
+    
+    protected abstract BuildContext newContext();
+
+    public void testPutAndGet_ShouldStoreAndRetrieveKeyValuePairOfStrings()
+    {
+        BuildContext ctx = newContext();
+        
+        String key = "key";
+        String value = "value";
+        
+        ctx.put( key, value );
+        
+        assertEquals( value, ctx.get( key ) );
+    }
+    
+    public void testPutAndGet_ShouldStoreAndRetrieveStringKeyWithMapValue()
+    {
+        BuildContext ctx = newContext();
+        
+        String key = "key";
+        Map value = new HashMap();
+        
+        String key2 = "key2";
+        String value2 = "value";
+        
+        value.put( key2, value2 );
+        
+        ctx.put( key, value );
+        
+        assertSame( value, ctx.get( key ) );
+        
+        assertEquals( value2, ((Map) ctx.get( key )).get( key2 ) );
+    }
+    
+    public void testPutDeleteAndGet_ShouldStoreKeyValuePairDeleteThemAndRetrieveNull()
+    {
+        BuildContext ctx = newContext();
+        
+        String key = "key";
+        String value = "value";
+        
+        ctx.put( key, value );
+        
+        assertEquals( value, ctx.get( key ) );
+        
+        ctx.delete( key );
+        
+        assertNull( ctx.get( key ) );
+    }
+    
+}

Propchange: maven/components/trunk/maven-build-context/src/test/java/org/apache/maven/context/AbstractBuildContextTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-build-context/src/test/java/org/apache/maven/context/AbstractBuildContextTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/components/trunk/maven-build-context/src/test/java/org/apache/maven/context/DefaultBuildContextManagerTest.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-build-context/src/test/java/org/apache/maven/context/DefaultBuildContextManagerTest.java?view=auto&rev=497911
==============================================================================
--- maven/components/trunk/maven-build-context/src/test/java/org/apache/maven/context/DefaultBuildContextManagerTest.java (added)
+++ maven/components/trunk/maven-build-context/src/test/java/org/apache/maven/context/DefaultBuildContextManagerTest.java Fri Jan 19 11:15:18 2007
@@ -0,0 +1,12 @@
+package org.apache.maven.context;
+
+public class DefaultBuildContextManagerTest
+    extends AbstractBuildContextManagerTest
+{
+
+    protected String getRoleHintBeforeSetUp()
+    {
+        return DefaultBuildContextManager.ROLE_HINT;
+    }
+
+}

Propchange: maven/components/trunk/maven-build-context/src/test/java/org/apache/maven/context/DefaultBuildContextManagerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-build-context/src/test/java/org/apache/maven/context/DefaultBuildContextManagerTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/components/trunk/maven-build-context/src/test/java/org/apache/maven/context/DefaultBuildContextTest.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-build-context/src/test/java/org/apache/maven/context/DefaultBuildContextTest.java?view=auto&rev=497911
==============================================================================
--- maven/components/trunk/maven-build-context/src/test/java/org/apache/maven/context/DefaultBuildContextTest.java (added)
+++ maven/components/trunk/maven-build-context/src/test/java/org/apache/maven/context/DefaultBuildContextTest.java Fri Jan 19 11:15:18 2007
@@ -0,0 +1,40 @@
+package org.apache.maven.context;
+
+import java.util.Collections;
+import java.util.Map;
+
+public class DefaultBuildContextTest
+    extends AbstractBuildContextTest
+{
+
+    protected BuildContext newContext()
+    {
+        return new DefaultBuildContext();
+    }
+    
+    public void testConstructor_ShouldThrowNPEWhenContextMapParameterIsNull()
+    {
+        try
+        {
+            new DefaultBuildContext( null );
+            
+            fail( "Should throw NPE when contextMap parameter is null." );
+        }
+        catch( NullPointerException e )
+        {
+            // should happen.
+        }
+    }
+
+    public void testConstructor_ShouldRetrieveValueFromPreExistingContextMap()
+    {
+        String key = "key";
+        String value = "value";
+        
+        Map contextMap = Collections.singletonMap( key, value );
+        BuildContext ctx = new DefaultBuildContext( contextMap );
+        
+        assertEquals( value, ctx.get( key ) );
+    }
+
+}

Propchange: maven/components/trunk/maven-build-context/src/test/java/org/apache/maven/context/DefaultBuildContextTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-build-context/src/test/java/org/apache/maven/context/DefaultBuildContextTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Modified: maven/components/trunk/maven-core/pom.xml
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/pom.xml?view=diff&rev=497911&r1=497910&r2=497911
==============================================================================
--- maven/components/trunk/maven-core/pom.xml (original)
+++ maven/components/trunk/maven-core/pom.xml Fri Jan 19 11:15:18 2007
@@ -29,6 +29,11 @@
   <dependencies>
     <dependency>
       <groupId>org.apache.maven</groupId>
+      <artifactId>maven-build-context</artifactId>
+      <version>2.1-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
       <artifactId>maven-settings</artifactId>
       <version>2.1-SNAPSHOT</version>
     </dependency>

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=497911&r1=497910&r2=497911
==============================================================================
--- 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 Fri Jan 19 11:15:18 2007
@@ -20,8 +20,11 @@
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.artifact.resolver.ArtifactResolutionException;
 import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
+import org.apache.maven.context.BuildContextManager;
+import org.apache.maven.context.SystemBuildContext;
 import org.apache.maven.execution.BuildFailure;
 import org.apache.maven.execution.DefaultMavenExecutionResult;
+import org.apache.maven.execution.ExecutionBuildContext;
 import org.apache.maven.execution.MavenExecutionRequest;
 import org.apache.maven.execution.MavenExecutionResult;
 import org.apache.maven.execution.MavenSession;
@@ -74,6 +77,8 @@
     // Components
     // ----------------------------------------------------------------------
 
+    protected BuildContextManager buildContextManager;
+    
     protected MavenProjectBuilder projectBuilder;
 
     protected LifecycleExecutor lifecycleExecutor;
@@ -97,6 +102,8 @@
     public MavenExecutionResult execute( MavenExecutionRequest request )
     {
         request.setStartTime( new Date() );
+        
+        initializeBuildContext( request );
 
         EventDispatcher dispatcher = new DefaultEventDispatcher( request.getEventMonitors() );
 
@@ -166,6 +173,21 @@
         return new DefaultMavenExecutionResult( result.getReactorManager() );
     }
 
+    /**
+     * Initialize some context objects to be stored in the container's context map for reference by
+     * other Maven components (including custom components that need more information about the 
+     * build than is supplied to them by the APIs).
+     */
+    private void initializeBuildContext( MavenExecutionRequest request )
+    {
+        new ExecutionBuildContext( request ).store( buildContextManager );
+        
+        SystemBuildContext systemContext = SystemBuildContext.getSystemBuildContext( buildContextManager, true );
+        
+        systemContext.setSystemProperties( request.getProperties() );
+        systemContext.store( buildContextManager );
+    }
+
     private void logErrors( ReactorManager rm,
                             boolean showErrors )
     {
@@ -304,17 +326,22 @@
         throws MavenExecutionException, BuildFailureException
     {
         List projects;
+        
+        List files;
         try
         {
-            List files = getProjectFiles( request );
-
-            projects = collectProjects( files, request.getLocalRepository(), request.isRecursive(),
-                                        request.getSettings(), globalProfileManager, !request.useReactor() );
-
+            files = getProjectFiles( request );
         }
         catch ( IOException e )
         {
-            throw new MavenExecutionException( "Error processing projects for the reactor: " + e.getMessage(), e );
+            throw new MavenExecutionException( "Error selecting project files for the reactor: " + e.getMessage(), e );
+        }
+        
+        try
+        {
+            projects = collectProjects( files, request.getLocalRepository(), request.isRecursive(),
+                                        request.getSettings(), globalProfileManager, !request.useReactor() );
+
         }
         catch ( ArtifactResolutionException e )
         {

Added: 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=auto&rev=497911
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/ExecutionBuildContext.java (added)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/ExecutionBuildContext.java Fri Jan 19 11:15:18 2007
@@ -0,0 +1,216 @@
+package org.apache.maven.execution;
+
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.context.BuildContext;
+import org.apache.maven.context.BuildContextManager;
+import org.apache.maven.context.ManagedBuildData;
+import org.apache.maven.settings.Settings;
+import org.apache.maven.wagon.events.TransferListener;
+
+import java.io.File;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+import java.util.Properties;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Build context object that supplies information about how Maven was invoked, including all of the
+ * information available in the MavenExecutionRequest (in read-only form).
+ */
+public class ExecutionBuildContext
+    implements ManagedBuildData
+{
+    
+    public static final String BUILD_CONTEXT_KEY = ExecutionBuildContext.class.getName();
+    
+    private final MavenExecutionRequest request;
+
+    public ExecutionBuildContext( MavenExecutionRequest request )
+    {
+        this.request = request;
+    }
+
+    public List getActiveProfiles()
+    {
+        return Collections.unmodifiableList( request.getActiveProfiles() );
+    }
+
+    public String getBaseDirectory()
+    {
+        return request.getBaseDirectory();
+    }
+
+    public String getGlobalChecksumPolicy()
+    {
+        return request.getGlobalChecksumPolicy();
+    }
+
+    public List getGoals()
+    {
+        return Collections.unmodifiableList( request.getGoals() );
+    }
+
+    public List getInactiveProfiles()
+    {
+        return Collections.unmodifiableList( request.getInactiveProfiles() );
+    }
+
+    public ArtifactRepository getLocalRepository()
+    {
+        return request.getLocalRepository();
+    }
+
+    public File getLocalRepositoryPath()
+    {
+        return request.getLocalRepositoryPath();
+    }
+
+    public int getLoggingLevel()
+    {
+        return request.getLoggingLevel();
+    }
+
+    public List getMirrors()
+    {
+        return Collections.unmodifiableList( request.getMirrors() );
+    }
+
+    public List getPluginGroups()
+    {
+        return Collections.unmodifiableList( request.getPluginGroups() );
+    }
+
+    public String getPomFile()
+    {
+        return request.getPomFile();
+    }
+
+    public List getProfiles()
+    {
+        return Collections.unmodifiableList( request.getProfiles() );
+    }
+
+    public Properties getProperties()
+    {
+        return new Properties( request.getProperties() );
+    }
+
+    public List getProxies()
+    {
+        return Collections.unmodifiableList( request.getProxies() );
+    }
+
+    public String getReactorFailureBehavior()
+    {
+        return request.getReactorFailureBehavior();
+    }
+
+    public List getServers()
+    {
+        return Collections.unmodifiableList( request.getServers() );
+    }
+
+    public Settings getSettings()
+    {
+        return request.getSettings();
+    }
+
+    public String getSettingsFile()
+    {
+        return request.getSettingsFile();
+    }
+
+    public Date getStartTime()
+    {
+        return request.getStartTime();
+    }
+
+    public TransferListener getTransferListener()
+    {
+        return request.getTransferListener();
+    }
+
+    public boolean isInteractiveMode()
+    {
+        return request.isInteractiveMode();
+    }
+
+    public boolean isNoSnapshotUpdates()
+    {
+        return request.isNoSnapshotUpdates();
+    }
+
+    public boolean isOffline()
+    {
+        return request.isOffline();
+    }
+
+    public boolean isRecursive()
+    {
+        return request.isRecursive();
+    }
+
+    public boolean isShowErrors()
+    {
+        return request.isShowErrors();
+    }
+
+    public boolean isUpdateSnapshots()
+    {
+        return request.isUpdateSnapshots();
+    }
+
+    public boolean isUsePluginRegistry()
+    {
+        return request.isUsePluginRegistry();
+    }
+
+    public boolean isUsePluginUpdateOverride()
+    {
+        return request.isUsePluginUpdateOverride();
+    }
+
+    public String getStorageKey()
+    {
+        return BUILD_CONTEXT_KEY;
+    }
+
+    public static ExecutionBuildContext readExecutionBuildContext( BuildContextManager buildContextManager )
+    {
+        BuildContext buildContext = buildContextManager.readBuildContext( false );
+        
+        ExecutionBuildContext executionContext = null;
+        
+        if ( buildContext != null )
+        {
+            executionContext = (ExecutionBuildContext) buildContext.get( BUILD_CONTEXT_KEY );
+        }
+        
+        return executionContext;
+    }
+    
+    public void store( BuildContextManager buildContextManager )
+    {
+        BuildContext buildContext = buildContextManager.readBuildContext( true );
+        
+        buildContext.put( this );
+        
+        buildContextManager.storeBuildContext( buildContext );
+    }
+}

Propchange: maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/ExecutionBuildContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

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=497911&r1=497910&r2=497911
==============================================================================
--- 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 Fri Jan 19 11:15:18 2007
@@ -81,6 +81,10 @@
       <implementation>org.apache.maven.DefaultMaven</implementation>
       <requirements>
         <requirement>
+          <role>org.apache.maven.context.BuildContextManager</role>
+          <role-hint>default</role-hint>
+        </requirement>
+        <requirement>
           <role>org.apache.maven.project.MavenProjectBuilder</role>
         </requirement>
         <requirement>

Modified: maven/components/trunk/maven-model/maven.mdo
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-model/maven.mdo?view=diff&rev=497911&r1=497910&r2=497911
==============================================================================
--- maven/components/trunk/maven-model/maven.mdo (original)
+++ maven/components/trunk/maven-model/maven.mdo Fri Jan 19 11:15:18 2007
@@ -2629,6 +2629,16 @@
             <type>ActivationFile</type>
           </association>
         </field>
+        <field>
+          <name>custom</name>
+          <version>4.0.0</version>
+          <description>
+            Describes a custom profile activation trigger, brought in via build extension.
+          </description>
+          <association>
+            <type>ActivationCustom</type>
+          </association>
+        </field>
       </fields>
     </class>
     <class>
@@ -2711,6 +2721,32 @@
           <version>4.0.0</version>
           <type>String</type>
           <description>The name of the file that must exist to activate the profile.</description>
+        </field>
+      </fields>
+    </class>
+    <class>
+      <name>ActivationCustom</name>
+      <version>4.0.0</version>
+      <description><![CDATA[
+        This activation allows users to specify their own custom trigger for a profile.
+      ]]></description>
+      <fields>
+        <field>
+          <name>configuration</name>
+          <version>4.0.0</version>
+          <type>DOM</type>
+          <description><![CDATA[
+            The specification for triggering the profile according to the rules of the custom
+            activation type.
+          ]]></description>
+        </field>
+        <field>
+          <name>type</name>
+          <version>4.0.0</version>
+          <type>String</type>
+          <description><![CDATA[
+            The type (role-hint) of activation which is to be used to activate the profile.
+          ]]></description>
         </field>
       </fields>
     </class>

Modified: maven/components/trunk/maven-project/pom.xml
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/pom.xml?view=diff&rev=497911&r1=497910&r2=497911
==============================================================================
--- maven/components/trunk/maven-project/pom.xml (original)
+++ maven/components/trunk/maven-project/pom.xml Fri Jan 19 11:15:18 2007
@@ -31,6 +31,11 @@
   <dependencies>
     <dependency>
       <groupId>org.apache.maven</groupId>
+      <artifactId>maven-build-context</artifactId>
+      <version>2.1-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
       <artifactId>maven-artifact-test</artifactId>
       <version>2.1-SNAPSHOT</version>
       <scope>test</scope>

Added: maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/CustomActivator.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/CustomActivator.java?view=auto&rev=497911
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/CustomActivator.java (added)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/CustomActivator.java Fri Jan 19 11:15:18 2007
@@ -0,0 +1,137 @@
+package org.apache.maven.profiles.activation;
+
+import org.apache.maven.model.Activation;
+import org.apache.maven.model.ActivationCustom;
+import org.apache.maven.model.Profile;
+import org.codehaus.plexus.PlexusConstants;
+import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.component.configurator.BasicComponentConfigurator;
+import org.codehaus.plexus.component.configurator.ComponentConfigurationException;
+import org.codehaus.plexus.component.configurator.ComponentConfigurator;
+import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
+import org.codehaus.plexus.configuration.PlexusConfiguration;
+import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration;
+import org.codehaus.plexus.context.Context;
+import org.codehaus.plexus.context.ContextException;
+import org.codehaus.plexus.logging.LogEnabled;
+import org.codehaus.plexus.logging.Logger;
+import org.codehaus.plexus.logging.console.ConsoleLogger;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
+import org.codehaus.plexus.util.xml.Xpp3Dom;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Profile activator that allows the use of custom third-party activators, by specifying a type - 
+ * or role-hint - for the activator, along with a configuration (in the form of a DOM) to be used
+ * in configuring the activator. This activator will lookup/configure custom activators on-the-fly,
+ * without caching any of the lookups from the container.
+ */
+public class CustomActivator
+    implements ProfileActivator, Contextualizable, LogEnabled
+{
+
+    private PlexusContainer container;
+
+    private Logger logger;
+
+    public boolean canDetermineActivation( Profile profile )
+    {
+        Activation activation = profile.getActivation();
+
+        if ( activation != null )
+        {
+            ActivationCustom custom = activation.getCustom();
+
+            if ( custom != null )
+            {
+                ProfileActivator activator = loadProfileActivator( custom );
+
+                return activator.canDetermineActivation( profile );
+            }
+        }
+
+        return false;
+    }
+
+    private ProfileActivator loadProfileActivator( ActivationCustom custom )
+    {
+        String type = custom.getType();
+
+        ProfileActivator activator;
+        try
+        {
+            activator = (ProfileActivator) container.lookup( ProfileActivator.ROLE, type );
+        }
+        catch ( ComponentLookupException e )
+        {
+            getLogger().debug( "Failed to lookup ProfileActivator \'" + type + "\'", e );
+
+            throw new IllegalArgumentException( "Cannot find ProfileActivator with role-hint: " + type
+                + ". \nPerhaps you're missing a build extension? \nSee debug output for more information." );
+        }
+
+        PlexusConfiguration configuration = new XmlPlexusConfiguration( (Xpp3Dom) custom.getConfiguration() );
+
+        ComponentConfigurator configurator = new BasicComponentConfigurator();
+
+        try
+        {
+            configurator.configureComponent( activator, configuration, container.getContainerRealm() );
+        }
+        catch ( ComponentConfigurationException e )
+        {
+            getLogger().debug( "Failed to configure ProfileActivator \'" + type + "\'", e );
+
+            throw new IllegalArgumentException( "Failed to configure ProfileActivator with role-hint: " + type
+                + ". Turn on debug mode for more information." );
+        }
+
+        return activator;
+    }
+
+    public boolean isActive( Profile profile )
+    {
+        ActivationCustom custom = profile.getActivation().getCustom();
+
+        ProfileActivator activator = loadProfileActivator( custom );
+
+        return activator.isActive( profile );
+    }
+
+    public void contextualize( Context context )
+        throws ContextException
+    {
+        this.container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
+    }
+
+    private Logger getLogger()
+    {
+        if ( logger == null )
+        {
+            logger = new ConsoleLogger( Logger.LEVEL_DEBUG, "CustomActivator-instantiated" );
+        }
+
+        return logger;
+    }
+
+    public void enableLogging( Logger logger )
+    {
+        this.logger = logger;
+    }
+
+}

Propchange: maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/CustomActivator.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Added: maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/CustomActivatorExpressionEvaluator.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/CustomActivatorExpressionEvaluator.java?view=auto&rev=497911
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/CustomActivatorExpressionEvaluator.java (added)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/CustomActivatorExpressionEvaluator.java Fri Jan 19 11:15:18 2007
@@ -0,0 +1,25 @@
+package org.apache.maven.profiles.activation;
+
+import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
+import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator;
+
+import java.io.File;
+
+public class CustomActivatorExpressionEvaluator
+    implements ExpressionEvaluator
+{
+
+    public File alignToBaseDirectory( File file )
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public Object evaluate( String expression )
+        throws ExpressionEvaluationException
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+}

Propchange: maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/CustomActivatorExpressionEvaluator.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/DetectedProfileActivator.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/DetectedProfileActivator.java?view=diff&rev=497911&r1=497910&r2=497911
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/DetectedProfileActivator.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/DetectedProfileActivator.java Fri Jan 19 11:15:18 2007
@@ -1,5 +1,6 @@
 package org.apache.maven.profiles.activation;
 
+import org.apache.maven.context.BuildContextManager;
 import org.apache.maven.model.Profile;
 
 /*
@@ -21,11 +22,18 @@
 public abstract class DetectedProfileActivator
     implements ProfileActivator
 {
+    private BuildContextManager buildContextManager;
+
     public boolean canDetermineActivation( Profile profile )
     {
         return canDetectActivation( profile );
     }
 
     protected abstract boolean canDetectActivation( Profile profile );
+    
+    protected BuildContextManager getBuildContextManager()
+    {
+        return buildContextManager;
+    }
 
 }

Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/FileProfileActivator.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/FileProfileActivator.java?view=diff&rev=497911&r1=497910&r2=497911
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/FileProfileActivator.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/FileProfileActivator.java Fri Jan 19 11:15:18 2007
@@ -22,13 +22,14 @@
  */
 
 public class FileProfileActivator
-    extends DetectedProfileActivator
+    implements ProfileActivator
 {
-    protected boolean canDetectActivation( Profile profile )
+    
+    public boolean canDetermineActivation( Profile profile )
     {
         return profile.getActivation() != null && profile.getActivation().getFile() != null;
     }
-
+    
     public boolean isActive( Profile profile )
     {
         Activation activation = profile.getActivation();
@@ -56,4 +57,5 @@
 
         return false;
     }
+
 }

Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/JdkPrefixProfileActivator.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/JdkPrefixProfileActivator.java?view=diff&rev=497911&r1=497910&r2=497911
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/JdkPrefixProfileActivator.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/JdkPrefixProfileActivator.java Fri Jan 19 11:15:18 2007
@@ -1,5 +1,6 @@
 package org.apache.maven.profiles.activation;
 
+import org.apache.maven.context.SystemBuildContext;
 import org.apache.maven.model.Activation;
 import org.apache.maven.model.Profile;
 import org.codehaus.plexus.util.StringUtils;
@@ -23,7 +24,8 @@
 public class JdkPrefixProfileActivator
     extends DetectedProfileActivator
 {
-    private static final String JDK_VERSION = System.getProperty( "java.version" );
+    
+    public static final String JDK_VERSION = "java.version";
 
     public boolean isActive( Profile profile )
     {
@@ -38,9 +40,12 @@
             reverse = true;
             jdk = jdk.substring( 1 );
         }
+        
+        SystemBuildContext systemContext = SystemBuildContext.getSystemBuildContext( getBuildContextManager(), true );
+        String javaVersion = systemContext.getSystemProperty( JDK_VERSION );
 
         // null case is covered by canDetermineActivation(), so we can do a straight startsWith() here.
-        boolean result = JDK_VERSION.startsWith( jdk );
+        boolean result = javaVersion.startsWith( jdk );
         
         if ( reverse )
         {

Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/SystemPropertyProfileActivator.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/SystemPropertyProfileActivator.java?view=diff&rev=497911&r1=497910&r2=497911
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/SystemPropertyProfileActivator.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/activation/SystemPropertyProfileActivator.java Fri Jan 19 11:15:18 2007
@@ -1,15 +1,12 @@
 package org.apache.maven.profiles.activation;
 
-import java.util.Properties;
+import org.apache.maven.context.SystemBuildContext;
 import org.apache.maven.model.Activation;
 import org.apache.maven.model.ActivationProperty;
 import org.apache.maven.model.Profile;
-import org.codehaus.plexus.context.Context;
-import org.codehaus.plexus.context.ContextException;
 import org.codehaus.plexus.logging.LogEnabled;
 import org.codehaus.plexus.logging.Logger;
 import org.codehaus.plexus.logging.console.ConsoleLogger;
-import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
 import org.codehaus.plexus.util.StringUtils;
 
 /*
@@ -29,16 +26,11 @@
  */
 
 public class SystemPropertyProfileActivator
-    extends DetectedProfileActivator implements Contextualizable, LogEnabled
+    extends DetectedProfileActivator 
+    implements LogEnabled
 {
-    private Context context;
     private Logger logger;
     
-    public void contextualize(Context context) throws ContextException 
-    {
-        this.context = context;
-    }
-    
     protected boolean canDetectActivation( Profile profile )
     {
         return profile.getActivation() != null && profile.getActivation().getProperty() != null;
@@ -46,30 +38,14 @@
 
     public boolean isActive( Profile profile )
     {
-        Properties properties = null;
-        if ( context.contains( "SystemProperties" ) )
-        {
-            try
-            {
-                properties = (Properties) context.get("SystemProperties");
-            }
-            catch ( ContextException e )
-            {
-                getLogger().debug( "Failed to get system properties cache from context.", e );
-            }
-        }
-        
-        if ( properties == null )
-        {
-            properties = System.getProperties();
-        }
-        
         Activation activation = profile.getActivation();
 
         ActivationProperty property = activation.getProperty();
 
         if ( property != null )
         {
+            SystemBuildContext systemBuildContext = SystemBuildContext.getSystemBuildContext( getBuildContextManager(), true );
+            
             String name = property.getName();
             boolean reverseName = false;
             
@@ -79,7 +55,7 @@
                 name = name.substring( 1 );
             }
             
-            String sysValue = properties != null ? properties.getProperty( name ) : null;
+            String sysValue = systemBuildContext.getSystemProperty( name );
 
             String propValue = property.getValue();
             if ( StringUtils.isNotEmpty( propValue ) )

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=497911&r1=497910&r2=497911
==============================================================================
--- 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 Fri Jan 19 11:15:18 2007
@@ -33,6 +33,7 @@
 import org.apache.maven.artifact.resolver.ArtifactResolver;
 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.Build;
 import org.apache.maven.model.Dependency;
 import org.apache.maven.model.DependencyManagement;
@@ -40,16 +41,14 @@
 import org.apache.maven.model.Extension;
 import org.apache.maven.model.Model;
 import org.apache.maven.model.Plugin;
-import org.apache.maven.model.Profile;
 import org.apache.maven.model.ReportPlugin;
 import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
 import org.apache.maven.profiles.DefaultProfileManager;
 import org.apache.maven.profiles.MavenProfilesBuilder;
 import org.apache.maven.profiles.ProfileManager;
-import org.apache.maven.profiles.ProfilesConversionUtils;
-import org.apache.maven.profiles.ProfilesRoot;
 import org.apache.maven.profiles.activation.ProfileActivationException;
 import org.apache.maven.project.artifact.InvalidDependencyVersionException;
+import org.apache.maven.project.build.ProjectBuildContext;
 import org.apache.maven.project.build.model.DefaultModelLineage;
 import org.apache.maven.project.build.model.ModelLineage;
 import org.apache.maven.project.build.model.ModelLineageBuilder;
@@ -150,8 +149,6 @@
 
     private ModelInheritanceAssembler modelInheritanceAssembler;
 
-    private ProfileInjector profileInjector;
-
     private ModelValidator validator;
     
     private Map processedProjectCache = new HashMap();
@@ -167,11 +164,11 @@
 
     private ModelInterpolator modelInterpolator;
 
-    private ArtifactRepositoryFactory artifactRepositoryFactory;
-    
     private ModelLineageBuilder modelLineageBuilder;
     
     private ProfileAdvisor profileAdvisor;
+    
+    private BuildContextManager buildContextManager;
 
     private MavenTools mavenTools;
 
@@ -263,18 +260,31 @@
 
         superModel.setVersion( STANDALONE_SUPERPOM_VERSION );
 
-
-        List activeProfiles;
-
-        profileManager.addProfiles( superModel.getProfiles() );
-
+        MavenProject project = new MavenProject( superModel );
+        
+        ProjectBuildContext projectContext = ProjectBuildContext.getProjectBuildContext( buildContextManager, true );
+        
+        projectContext.setCurrentProject( project );
+        projectContext.store( buildContextManager );
+        
         String projectId = safeVersionlessKey( STANDALONE_SUPERPOM_GROUPID, STANDALONE_SUPERPOM_ARTIFACTID );
 
-        activeProfiles = injectActiveProfiles( profileManager, superModel );
-
-        MavenProject project = new MavenProject( superModel );
+        List activeProfiles = profileAdvisor.applyActivatedProfiles( superModel, null, profileManager.getExplicitlyActivatedIds(), profileManager.getExplicitlyDeactivatedIds() );
+        List activeExternalProfiles = profileAdvisor.applyActivatedExternalProfiles( superModel, null, profileManager );
+        
+        LinkedHashSet profiles = new LinkedHashSet();
+        
+        if ( activeProfiles != null && !activeProfiles.isEmpty() )
+        {
+            profiles.addAll( activeProfiles );
+        }
+        
+        if ( activeExternalProfiles != null && !activeExternalProfiles.isEmpty() )
+        {
+            profiles.addAll( activeExternalProfiles );
+        }
 
-        project.setActiveProfiles( activeProfiles );
+        project.setActiveProfiles( new ArrayList( profiles ) );
 
         project.setOriginalModel( superModel );
 
@@ -296,6 +306,7 @@
         }
     }
 
+
     public MavenProject buildWithDependencies( File projectDescriptor,
                                                ArtifactRepository localRepository,
                                                ProfileManager profileManager )
@@ -1001,6 +1012,11 @@
         
         modelLineageBuilder.resumeBuildingModelLineage( modelLineage, localRepository, externalProfileManager, cachedPomFilesByModelId );
         
+        ProjectBuildContext projectContext = ProjectBuildContext.getProjectBuildContext( buildContextManager, true );
+        
+        projectContext.setModelLineage( modelLineage );
+        projectContext.store( buildContextManager );
+        
         List explicitlyActive;
         List explicitlyInactive;
         
@@ -1026,6 +1042,9 @@
             
             MavenProject project = new MavenProject( currentModel );
             project.setFile( currentPom );
+            
+            projectContext.setCurrentProject( project );
+            projectContext.store( buildContextManager );
 
             project.setActiveProfiles( profileAdvisor.applyActivatedProfiles( model, projectDir, explicitlyActive,
                                                                               explicitlyInactive ) );
@@ -1059,80 +1078,6 @@
         }
         
         return result;
-    }
-
-    private List injectActiveProfiles( ProfileManager profileManager, Model model )
-        throws ProjectBuildingException
-    {
-        List activeProfiles;
-
-        if ( profileManager != null )
-        {
-            try
-            {
-                activeProfiles = profileManager.getActiveProfiles();
-            }
-            catch ( ProfileActivationException e )
-            {
-                String projectId = safeVersionlessKey( model.getGroupId(), model.getArtifactId() );
-
-                throw new ProjectBuildingException( projectId, e.getMessage(), e );
-            }
-
-            for ( Iterator it = activeProfiles.iterator(); it.hasNext(); )
-            {
-                Profile profile = (Profile) it.next();
-
-                profileInjector.inject( profile, model );
-            }
-        }
-        else
-        {
-            activeProfiles = Collections.EMPTY_LIST;
-        }
-
-        return activeProfiles;
-    }
-
-    private void loadProjectExternalProfiles( ProfileManager profileManager, File projectDir )
-        throws ProfileActivationException
-    {
-        if ( projectDir != null )
-        {
-            try
-            {
-                ProfilesRoot root = profilesBuilder.buildProfiles( projectDir );
-
-                if ( root != null )
-                {
-                    List active = root.getActiveProfiles();
-
-                    if ( active != null && !active.isEmpty() )
-                    {
-                        profileManager.explicitlyActivate( root.getActiveProfiles() );
-                    }
-
-                    for ( Iterator it = root.getProfiles().iterator(); it.hasNext(); )
-                    {
-                        org.apache.maven.profiles.Profile rawProfile = (org.apache.maven.profiles.Profile) it.next();
-
-                        Profile converted = ProfilesConversionUtils.convertFromProfileXmlProfile( rawProfile );
-
-                        profileManager.addProfile( converted );
-                    }
-                }
-            }
-            catch ( IOException e )
-            {
-                throw new ProfileActivationException( "Cannot read profiles.xml resource from directory: " + projectDir,
-                                                      e );
-            }
-            catch ( XmlPullParserException e )
-            {
-                throw new ProfileActivationException(
-                    "Cannot parse profiles.xml resource from directory: " + projectDir, e );
-            }
-        }
     }
 
     private Model readModel( String projectId, File file, boolean strict )

Added: 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=auto&rev=497911
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/ProjectBuildContext.java (added)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/ProjectBuildContext.java Fri Jan 19 11:15:18 2007
@@ -0,0 +1,98 @@
+package org.apache.maven.project.build;
+
+import org.apache.maven.context.BuildContext;
+import org.apache.maven.context.BuildContextManager;
+import org.apache.maven.context.ManagedBuildData;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.build.model.ModelLineage;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Build context information available for use during profile activation, which supplies information
+ * about the current project and lineage from the current project back through parent poms to the
+ * POM that declared that profile (where the activator is used). Lineage may not be accessible in
+ * all cases, and will usually be incomplete (not stretching all the way back to the common super-POM).
+ * This could enable custom profile activators that trigger based on model properties, etc.
+ */
+public class ProjectBuildContext
+    implements ManagedBuildData
+{
+    
+    public static final String BUILD_CONTEXT_KEY = ProjectBuildContext.class.getName();
+    
+    private ModelLineage modelLineage;
+    
+    private MavenProject currentProject;
+    
+    public ProjectBuildContext()
+    {
+    }
+
+    public ModelLineage getModelLineage()
+    {
+        return modelLineage;
+    }
+
+    public void setModelLineage( ModelLineage modelLineage )
+    {
+        this.modelLineage = modelLineage;
+    }
+
+    public MavenProject getCurrentProject()
+    {
+        return currentProject;
+    }
+
+    public void setCurrentProject( MavenProject currentProject )
+    {
+        this.currentProject = currentProject;
+    }
+
+    public String getStorageKey()
+    {
+        return BUILD_CONTEXT_KEY;
+    }
+    
+    public static ProjectBuildContext getProjectBuildContext( BuildContextManager buildContextManager, boolean create )
+    {
+        BuildContext buildContext = buildContextManager.readBuildContext( false );
+        
+        ProjectBuildContext projectContext = null;
+        
+        if ( buildContext != null )
+        {
+            projectContext = (ProjectBuildContext) buildContext.get( BUILD_CONTEXT_KEY );
+        }
+        
+        if ( create && projectContext == null )
+        {
+            projectContext = new ProjectBuildContext();
+        }
+        
+        return projectContext;
+    }
+    
+    public void store( BuildContextManager buildContextManager )
+    {
+        BuildContext buildContext = buildContextManager.readBuildContext( true );
+        
+        buildContext.put( this );
+        
+        buildContextManager.storeBuildContext( buildContext );
+    }
+}

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

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

Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/model/DefaultModelLineage.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/model/DefaultModelLineage.java?view=diff&rev=497911&r1=497910&r2=497911
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/model/DefaultModelLineage.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/model/DefaultModelLineage.java Fri Jan 19 11:15:18 2007
@@ -328,4 +328,44 @@
         }
     }
 
+    public ModelLineageIterator lineageIterator()
+    {
+        return new ModelLineageIterator()
+        {
+
+            private int idx = -1;
+
+            public boolean hasNext()
+            {
+                return tuples.size() > idx + 1;
+            }
+
+            public Object next()
+            {
+                return ( (ModelLineageTuple) tuples.get( ( ++idx ) ) ).model;
+            }
+
+            public void remove()
+            {
+                tuples.remove( idx );
+            }
+
+            public List getArtifactRepositories()
+            {
+                return ( (ModelLineageTuple) tuples.get( idx ) ).remoteRepositories;
+            }
+
+            public Model getModel()
+            {
+                return ( (ModelLineageTuple) tuples.get( idx ) ).model;
+            }
+
+            public File getPOMFile()
+            {
+                return ( (ModelLineageTuple) tuples.get( idx ) ).file;
+            }
+
+        };
+    }
+
 }

Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/model/ModelLineage.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/model/ModelLineage.java?view=diff&rev=497911&r1=497910&r2=497911
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/model/ModelLineage.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/model/ModelLineage.java Fri Jan 19 11:15:18 2007
@@ -88,6 +88,14 @@
      * that of the deepest parent at the zero index, and that of the current POM at the last index.
      */
     List getArtifactRepositoryListsInDescendingOrder();
+    
+    /**
+     * Retrieve an Iterator derivative that functions in the simplest sense just like the return 
+     * value of the modelIterator() method. However, the ModelLineageIterator also gives access to
+     * the current POM file and current remote ArtifactRepository instances used to resolve the 
+     * current Model...along with a method to give explicit access to the current Model instance.
+     */
+    ModelLineageIterator lineageIterator();
 
     /**
      * Iterate over the lineage of Model instances, starting with the child (current) Model, 

Added: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/model/ModelLineageIterator.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/model/ModelLineageIterator.java?view=auto&rev=497911
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/model/ModelLineageIterator.java (added)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/model/ModelLineageIterator.java Fri Jan 19 11:15:18 2007
@@ -0,0 +1,37 @@
+package org.apache.maven.project.build.model;
+
+import org.apache.maven.model.Model;
+
+import java.io.File;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * Iterator that gives access to all information associated with each model in a ModelLineage.
+ * The result of the next() method is the Model instance itself, but you can also retrieve this
+ * Model instance using getModel() below.
+ * 
+ * @author jdcasey
+ */
+public interface ModelLineageIterator
+    extends Iterator
+{
+    
+    /**
+     * Retrieve the Model instance associated with the current position in the ModelLineage.
+     * This is the same return value as the next() method.
+     */
+    Model getModel();
+    
+    /**
+     * Retrieve the POM File associated with the current position in the ModelLineage
+     */
+    File getPOMFile();
+    
+    /**
+     * Retrieve the remote ArtifactRepository instances associated with the current position 
+     * in the ModelLineage.
+     */
+    List getArtifactRepositories();
+
+}

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

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

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=497911&r1=497910&r2=497911
==============================================================================
--- 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 Fri Jan 19 11:15:18 2007
@@ -102,9 +102,6 @@
           <role>org.apache.maven.profiles.MavenProfilesBuilder</role>
         </requirement>
         <requirement>
-          <role>org.apache.maven.project.injection.ProfileInjector</role>
-        </requirement>
-        <requirement>
           <role>org.apache.maven.project.injection.ModelDefaultsInjector</role>
         </requirement>
         <requirement>
@@ -126,7 +123,8 @@
           <role>org.apache.maven.artifact.resolver.ArtifactResolver</role>
         </requirement>
         <requirement>
-          <role>org.apache.maven.artifact.repository.ArtifactRepositoryFactory</role>
+          <role>org.apache.maven.context.BuildContextManager</role>
+          <role-hint>default</role-hint>
         </requirement>
         <requirement>
           <role>org.apache.maven.artifact.manager.WagonManager</role>
@@ -155,6 +153,12 @@
       <role>org.apache.maven.profiles.activation.ProfileActivator</role>
       <role-hint>jdk-prefix</role-hint>
       <implementation>org.apache.maven.profiles.activation.JdkPrefixProfileActivator</implementation>
+      <requirements>
+        <requirement>
+          <role>org.apache.maven.context.BuildContextManager</role>
+          <role-hint>default</role-hint>
+        </requirement>
+      </requirements>
     </component>
 <!--
      |
@@ -165,6 +169,12 @@
       <role>org.apache.maven.profiles.activation.ProfileActivator</role>
       <role-hint>system-property</role-hint>
       <implementation>org.apache.maven.profiles.activation.SystemPropertyProfileActivator</implementation>
+      <requirements>
+        <requirement>
+          <role>org.apache.maven.context.BuildContextManager</role>
+          <role-hint>default</role-hint>
+        </requirement>
+      </requirements>
     </component>
     <!--
      |
@@ -185,6 +195,16 @@
       <role>org.apache.maven.profiles.activation.ProfileActivator</role>
       <role-hint>file</role-hint>
       <implementation>org.apache.maven.profiles.activation.FileProfileActivator</implementation>
+    </component>
+    <!--
+     |
+     |
+     |
+     -->
+    <component>
+      <role>org.apache.maven.profiles.activation.ProfileActivator</role>
+      <role-hint>custom</role-hint>
+      <implementation>org.apache.maven.profiles.activation.CustomActivator</implementation>
     </component>
 <!--
      |

Modified: maven/components/trunk/maven-project/src/test/java/org/apache/maven/profiles/DefaultProfileManagerTest.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/test/java/org/apache/maven/profiles/DefaultProfileManagerTest.java?view=diff&rev=497911&r1=497910&r2=497911
==============================================================================
--- maven/components/trunk/maven-project/src/test/java/org/apache/maven/profiles/DefaultProfileManagerTest.java (original)
+++ maven/components/trunk/maven-project/src/test/java/org/apache/maven/profiles/DefaultProfileManagerTest.java Fri Jan 19 11:15:18 2007
@@ -1,9 +1,12 @@
 package org.apache.maven.profiles;
 
+import org.apache.maven.context.BuildContextManager;
+import org.apache.maven.context.DefaultBuildContextManager;
+import org.apache.maven.context.SystemBuildContext;
 import org.apache.maven.model.Activation;
+import org.apache.maven.model.ActivationOS;
 import org.apache.maven.model.ActivationProperty;
 import org.apache.maven.model.Profile;
-import org.apache.maven.model.ActivationOS;
 import org.apache.maven.profiles.activation.ProfileActivationException;
 import org.codehaus.plexus.PlexusTestCase;
 
@@ -13,8 +16,20 @@
     extends PlexusTestCase
 {
     
+    private BuildContextManager buildContextManager;
+    
+    public void setUp() throws Exception
+    {
+        super.setUp();
+        
+        buildContextManager = (BuildContextManager) lookup( BuildContextManager.ROLE, DefaultBuildContextManager.ROLE_HINT );
+    }
+    
     public void testShouldActivateDefaultProfile() throws ProfileActivationException
     {
+        SystemBuildContext sysContext = SystemBuildContext.getSystemBuildContext( buildContextManager, true );
+        sysContext.store( buildContextManager );
+        
         Profile notActivated = new Profile();
         notActivated.setId("notActivated");
         
@@ -47,6 +62,9 @@
 
     public void testShouldNotActivateDefaultProfile() throws ProfileActivationException
     {
+        SystemBuildContext sysContext = SystemBuildContext.getSystemBuildContext( buildContextManager, true );
+        sysContext.store( buildContextManager );
+        
         Profile syspropActivated = new Profile();
         syspropActivated.setId("syspropActivated");
         
@@ -82,6 +100,9 @@
 
     public void testShouldNotActivateReversalOfPresentSystemProperty() throws ProfileActivationException
     {
+        SystemBuildContext sysContext = SystemBuildContext.getSystemBuildContext( buildContextManager, true );
+        sysContext.store( buildContextManager );
+        
         Profile syspropActivated = new Profile();
         syspropActivated.setId("syspropActivated");