maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdca...@apache.org
Subject svn commit: r683740 - in /maven/components/branches/maven-2.0.10-RC: ./ maven-core/src/main/java/org/apache/maven/lifecycle/ maven-core/src/main/java/org/apache/maven/plugin/ maven-core/src/main/resources/META-INF/plexus/ maven-project/src/main/java/or...
Date Thu, 07 Aug 2008 22:33:15 GMT
Author: jdcasey
Date: Thu Aug  7 15:33:15 2008
New Revision: 683740

URL: http://svn.apache.org/viewvc?rev=683740&view=rev
Log:
[MNG-3698] Moved concrete/dynamic transitions out to the lifecycle executor to make them happen less often, and added code to check whether reactorProjects are used or reachable (via session parameter) before calculating their concrete state blindly. Also, conserving the RegexBasedInterpolator (the class from plexus-interpolator) to keep from reconstructing the Pattern instance inside it repeatedly. Added a buffer size to the StringWriter used in the interpolator, and finally changed the concrete calculation to avoid some needless project-instance cloning (which as it turns out is wrong...see MNG-3700). Performance is significantly improved, and memory usage has been cut from what it used in 2.0.9.

Added:
    maven/components/branches/maven-2.0.10-RC/maven-project/src/test/resources/project-dynamism/pom-plugins.xml
Modified:
    maven/components/branches/maven-2.0.10-RC/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
    maven/components/branches/maven-2.0.10-RC/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
    maven/components/branches/maven-2.0.10-RC/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java
    maven/components/branches/maven-2.0.10-RC/maven-core/src/main/resources/META-INF/plexus/components.xml
    maven/components/branches/maven-2.0.10-RC/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
    maven/components/branches/maven-2.0.10-RC/maven-project/src/main/java/org/apache/maven/project/MavenProject.java
    maven/components/branches/maven-2.0.10-RC/maven-project/src/main/java/org/apache/maven/project/interpolation/BuildTimestampValueSource.java
    maven/components/branches/maven-2.0.10-RC/maven-project/src/main/java/org/apache/maven/project/interpolation/RegexBasedModelInterpolator.java
    maven/components/branches/maven-2.0.10-RC/maven-project/src/test/java/org/apache/maven/project/MavenProjectDynamismTest.java
    maven/components/branches/maven-2.0.10-RC/maven-project/src/test/java/org/apache/maven/project/interpolation/RegexBasedModelInterpolatorTest.java
    maven/components/branches/maven-2.0.10-RC/pom.xml

Modified: maven/components/branches/maven-2.0.10-RC/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.0.10-RC/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java?rev=683740&r1=683739&r2=683740&view=diff
==============================================================================
--- maven/components/branches/maven-2.0.10-RC/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java (original)
+++ maven/components/branches/maven-2.0.10-RC/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java Thu Aug  7 15:33:15 2008
@@ -46,13 +46,17 @@
 import org.apache.maven.plugin.PluginManagerException;
 import org.apache.maven.plugin.PluginNotFoundException;
 import org.apache.maven.plugin.descriptor.MojoDescriptor;
+import org.apache.maven.plugin.descriptor.Parameter;
 import org.apache.maven.plugin.descriptor.PluginDescriptor;
 import org.apache.maven.plugin.lifecycle.Execution;
 import org.apache.maven.plugin.lifecycle.Phase;
 import org.apache.maven.plugin.version.PluginVersionNotFoundException;
 import org.apache.maven.plugin.version.PluginVersionResolutionException;
 import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.MavenProjectBuilder;
 import org.apache.maven.project.artifact.InvalidDependencyVersionException;
+import org.apache.maven.project.interpolation.ModelInterpolationException;
+import org.apache.maven.project.interpolation.ModelInterpolator;
 import org.apache.maven.reporting.MavenReport;
 import org.apache.maven.settings.Settings;
 import org.codehaus.plexus.PlexusContainerException;
@@ -60,9 +64,13 @@
 import org.codehaus.plexus.logging.AbstractLogEnabled;
 import org.codehaus.plexus.util.StringUtils;
 import org.codehaus.plexus.util.xml.Xpp3Dom;
+import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
+import org.codehaus.plexus.util.xml.Xpp3DomWriter;
 import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
 
 import java.io.IOException;
+import java.io.StringReader;
+import java.io.StringWriter;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
@@ -98,6 +106,10 @@
 
     private Map phaseToLifecycleMap;
 
+    private MavenProjectBuilder mavenProjectBuilder;
+
+    private ModelInterpolator modelInterpolator;
+
     // ----------------------------------------------------------------------
     //
     // ----------------------------------------------------------------------
@@ -542,6 +554,41 @@
 
             MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
 
+            calculateConcreteState( project, session );
+            
+            boolean usesAllProjects = false;
+            
+            List params = mojoDescriptor.getParameters();
+            if ( params != null && !params.isEmpty() )
+            {
+                for ( Iterator it = params.iterator(); it.hasNext(); )
+                {
+                    Parameter param = (Parameter) it.next();
+                    
+                    if ( param.getExpression() != null
+                        && ( param.getExpression().startsWith( "session" ) || param.getExpression().equals(
+                                                                                                            "reactorProjects" ) ) )
+                    {
+                        usesAllProjects = true;
+                        break;
+                    }
+                    else if ( param.getDefaultValue() != null
+                        && ( param.getDefaultValue().startsWith( "session" ) || param.getDefaultValue().equals(
+                                                                                                                "reactorProjects" ) ) )
+                    {
+                        usesAllProjects = true;
+                        break;
+                    }
+                }
+            }
+            
+            if ( usesAllProjects )
+            {
+                calculateAllConcreteStates( session );
+            }
+            
+            calculateConcreteConfiguration( mojoExecution, project, session );
+
             if ( mojoDescriptor.getExecutePhase() != null || mojoDescriptor.getExecuteGoal() != null )
             {
                 forkEntryPoints.push( mojoDescriptor );
@@ -550,7 +597,7 @@
 
                 forkEntryPoints.pop();
             }
-
+            
             if ( mojoDescriptor.isRequiresReports() )
             {
                 List reports = getReports( project, forkEntryPoints, mojoExecution, session );
@@ -606,6 +653,110 @@
             {
                 throw new LifecycleExecutionException( e.getMessage(), e );
             }
+            
+            restoreDynamicState( project, session );
+            
+            if ( usesAllProjects )
+            {
+                restoreAllDynamicStates( session );
+            }
+        }
+    }
+    
+    private void calculateConcreteConfiguration( MojoExecution mojoExecution, MavenProject project, MavenSession session )
+        throws LifecycleExecutionException
+    {
+        if ( mojoExecution.getConfiguration() == null )
+        {
+            return;
+        }
+        
+        StringWriter writer = new StringWriter();
+        Xpp3DomWriter.write( writer, mojoExecution.getConfiguration() );
+        
+        String domStr = writer.toString();
+        
+        try
+        {
+            domStr =
+                modelInterpolator.interpolate( domStr, project.getModel(), project.getBasedir(),
+                                               session.getProjectBuilderConfiguration(), getLogger().isDebugEnabled() );
+        }
+        catch ( ModelInterpolationException e )
+        {
+            throw new LifecycleExecutionException( "Error interpolating configuration for: '" + mojoExecution.getMojoDescriptor().getRoleHint() +
+                                              "' (execution: '" + mojoExecution.getExecutionId() + "')", e );
+        }
+        
+        try
+        {
+            mojoExecution.setConfiguration( Xpp3DomBuilder.build( new StringReader( domStr ) ) );
+        }
+        catch ( XmlPullParserException e )
+        {
+            throw new LifecycleExecutionException( "Error reading interpolated configuration for: '" + mojoExecution.getMojoDescriptor().getRoleHint() +
+                                              "' (execution: '" + mojoExecution.getExecutionId() + "')", e );
+        }
+        catch ( IOException e )
+        {
+            throw new LifecycleExecutionException( "Error reading interpolated configuration for: '" + mojoExecution.getMojoDescriptor().getRoleHint() +
+                                              "' (execution: '" + mojoExecution.getExecutionId() + "')", e );
+        }
+    }
+    
+    private void calculateAllConcreteStates( MavenSession session )
+        throws LifecycleExecutionException
+    {
+        List projects = session.getSortedProjects();
+        if ( projects != null )
+        {
+            for ( Iterator it = projects.iterator(); it.hasNext(); )
+            {
+                calculateConcreteState( (MavenProject) it.next(), session );
+            }
+        }
+    }
+
+    private void calculateConcreteState( MavenProject project, MavenSession session )
+        throws LifecycleExecutionException
+    {
+        if ( mavenProjectBuilder != null && project != null && !project.isConcrete() )
+        {
+            try
+            {
+                mavenProjectBuilder.calculateConcreteState( project, session.getProjectBuilderConfiguration() );
+            }
+            catch ( ModelInterpolationException e )
+            {
+                throw new LifecycleExecutionException( "Failed to calculate concrete state for project: " + project,
+                                                         e );
+            }
+        }
+    }
+    private void restoreAllDynamicStates( MavenSession session )
+        throws LifecycleExecutionException
+    {
+        List reactorProjects = session.getSortedProjects();
+        if ( reactorProjects != null )
+        {
+            for ( Iterator it = reactorProjects.iterator(); it.hasNext(); )
+            {
+                MavenProject project = (MavenProject) it.next();
+                restoreDynamicState( project, session );
+            }
+        }
+    }
+
+    private void restoreDynamicState( MavenProject project, MavenSession session )
+        throws LifecycleExecutionException
+    {
+        try
+        {
+            mavenProjectBuilder.restoreDynamicState( project, session.getProjectBuilderConfiguration() );
+        }
+        catch ( ModelInterpolationException e )
+        {
+            throw new LifecycleExecutionException( "Failed to restore dynamic state for project: " + project, e );
         }
     }
 
@@ -896,6 +1047,7 @@
                             }
 
                             Xpp3Dom configuration = (Xpp3Dom) exec.getConfiguration();
+                            // NOTE: This seems to be duplicated below. Why??
                             if ( phase.getConfiguration() != null )
                             {
                                 configuration = Xpp3Dom.mergeXpp3Dom( new Xpp3Dom( (Xpp3Dom) phase.getConfiguration() ),

Modified: maven/components/branches/maven-2.0.10-RC/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.0.10-RC/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java?rev=683740&r1=683739&r2=683740&view=diff
==============================================================================
--- maven/components/branches/maven-2.0.10-RC/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java (original)
+++ maven/components/branches/maven-2.0.10-RC/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java Thu Aug  7 15:33:15 2008
@@ -135,8 +135,6 @@
 
     protected MavenProjectBuilder mavenProjectBuilder;
     
-    protected ModelInterpolator modelInterpolator;
-
     protected PluginMappingManager pluginMappingManager;
 
     // END component requirements
@@ -534,30 +532,8 @@
                 }
             }
         }
-
-        restoreAllProjectDynamism( session );
     }
 
-    private void restoreAllProjectDynamism( MavenSession session )
-        throws PluginManagerException
-    {
-        List reactorProjects = session.getSortedProjects();
-        if ( reactorProjects != null )
-        {
-            for ( Iterator it = reactorProjects.iterator(); it.hasNext(); )
-            {
-                MavenProject project = (MavenProject) it.next();
-                try
-                {
-                    mavenProjectBuilder.restoreDynamicState( project, session.getProjectBuilderConfiguration() );
-                }
-                catch ( ModelInterpolationException e )
-                {
-                    throw new PluginManagerException( "Failed to restore dynamic state for project: " + project, e );
-                }
-            }
-        }
-    }
 
     public MavenReport getReport( MavenProject project,
                                   MojoExecution mojoExecution,
@@ -578,8 +554,6 @@
 
         MavenReport report = (MavenReport) getConfiguredMojo( session, dom, project, true, mojoExecution );
         
-        restoreAllProjectDynamism( session );
-        
         return report;
     }
 
@@ -676,52 +650,6 @@
         }
         else
         {
-            if ( project != null && !project.isConcrete() )
-            {
-                try
-                {
-                    mavenProjectBuilder.calculateConcreteState( project, session.getProjectBuilderConfiguration() );
-                }
-                catch ( ModelInterpolationException e )
-                {
-                    throw new PluginManagerException( "Error calculating concrete state for project: " + project
-                        + "\n(processing configuration for mojo: '" + mojoDescriptor.getRoleHint() + "' with execution-id: '"
-                        + mojoExecution.getExecutionId() + "')", e );
-                }
-            }
-            
-            StringWriter writer = new StringWriter();
-            Xpp3DomWriter.write( writer, dom );
-            
-            String domStr = writer.toString();
-            
-            try
-            {
-                domStr =
-                    modelInterpolator.interpolate( domStr, project.getModel(), project.getBasedir(),
-                                                   session.getProjectBuilderConfiguration(), getLogger().isDebugEnabled() );
-            }
-            catch ( ModelInterpolationException e )
-            {
-                throw new PluginManagerException( "Error interpolating configuration for: '" + mojoDescriptor.getRoleHint() +
-                                                  "' (execution: '" + mojoExecution.getExecutionId() + "')", e );
-            }
-            
-            try
-            {
-                dom = Xpp3DomBuilder.build( new StringReader( domStr ) );
-            }
-            catch ( XmlPullParserException e )
-            {
-                throw new PluginManagerException( "Error reading interpolated configuration for: '" + mojoDescriptor.getRoleHint() +
-                                                  "' (execution: '" + mojoExecution.getExecutionId() + "')", e );
-            }
-            catch ( IOException e )
-            {
-                throw new PluginManagerException( "Error reading interpolated configuration for: '" + mojoDescriptor.getRoleHint() +
-                                                  "' (execution: '" + mojoExecution.getExecutionId() + "')", e );
-            }
-            
             pomConfiguration = new XmlPlexusConfiguration( dom );
         }
 
@@ -737,7 +665,6 @@
 
         ExpressionEvaluator expressionEvaluator = new PluginParameterExpressionEvaluator( session, mojoExecution,
                                                                                           pathTranslator,
-                                                                                          mavenProjectBuilder,
                                                                                           getLogger(),
                                                                                           project,
                                                                                           session.getExecutionProperties() );

Modified: maven/components/branches/maven-2.0.10-RC/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.0.10-RC/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java?rev=683740&r1=683739&r2=683740&view=diff
==============================================================================
--- maven/components/branches/maven-2.0.10-RC/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java (original)
+++ maven/components/branches/maven-2.0.10-RC/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java Thu Aug  7 15:33:15 2008
@@ -23,8 +23,6 @@
 import org.apache.maven.plugin.descriptor.MojoDescriptor;
 import org.apache.maven.plugin.descriptor.PluginDescriptor;
 import org.apache.maven.project.MavenProject;
-import org.apache.maven.project.MavenProjectBuilder;
-import org.apache.maven.project.interpolation.ModelInterpolationException;
 import org.apache.maven.project.path.PathTranslator;
 import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
 import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator;
@@ -33,8 +31,6 @@
 
 import java.io.File;
 import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 
@@ -78,8 +74,6 @@
 
     private final Properties properties;
 
-    private final MavenProjectBuilder projectBuilder;
-
     public PluginParameterExpressionEvaluator( MavenSession context,
                                                MojoExecution mojoExecution,
                                                PathTranslator pathTranslator,
@@ -87,21 +81,9 @@
                                                MavenProject project,
                                                Properties properties )
     {
-        this( context, mojoExecution, pathTranslator, null, logger, project, properties );
-    }
-    
-    public PluginParameterExpressionEvaluator( MavenSession context,
-                                               MojoExecution mojoExecution,
-                                               PathTranslator pathTranslator,
-                                               MavenProjectBuilder projectBuilder,
-                                               Logger logger,
-                                               MavenProject project,
-                                               Properties properties )
-    {
         this.context = context;
         this.mojoExecution = mojoExecution;
         this.pathTranslator = pathTranslator;
-        this.projectBuilder = projectBuilder;
         this.logger = logger;
         this.project = project;
         this.properties = properties;
@@ -130,8 +112,6 @@
     public Object evaluate( String expr )
         throws ExpressionEvaluationException
     {
-        calculateConcreteState( project );
-        
         Object value = null;
 
         if ( expr == null )
@@ -195,14 +175,10 @@
         }
         else if ( "session".equals( expression ) )
         {
-            calculateAllConcreteStates();
-            
             value = context;
         }
         else if ( "reactorProjects".equals( expression ) )
         {
-            calculateAllConcreteStates();
-            
             value = context.getSortedProjects();
         }
         else if ( "reports".equals( expression ) )
@@ -215,17 +191,14 @@
         }
         else if ( "project".equals( expression ) )
         {
-            // concrete state calculated above for the direct project.
             value = project;
         }
         else if ( "executedProject".equals( expression ) )
         {
-            // concrete state calculated above for the direct project and associated execution project.
             value = project.getExecutionProject();
         }
         else if ( expression.startsWith( "project" ) )
         {
-            // concrete state calculated above for the direct project.
             try
             {
                 int pathSeparator = expression.indexOf( "/" );
@@ -363,35 +336,6 @@
         return value;
     }
 
-    private void calculateAllConcreteStates()
-        throws ExpressionEvaluationException
-    {
-        List projects = context.getSortedProjects();
-        if ( projects != null )
-        {
-            for ( Iterator it = projects.iterator(); it.hasNext(); )
-            {
-                calculateConcreteState( (MavenProject) it.next() );
-            }
-        }
-    }
-
-    private void calculateConcreteState( MavenProject project )
-        throws ExpressionEvaluationException
-    {
-        if ( projectBuilder != null && project != null && !project.isConcrete() )
-        {
-            try
-            {
-                projectBuilder.calculateConcreteState( project, context.getProjectBuilderConfiguration() );
-            }
-            catch ( ModelInterpolationException e )
-            {
-                throw new ExpressionEvaluationException( "Failed to calculate concrete state for project: " + project, e );
-            }
-        }
-    }
-
     private String stripTokens( String expr )
     {
         if ( expr.startsWith( "${" ) && expr.indexOf( "}" ) == expr.length() - 1 )

Modified: maven/components/branches/maven-2.0.10-RC/maven-core/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.0.10-RC/maven-core/src/main/resources/META-INF/plexus/components.xml?rev=683740&r1=683739&r2=683740&view=diff
==============================================================================
--- maven/components/branches/maven-2.0.10-RC/maven-core/src/main/resources/META-INF/plexus/components.xml (original)
+++ maven/components/branches/maven-2.0.10-RC/maven-core/src/main/resources/META-INF/plexus/components.xml Thu Aug  7 15:33:15 2008
@@ -50,9 +50,6 @@
         <requirement>
           <role>org.apache.maven.project.MavenProjectBuilder</role>
         </requirement>
-        <requirement>
-          <role>org.apache.maven.project.interpolation.ModelInterpolator</role>
-        </requirement>
       </requirements>
     </component>
 
@@ -227,6 +224,12 @@
         <requirement>
           <role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
         </requirement>
+        <requirement>
+          <role>org.apache.maven.project.MavenProjectBuilder</role>
+        </requirement>
+        <requirement>
+          <role>org.apache.maven.project.interpolation.ModelInterpolator</role>
+        </requirement>
       </requirements>
       <configuration>
         <lifecycles>

Modified: maven/components/branches/maven-2.0.10-RC/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.0.10-RC/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java?rev=683740&r1=683739&r2=683740&view=diff
==============================================================================
--- maven/components/branches/maven-2.0.10-RC/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java (original)
+++ maven/components/branches/maven-2.0.10-RC/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java Thu Aug  7 15:33:15 2008
@@ -1805,6 +1805,8 @@
         container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
     }
 
+    // NOTE: This is a code hotspot, PLEASE be careful about the performance of logic inside or
+    // called from this method. 
     public void calculateConcreteState( MavenProject project, ProjectBuilderConfiguration config )
         throws ModelInterpolationException
     {
@@ -1820,14 +1822,15 @@
             initResourceMergeIds( build.getTestResources() );
         }
 
-        Model model = ModelUtils.cloneModel( project.getModel() );
-
-        // We don't need all the project methods that are added over those in the model, but we do need basedir
-        Map context = new HashMap();
+        // NOTE: Since interpolation makes a copy through serialization, we don't need this.
+        // See note below.
+        //
+        // Model model = ModelUtils.cloneModel( project.getModel() );
 
         File basedir = project.getBasedir();
 
-        model = modelInterpolator.interpolate( model, project.getBasedir(), config, getLogger().isDebugEnabled() );
+        // NOTE: If we ever get past serialization/deserialization for interpolation, we'll need to copy the model here!
+        Model model = modelInterpolator.interpolate( project.getModel(), project.getBasedir(), config, getLogger().isDebugEnabled() );
 
         List originalInterpolatedCompileSourceRoots = interpolateListOfStrings( project.getCompileSourceRoots(),
                                                                            model,
@@ -1860,14 +1863,12 @@
         project.setScriptSourceRoots( originalInterpolatedScriptSourceRoots == null ? null
                         : translateListOfPaths( originalInterpolatedScriptSourceRoots, basedir ) );
 
-        Model model2 = ModelUtils.cloneModel( model );
-
         if ( basedir != null )
         {
             pathTranslator.alignToBaseDirectory( model, basedir );
         }
 
-        project.preserveBuild( model2.getBuild() );
+        project.preserveBuild( ModelUtils.cloneBuild( model.getBuild() ) );
         project.setBuild( model.getBuild() );
 
         calculateConcreteProjectReferences( project, config );
@@ -1933,6 +1934,8 @@
         return result;
     }
 
+    // NOTE: This is a code hotspot, PLEASE be careful about the performance of logic inside or
+    // called from this method. 
     public void restoreDynamicState( MavenProject project, ProjectBuilderConfiguration config )
         throws ModelInterpolationException
     {
@@ -1943,8 +1946,9 @@
 
         restoreBuildRoots( project, config, getLogger().isDebugEnabled() );
         restoreModelBuildSection( project, config, getLogger().isDebugEnabled() );
-
+        
         restoreDynamicProjectReferences( project, config );
+        
         if ( project.getExecutionProject() != null )
         {
             restoreDynamicState( project.getExecutionProject(), config );
@@ -1953,6 +1957,36 @@
         project.setConcrete( false );
     }
 
+    private void propagateNewPlugins( MavenProject project )
+    {
+        Build changedBuild = project.getBuild();
+        Build dynamicBuild = project.getDynamicBuild();
+        
+        if ( changedBuild == null || dynamicBuild == null )
+        {
+            return;
+        }
+        
+        List changedPlugins = changedBuild.getPlugins();
+        List dynamicPlugins = dynamicBuild.getPlugins();
+        
+        if ( changedPlugins != null && dynamicPlugins != null && changedPlugins.size() != dynamicPlugins.size() )
+        {
+            changedPlugins.removeAll( dynamicPlugins );
+            if ( !changedPlugins.isEmpty() )
+            {
+                for ( Iterator it = changedPlugins.iterator(); it.hasNext(); )
+                {
+                    Plugin plugin = (Plugin) it.next();
+                    
+                    dynamicBuild.addPlugin( plugin );
+                }
+            }
+        }
+        
+        dynamicBuild.flushPluginMap();
+    }
+
     private void restoreDynamicProjectReferences( MavenProject project,
                                                   ProjectBuilderConfiguration config )
         throws ModelInterpolationException
@@ -2083,6 +2117,8 @@
                                                       config,
                                                       debugMessages ) );
 
+        propagateNewPlugins( project );
+        
         project.setBuild( dynamicBuild );
 
         project.clearRestorableBuild();

Modified: maven/components/branches/maven-2.0.10-RC/maven-project/src/main/java/org/apache/maven/project/MavenProject.java
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.0.10-RC/maven-project/src/main/java/org/apache/maven/project/MavenProject.java?rev=683740&r1=683739&r2=683740&view=diff
==============================================================================
--- maven/components/branches/maven-2.0.10-RC/maven-project/src/main/java/org/apache/maven/project/MavenProject.java (original)
+++ maven/components/branches/maven-2.0.10-RC/maven-project/src/main/java/org/apache/maven/project/MavenProject.java Thu Aug  7 15:33:15 2008
@@ -63,7 +63,6 @@
 import org.apache.maven.project.artifact.ActiveProjectArtifact;
 import org.apache.maven.project.artifact.InvalidDependencyVersionException;
 import org.apache.maven.project.artifact.MavenMetadataSource;
-import org.apache.maven.project.overlay.BuildOverlay;
 import org.codehaus.plexus.util.xml.Xpp3Dom;
 
 /**
@@ -145,8 +144,6 @@
 
     private Map projectReferences = new HashMap();
 
-    private Build buildOverlay;
-
     private boolean executionRoot;
     
     private Map moduleAdjustments;
@@ -1085,19 +1082,12 @@
 
     public void setBuild( Build build )
     {
-        this.buildOverlay = new BuildOverlay( build );
-
         getModel().setBuild( build );
     }
 
     public Build getBuild()
     {
-        if ( buildOverlay == null )
-        {
-            buildOverlay = new BuildOverlay( getModelBuild() );
-        }
-
-        return buildOverlay;
+        return getModelBuild();
     }
 
     public List getResources()

Modified: maven/components/branches/maven-2.0.10-RC/maven-project/src/main/java/org/apache/maven/project/interpolation/BuildTimestampValueSource.java
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.0.10-RC/maven-project/src/main/java/org/apache/maven/project/interpolation/BuildTimestampValueSource.java?rev=683740&r1=683739&r2=683740&view=diff
==============================================================================
--- maven/components/branches/maven-2.0.10-RC/maven-project/src/main/java/org/apache/maven/project/interpolation/BuildTimestampValueSource.java (original)
+++ maven/components/branches/maven-2.0.10-RC/maven-project/src/main/java/org/apache/maven/project/interpolation/BuildTimestampValueSource.java Thu Aug  7 15:33:15 2008
@@ -32,20 +32,27 @@
     implements ValueSource
 {
 
+    private final Date startTime;
+
+    private final String format;
+    
     private String formattedDate;
 
     public BuildTimestampValueSource( Date startTime, String format )
     {
-        if ( startTime != null )
-        {
-            formattedDate = new SimpleDateFormat( format ).format( startTime );
-        }
+        this.startTime = startTime;
+        this.format = format;
     }
 
     public Object getValue( String expression )
     {
         if ( "build.timestamp".equals( expression ) || "maven.build.timestamp".equals( expression ) )
         {
+            if ( formattedDate == null && startTime != null )
+            {
+                formattedDate = new SimpleDateFormat( format ).format( startTime );
+            }
+            
             return formattedDate;
         }
 

Modified: maven/components/branches/maven-2.0.10-RC/maven-project/src/main/java/org/apache/maven/project/interpolation/RegexBasedModelInterpolator.java
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.0.10-RC/maven-project/src/main/java/org/apache/maven/project/interpolation/RegexBasedModelInterpolator.java?rev=683740&r1=683739&r2=683740&view=diff
==============================================================================
--- maven/components/branches/maven-2.0.10-RC/maven-project/src/main/java/org/apache/maven/project/interpolation/RegexBasedModelInterpolator.java (original)
+++ maven/components/branches/maven-2.0.10-RC/maven-project/src/main/java/org/apache/maven/project/interpolation/RegexBasedModelInterpolator.java Thu Aug  7 15:33:15 2008
@@ -36,6 +36,8 @@
 import org.codehaus.plexus.interpolation.ValueSource;
 import org.codehaus.plexus.logging.AbstractLogEnabled;
 import org.codehaus.plexus.logging.Logger;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
 import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
 
 import java.io.File;
@@ -58,7 +60,7 @@
  */
 public class RegexBasedModelInterpolator
     extends AbstractLogEnabled
-    implements ModelInterpolator
+    implements ModelInterpolator, Initializable
 {
     private static final List PROJECT_PREFIXES = Arrays.asList( new String[]{ "pom.", "project." } );
 
@@ -85,6 +87,10 @@
     }
 
     private PathTranslator pathTranslator;
+    
+    private RegexBasedInterpolator interpolator;
+    
+    private RecursionInterceptor recursionInterceptor;
 
     public RegexBasedModelInterpolator( Properties envars )
     {
@@ -141,7 +147,7 @@
                               boolean debugEnabled )
         throws ModelInterpolationException
     {
-        StringWriter sWriter = new StringWriter();
+        StringWriter sWriter = new StringWriter( 1024 );
 
         MavenXpp3Writer writer = new MavenXpp3Writer();
         try
@@ -224,78 +230,105 @@
         },
         PROJECT_PREFIXES, true );
 
-        RegexBasedInterpolator interpolator = new RegexBasedInterpolator();
-
-        // NOTE: Order counts here!
-        interpolator.addValueSource( basedirValueSource );
-        interpolator.addValueSource( new BuildTimestampValueSource( config.getBuildStartTime(), timestampFormat ) );
-        interpolator.addValueSource( new MapBasedValueSource( config.getExecutionProperties() ) );
-        interpolator.addValueSource( modelValueSource1 );
-        interpolator.addValueSource( new PrefixedValueSourceWrapper( new MapBasedValueSource( modelProperties ), PROJECT_PREFIXES, true ) );
-        interpolator.addValueSource( modelValueSource2 );
-        interpolator.addValueSource( new MapBasedValueSource( config.getUserProperties() ) );
-        
         PathTranslatingPostProcessor pathTranslatingPostProcessor =
             new PathTranslatingPostProcessor( TRANSLATED_PATH_EXPRESSIONS, projectDir, pathTranslator );
         
-        interpolator.addPostProcessor( pathTranslatingPostProcessor );
-
-        RecursionInterceptor recursionInterceptor = new PrefixAwareRecursionInterceptor( PROJECT_PREFIXES );
-
         String result = src;
-        try
-        {
-            result = interpolator.interpolate( result, "", recursionInterceptor );
-        }
-        catch( InterpolationException e )
+        synchronized( this )
         {
-            throw new ModelInterpolationException( e.getMessage(), e );
-        }
-
-        if ( debug )
-        {
-            List feedback = interpolator.getFeedback();
-            if ( feedback != null && !feedback.isEmpty() )
+            List valueSources = new ArrayList( 7 );
+            
+            // NOTE: Order counts here!
+            valueSources.add( basedirValueSource );
+            valueSources.add( new BuildTimestampValueSource( config.getBuildStartTime(), timestampFormat ) );
+            valueSources.add( new MapBasedValueSource( config.getExecutionProperties() ) );
+            valueSources.add( modelValueSource1 );
+            valueSources.add( new PrefixedValueSourceWrapper( new MapBasedValueSource( modelProperties ), PROJECT_PREFIXES, true ) );
+            valueSources.add( modelValueSource2 );
+            valueSources.add( new MapBasedValueSource( config.getUserProperties() ) );
+            
+            for ( Iterator it = valueSources.iterator(); it.hasNext(); )
             {
-                logger.debug( "Maven encountered the following problems during initial POM interpolation:" );
+                ValueSource vs = (ValueSource) it.next();
+                interpolator.addValueSource( vs );
+            }
+            
+            interpolator.addPostProcessor( pathTranslatingPostProcessor );
 
-                Object last = null;
-                for ( Iterator it = feedback.iterator(); it.hasNext(); )
+            try
+            {
+                try
+                {
+                    result = interpolator.interpolate( result, "", recursionInterceptor );
+                }
+                catch( InterpolationException e )
                 {
-                    Object next = it.next();
+                    throw new ModelInterpolationException( e.getMessage(), e );
+                }
 
-                    if ( next instanceof Throwable )
+                if ( debug )
+                {
+                    List feedback = interpolator.getFeedback();
+                    if ( feedback != null && !feedback.isEmpty() )
                     {
-                        if ( last == null )
-                        {
-                            logger.debug( "", ( (Throwable) next ) );
-                        }
-                        else
+                        logger.debug( "Maven encountered the following problems during initial POM interpolation:" );
+
+                        Object last = null;
+                        for ( Iterator it = feedback.iterator(); it.hasNext(); )
                         {
-                            logger.debug( String.valueOf( last ), ( (Throwable) next ) );
+                            Object next = it.next();
+
+                            if ( next instanceof Throwable )
+                            {
+                                if ( last == null )
+                                {
+                                    logger.debug( "", ( (Throwable) next ) );
+                                }
+                                else
+                                {
+                                    logger.debug( String.valueOf( last ), ( (Throwable) next ) );
+                                }
+                            }
+                            else
+                            {
+                                if ( last != null )
+                                {
+                                    logger.debug( String.valueOf( last ) );
+                                }
+
+                                last = next;
+                            }
                         }
-                    }
-                    else
-                    {
+
                         if ( last != null )
                         {
                             logger.debug( String.valueOf( last ) );
                         }
-
-                        last = next;
                     }
                 }
 
-                if ( last != null )
+                interpolator.clearFeedback();
+            }
+            finally
+            {
+                for ( Iterator iterator = valueSources.iterator(); iterator.hasNext(); )
                 {
-                    logger.debug( String.valueOf( last ) );
+                    ValueSource vs = (ValueSource) iterator.next();
+                    interpolator.removeValuesSource( vs );
                 }
+                
+                interpolator.removePostProcessor( pathTranslatingPostProcessor );
             }
         }
 
-        interpolator.clearFeedback();
-
         return result;
     }
 
+    public void initialize()
+        throws InitializationException
+    {
+        interpolator = new RegexBasedInterpolator();
+        recursionInterceptor = new PrefixAwareRecursionInterceptor( PROJECT_PREFIXES );
+    }
+
 }

Modified: maven/components/branches/maven-2.0.10-RC/maven-project/src/test/java/org/apache/maven/project/MavenProjectDynamismTest.java
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.0.10-RC/maven-project/src/test/java/org/apache/maven/project/MavenProjectDynamismTest.java?rev=683740&r1=683739&r2=683740&view=diff
==============================================================================
--- maven/components/branches/maven-2.0.10-RC/maven-project/src/test/java/org/apache/maven/project/MavenProjectDynamismTest.java (original)
+++ maven/components/branches/maven-2.0.10-RC/maven-project/src/test/java/org/apache/maven/project/MavenProjectDynamismTest.java Thu Aug  7 15:33:15 2008
@@ -19,31 +19,25 @@
  * under the License.
  */
 
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
 import org.apache.maven.model.Build;
 import org.apache.maven.model.Dependency;
-import org.apache.maven.model.Model;
 import org.apache.maven.model.Plugin;
 import org.apache.maven.model.Resource;
-import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
 import org.apache.maven.project.interpolation.ModelInterpolationException;
 import org.codehaus.plexus.PlexusTestCase;
 import org.codehaus.plexus.util.StringUtils;
 import org.codehaus.plexus.util.xml.Xpp3Dom;
 import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
 
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.StringWriter;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.net.URLDecoder;
-import java.net.URLEncoder;
-import java.util.Iterator;
-import java.util.List;
-
 public class MavenProjectDynamismTest
     extends PlexusTestCase
 {
@@ -471,31 +465,86 @@
                       compileSourceRoots.get( 1 ) );
     }
 
+    public void testShouldMaintainAddedAndExistingPluginEntriesInRoundTrip()
+        throws IOException, XmlPullParserException, URISyntaxException, ProjectBuildingException,
+        ModelInterpolationException
+    {
+        // TODO: Make this run!
+        MavenProject project = buildProject( "pom-plugins.xml" );
+
+        String firstPlugin = "one:first-maven-plugin";
+        String secondPlugin = "two:second-maven-plugin";
+        String thirdPlugin = "three:third-maven-plugin";
+        
+        project.getBuild().flushPluginMap();
+        Map pluginMap = project.getBuild().getPluginsAsMap();
+        
+        assertNotNull( "Before calculating concrete state, project should contain plugin: " + firstPlugin, pluginMap.get( firstPlugin ) );
+        assertNotNull( "Before calculating concrete state, project should contain plugin: " + secondPlugin, pluginMap.get( secondPlugin ) );
+        assertNull( "Before calculating concrete state, project should NOT contain plugin: " + thirdPlugin, pluginMap.get( thirdPlugin ) );
+
+        ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration();
+        projectBuilder.calculateConcreteState( project, config );
+        
+        project.getBuild().flushPluginMap();
+        pluginMap = project.getBuild().getPluginsAsMap();
+        
+        assertNotNull( "After calculating concrete state, project should contain plugin: " + firstPlugin, pluginMap.get( firstPlugin ) );
+        assertNotNull( "After calculating concrete state, project should contain plugin: " + secondPlugin, pluginMap.get( secondPlugin ) );
+        assertNull( "After calculating concrete state, project should NOT contain plugin: " + thirdPlugin, pluginMap.get( thirdPlugin ) );
+        
+        Plugin third = new Plugin();
+        third.setGroupId( "three" );
+        third.setArtifactId( "third-maven-plugin" );
+        third.setVersion( "3" );
+        
+        project.addPlugin( third );
+        
+        project.getBuild().flushPluginMap();
+        pluginMap = project.getBuild().getPluginsAsMap();
+        
+        assertNotNull( "After adding third plugin, project should contain plugin: " + firstPlugin, pluginMap.get( firstPlugin ) );
+        assertNotNull( "After adding third plugin, project should contain plugin: " + secondPlugin, pluginMap.get( secondPlugin ) );
+        assertNotNull( "After adding third plugin, project should contain plugin: " + thirdPlugin, pluginMap.get( thirdPlugin ) );
+        
+        projectBuilder.restoreDynamicState( project, config );
+
+        project.getBuild().flushPluginMap();
+        pluginMap = project.getBuild().getPluginsAsMap();
+        
+        assertNotNull( "After restoring project dynamism, project should contain plugin: " + firstPlugin, pluginMap.get( firstPlugin ) );
+        assertNotNull( "After restoring project dynamism, project should contain plugin: " + secondPlugin, pluginMap.get( secondPlugin ) );
+        assertNotNull( "After restoring project dynamism, project should contain plugin: " + thirdPlugin, pluginMap.get( thirdPlugin ) );
+    }
+
     public void testShouldInterpolatePluginLevelDependency()
         throws IOException, XmlPullParserException, URISyntaxException, ProjectBuildingException,
         ModelInterpolationException
     {
         MavenProject project = buildProject( "plugin-level-dep.pom.xml" );
 
-        Plugin plugin = (Plugin) project.getBuild().getPluginsAsMap().get( "org.apache.maven.plugins:maven-compiler-plugin" );
-        
+        Plugin plugin =
+            (Plugin) project.getBuild().getPluginsAsMap().get( "org.apache.maven.plugins:maven-compiler-plugin" );
+
         assertNotNull( "ERROR - compiler plugin config not found!", plugin );
-        assertTrue( "ERROR - compiler plugin custom dependencies not found!", ( plugin.getDependencies() != null && !plugin.getDependencies().isEmpty() ) );
-        
+        assertTrue( "ERROR - compiler plugin custom dependencies not found!",
+                    ( plugin.getDependencies() != null && !plugin.getDependencies().isEmpty() ) );
+
         Dependency dep = (Dependency) plugin.getDependencies().get( 0 );
-        
-        assertEquals( "custom dependency version should be an INTERPOLATED reference to this project's version.", project.getVersion(), dep.getVersion() );
+
+        assertEquals( "custom dependency version should be an INTERPOLATED reference to this project's version.",
+                      project.getVersion(), dep.getVersion() );
     }
 
     // Useful for diagnostics.
-//    private void displayPOM( Model model )
-//        throws IOException
-//    {
-//        StringWriter writer = new StringWriter();
-//        new MavenXpp3Writer().write( writer, model );
-//
-//        System.out.println( writer.toString() );
-//    }
+    // private void displayPOM( Model model )
+    // throws IOException
+    // {
+    // StringWriter writer = new StringWriter();
+    // new MavenXpp3Writer().write( writer, model );
+    //
+    // System.out.println( writer.toString() );
+    // }
 
     private void assertResourcePresent( String testLabel, String directory, List resources )
     {

Modified: maven/components/branches/maven-2.0.10-RC/maven-project/src/test/java/org/apache/maven/project/interpolation/RegexBasedModelInterpolatorTest.java
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.0.10-RC/maven-project/src/test/java/org/apache/maven/project/interpolation/RegexBasedModelInterpolatorTest.java?rev=683740&r1=683739&r2=683740&view=diff
==============================================================================
--- maven/components/branches/maven-2.0.10-RC/maven-project/src/test/java/org/apache/maven/project/interpolation/RegexBasedModelInterpolatorTest.java (original)
+++ maven/components/branches/maven-2.0.10-RC/maven-project/src/test/java/org/apache/maven/project/interpolation/RegexBasedModelInterpolatorTest.java Thu Aug  7 15:33:15 2008
@@ -29,6 +29,7 @@
 import org.apache.maven.project.DefaultProjectBuilderConfiguration;
 import org.apache.maven.project.path.DefaultPathTranslator;
 import org.apache.maven.project.path.PathTranslator;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
 
 import java.io.File;
 import java.io.IOException;
@@ -49,7 +50,7 @@
     extends TestCase
 {
     private Map context;
-
+    
     protected void setUp()
         throws Exception
     {
@@ -59,7 +60,7 @@
     }
 
     public void testShouldNotThrowExceptionOnReferenceToNonExistentValue()
-        throws IOException, ModelInterpolationException
+        throws IOException, ModelInterpolationException, InitializationException
     {
         Model model = new Model();
 
@@ -68,13 +69,16 @@
 
         model.setScm( scm );
 
-        Model out = new RegexBasedModelInterpolator().interpolate( model, context );
+        RegexBasedModelInterpolator interpolator = new RegexBasedModelInterpolator();
+        interpolator.initialize();
+        
+        Model out = interpolator.interpolate( model, context );
 
         assertEquals( "${test}/somepath", out.getScm().getConnection() );
     }
 
     public void testShouldThrowExceptionOnRecursiveScmConnectionReference()
-        throws IOException
+        throws IOException, InitializationException
     {
         Model model = new Model();
 
@@ -85,7 +89,10 @@
 
         try
         {
-            Model out = new RegexBasedModelInterpolator().interpolate( model, context );
+            RegexBasedModelInterpolator interpolator = new RegexBasedModelInterpolator();
+            interpolator.initialize();
+            
+            interpolator.interpolate( model, context );
 
             fail( "The interpolator should not allow self-referencing expressions in POM." );
         }
@@ -96,7 +103,7 @@
     }
 
     public void testShouldNotThrowExceptionOnReferenceToValueContainingNakedExpression()
-        throws IOException, ModelInterpolationException
+        throws IOException, ModelInterpolationException, InitializationException
     {
         Model model = new Model();
 
@@ -107,8 +114,11 @@
 
         model.addProperty( "test", "test" );
 
-        Model out = new RegexBasedModelInterpolator().interpolate( model, context );
-
+        RegexBasedModelInterpolator interpolator = new RegexBasedModelInterpolator();
+        interpolator.initialize();
+        
+        Model out = interpolator.interpolate( model, context );
+        
         assertEquals( "test/somepath", out.getScm().getConnection() );
     }
 
@@ -125,8 +135,11 @@
 
         model.setOrganization( org );
 
-        Model out = new RegexBasedModelInterpolator().interpolate( model, context );
-
+        RegexBasedModelInterpolator interpolator = new RegexBasedModelInterpolator();
+        interpolator.initialize();
+        
+        Model out = interpolator.interpolate( model, context );
+        
         assertEquals( orgName + " Tools", out.getName() );
     }
 
@@ -141,8 +154,11 @@
 
         model.addDependency( dep );
 
-        Model out = new RegexBasedModelInterpolator().interpolate( model, context );
-
+        RegexBasedModelInterpolator interpolator = new RegexBasedModelInterpolator();
+        interpolator.initialize();
+        
+        Model out = interpolator.interpolate( model, context );
+        
         assertEquals( "3.8.1", ( (Dependency) out.getDependencies().get( 0 ) ).getVersion() );
     }
 
@@ -172,8 +188,11 @@
          }
          */
 
-        Model out = new RegexBasedModelInterpolator().interpolate( model, context );
-
+        RegexBasedModelInterpolator interpolator = new RegexBasedModelInterpolator();
+        interpolator.initialize();
+        
+        Model out = interpolator.interpolate( model, context );
+        
         assertEquals( "${something}", ( (Dependency) out.getDependencies().get( 0 ) ).getVersion() );
     }
 
@@ -189,8 +208,11 @@
 
         model.addDependency( dep );
 
-        Model out = new RegexBasedModelInterpolator().interpolate( model, context );
-
+        RegexBasedModelInterpolator interpolator = new RegexBasedModelInterpolator();
+        interpolator.initialize();
+        
+        Model out = interpolator.interpolate( model, context );
+        
         assertEquals( "foo-3.8.1", ( (Dependency) out.getDependencies().get( 0 ) ).getVersion() );
     }
 
@@ -207,8 +229,11 @@
 
         model.addRepository( repository );
 
-        Model out = new RegexBasedModelInterpolator().interpolate( model, context );
-
+        RegexBasedModelInterpolator interpolator = new RegexBasedModelInterpolator();
+        interpolator.initialize();
+        
+        Model out = interpolator.interpolate( model, context );
+        
         assertEquals( "file://localhost/myBasedir/temp-repo", ( (Repository) out.getRepositories().get( 0 ) ).getUrl() );
     }
 
@@ -227,8 +252,11 @@
 
         model.setProperties( modelProperties );
 
-        Model out = new RegexBasedModelInterpolator().interpolate( model, context );
-
+        RegexBasedModelInterpolator interpolator = new RegexBasedModelInterpolator();
+        interpolator.initialize();
+        
+        Model out = interpolator.interpolate( model, context );
+        
         assertEquals( out.getProperties().getProperty( "outputDirectory" ), "/path/to/home" );
     }
 
@@ -245,7 +273,10 @@
 
         model.setProperties( modelProperties );
 
-        Model out = new RegexBasedModelInterpolator( envars ).interpolate( model, context );
+        RegexBasedModelInterpolator interpolator = new RegexBasedModelInterpolator( envars );
+        interpolator.initialize();
+        
+        Model out = interpolator.interpolate( model, context );
 
         assertEquals( out.getProperties().getProperty( "outputDirectory" ), "${env.DOES_NOT_EXIST}" );
     }
@@ -261,8 +292,11 @@
 
         model.setProperties( modelProperties );
 
-        Model out = new RegexBasedModelInterpolator().interpolate( model, context );
-
+        RegexBasedModelInterpolator interpolator = new RegexBasedModelInterpolator();
+        interpolator.initialize();
+        
+        Model out = interpolator.interpolate( model, context );
+        
         assertEquals( out.getProperties().getProperty( "outputDirectory" ), "${DOES_NOT_EXIST}" );
     }
 
@@ -291,8 +325,11 @@
 
         model.setBuild( build );
 
-        Model out = new RegexBasedModelInterpolator().interpolate( model, context );
-
+        RegexBasedModelInterpolator interpolator = new RegexBasedModelInterpolator();
+        interpolator.initialize();
+        
+        Model out = interpolator.interpolate( model, context );
+        
         List outResources = out.getBuild().getResources();
         Iterator resIt = outResources.iterator();
 
@@ -302,7 +339,7 @@
     }
 
     public void testShouldInterpolateUnprefixedBasedirExpression()
-        throws ModelInterpolationException, IOException
+        throws ModelInterpolationException, IOException, InitializationException
     {
         File basedir = new File( "/test/path" );
         Model model = new Model();
@@ -311,7 +348,10 @@
 
         model.addDependency( dep );
 
-        Model result = new RegexBasedModelInterpolator().interpolate( model, basedir, new DefaultProjectBuilderConfiguration(), true );
+        RegexBasedModelInterpolator interpolator = new RegexBasedModelInterpolator();
+        interpolator.initialize();
+        
+        Model result = interpolator.interpolate( model, basedir, new DefaultProjectBuilderConfiguration(), true );
 
         List rDeps = result.getDependencies();
         assertNotNull( rDeps );
@@ -333,6 +373,7 @@
         
         PathTranslator translator = new DefaultPathTranslator();
         RegexBasedModelInterpolator interpolator = new RegexBasedModelInterpolator( translator );
+        interpolator.initialize();
         
         File basedir = new File( System.getProperty( "java.io.tmpdir" ), "base" );
         

Added: maven/components/branches/maven-2.0.10-RC/maven-project/src/test/resources/project-dynamism/pom-plugins.xml
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.0.10-RC/maven-project/src/test/resources/project-dynamism/pom-plugins.xml?rev=683740&view=auto
==============================================================================
--- maven/components/branches/maven-2.0.10-RC/maven-project/src/test/resources/project-dynamism/pom-plugins.xml (added)
+++ maven/components/branches/maven-2.0.10-RC/maven-project/src/test/resources/project-dynamism/pom-plugins.xml Thu Aug  7 15:33:15 2008
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" 
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+         
+  <modelVersion>4.0.0</modelVersion>
+  
+  <groupId>org.test</groupId>
+  <artifactId>test-build-dynamism</artifactId>
+  <version>1</version>
+  
+  <properties>
+    <myProperty>${pom.build.directory}</myProperty>
+  </properties>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>one</groupId>
+        <artifactId>first-maven-plugin</artifactId>
+        <version>1</version>
+      </plugin>
+      <plugin>
+        <groupId>two</groupId>
+        <artifactId>second-maven-plugin</artifactId>
+        <version>2</version>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>
\ No newline at end of file

Modified: maven/components/branches/maven-2.0.10-RC/pom.xml
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.0.10-RC/pom.xml?rev=683740&r1=683739&r2=683740&view=diff
==============================================================================
--- maven/components/branches/maven-2.0.10-RC/pom.xml (original)
+++ maven/components/branches/maven-2.0.10-RC/pom.xml Thu Aug  7 15:33:15 2008
@@ -206,6 +206,7 @@
               <!-- TODO: These represent method ADDITIONS from 2.0.9, and should be removed after 
                    2.0.10 is released. -->
               <exclude>org/apache/maven/lifecycle/LifecycleExecutor*</exclude>
+              <exclude>org/apache/maven/artifact/metadata/AbstractArtifactMetadata*</exclude>
               <exclude>org/apache/maven/artifact/metadata/ArtifactMetadataSource*</exclude>
               <exclude>org/apache/maven/project/MavenProjectBuilder*</exclude>
               <exclude>org/apache/maven/project/ProjectBuilderConfiguration*</exclude>



Mime
View raw message