maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdca...@apache.org
Subject svn commit: r666318 - in /maven/components/branches/john-2.0.x-dynamicBuild: maven-artifact-manager/src/test/java/org/apache/maven/artifact/resolver/ maven-artifact/src/test/java/org/apache/maven/artifact/resolver/ maven-core/src/main/java/org/apache/m...
Date Tue, 10 Jun 2008 20:55:19 GMT
Author: jdcasey
Date: Tue Jun 10 13:55:18 2008
New Revision: 666318

URL: http://svn.apache.org/viewvc?rev=666318&view=rev
Log:
[MNG-3530] All tests pass, time to write this branch up and submit it for discussion.

Added:
    maven/components/branches/john-2.0.x-dynamicBuild/maven-project/src/test/resources/project-dynamism/pom-interp.xml   (with props)
Modified:
    maven/components/branches/john-2.0.x-dynamicBuild/maven-artifact-manager/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolverTest.java
    maven/components/branches/john-2.0.x-dynamicBuild/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/DefaultArtifactCollectorTest.java
    maven/components/branches/john-2.0.x-dynamicBuild/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
    maven/components/branches/john-2.0.x-dynamicBuild/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java
    maven/components/branches/john-2.0.x-dynamicBuild/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java
    maven/components/branches/john-2.0.x-dynamicBuild/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java
    maven/components/branches/john-2.0.x-dynamicBuild/maven-core/src/main/java/org/apache/maven/extension/DefaultExtensionManager.java
    maven/components/branches/john-2.0.x-dynamicBuild/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
    maven/components/branches/john-2.0.x-dynamicBuild/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
    maven/components/branches/john-2.0.x-dynamicBuild/maven-project/src/test/java/org/apache/maven/project/MavenProjectDynamismTest.java

Modified: maven/components/branches/john-2.0.x-dynamicBuild/maven-artifact-manager/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolverTest.java
URL: http://svn.apache.org/viewvc/maven/components/branches/john-2.0.x-dynamicBuild/maven-artifact-manager/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolverTest.java?rev=666318&r1=666317&r2=666318&view=diff
==============================================================================
--- maven/components/branches/john-2.0.x-dynamicBuild/maven-artifact-manager/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolverTest.java (original)
+++ maven/components/branches/john-2.0.x-dynamicBuild/maven-artifact-manager/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolverTest.java Tue Jun 10 13:55:18 2008
@@ -29,7 +29,7 @@
 
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.HashSet;
+import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Set;
 
@@ -106,7 +106,7 @@
                                              List remoteRepositories )
                 throws ArtifactMetadataRetrievalException
             {
-                Set dependencies = new HashSet();
+                Set dependencies = new LinkedHashSet();
 
                 if ( "g".equals( artifact.getArtifactId() ) )
                 {
@@ -162,7 +162,7 @@
                                              List remoteRepositories )
                 throws ArtifactMetadataRetrievalException
             {
-                Set dependencies = new HashSet();
+                Set dependencies = new LinkedHashSet();
 
                 if ( "i".equals( artifact.getArtifactId() ) )
                 {

Modified: maven/components/branches/john-2.0.x-dynamicBuild/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/DefaultArtifactCollectorTest.java
URL: http://svn.apache.org/viewvc/maven/components/branches/john-2.0.x-dynamicBuild/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/DefaultArtifactCollectorTest.java?rev=666318&r1=666317&r2=666318&view=diff
==============================================================================
--- maven/components/branches/john-2.0.x-dynamicBuild/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/DefaultArtifactCollectorTest.java (original)
+++ maven/components/branches/john-2.0.x-dynamicBuild/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/DefaultArtifactCollectorTest.java Tue Jun 10 13:55:18 2008
@@ -19,17 +19,6 @@
  * under the License.
  */
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.factory.ArtifactFactory;
 import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
@@ -45,6 +34,17 @@
 import org.apache.maven.artifact.versioning.VersionRange;
 import org.codehaus.plexus.PlexusTestCase;
 
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
 /**
  * Test the default artifact collector.
  *
@@ -69,11 +69,11 @@
     {
         super.setUp();
 
-        this.source = new Source();
-        this.artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
-        this.artifactCollector = new DefaultArtifactCollector();
+        source = new Source();
+        artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
+        artifactCollector = new DefaultArtifactCollector();
 
-        this.projectArtifact = createArtifactSpec( "project", "1.0", null );
+        projectArtifact = createArtifactSpec( "project", "1.0", null );
     }
 
     // works, but we don't fail on cycles presently
@@ -945,7 +945,7 @@
         private ArtifactSpec addDependency( String id, String version, String scope, boolean optional )
             throws InvalidVersionSpecificationException
         {
-            ArtifactSpec dep = createArtifactSpec( id, version, scope, this.artifact.getScope(), optional );
+            ArtifactSpec dep = createArtifactSpec( id, version, scope, artifact.getScope(), optional );
             return addDependency( dep );
         }
 
@@ -993,7 +993,7 @@
                                      ArtifactFilter dependencyFilter )
             throws InvalidVersionSpecificationException
         {
-            Set projectArtifacts = new HashSet();
+            Set projectArtifacts = new LinkedHashSet();
 
             for ( Iterator i = dependencies.iterator(); i.hasNext(); )
             {

Modified: maven/components/branches/john-2.0.x-dynamicBuild/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
URL: http://svn.apache.org/viewvc/maven/components/branches/john-2.0.x-dynamicBuild/maven-core/src/main/java/org/apache/maven/DefaultMaven.java?rev=666318&r1=666317&r2=666318&view=diff
==============================================================================
--- maven/components/branches/john-2.0.x-dynamicBuild/maven-core/src/main/java/org/apache/maven/DefaultMaven.java (original)
+++ maven/components/branches/john-2.0.x-dynamicBuild/maven-core/src/main/java/org/apache/maven/DefaultMaven.java Tue Jun 10 13:55:18 2008
@@ -37,11 +37,9 @@
 import org.apache.maven.monitor.event.MavenEvents;
 import org.apache.maven.profiles.ProfileManager;
 import org.apache.maven.profiles.activation.ProfileActivationException;
-import org.apache.maven.project.DefaultProjectBuilderConfiguration;
 import org.apache.maven.project.DuplicateProjectException;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.project.MavenProjectBuilder;
-import org.apache.maven.project.ProjectBuilderConfiguration;
 import org.apache.maven.project.ProjectBuildingException;
 import org.apache.maven.reactor.MavenExecutionException;
 import org.apache.maven.settings.Mirror;
@@ -575,12 +573,7 @@
             }
         }
 
-        ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration();
-        config.setLocalRepository( request.getLocalRepository() )
-              .setGlobalProfileManager( request.getGlobalProfileManager() )
-              .setUserProperties( request.getUserProperties() );
-
-        return projectBuilder.build( pom, config );
+        return projectBuilder.build( pom, request.getProjectBuilderConfiguration() );
     }
 
     // ----------------------------------------------------------------------

Modified: maven/components/branches/john-2.0.x-dynamicBuild/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java
URL: http://svn.apache.org/viewvc/maven/components/branches/john-2.0.x-dynamicBuild/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java?rev=666318&r1=666317&r2=666318&view=diff
==============================================================================
--- maven/components/branches/john-2.0.x-dynamicBuild/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java (original)
+++ maven/components/branches/john-2.0.x-dynamicBuild/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java Tue Jun 10 13:55:18 2008
@@ -23,6 +23,8 @@
 import org.apache.maven.monitor.event.EventDispatcher;
 import org.apache.maven.monitor.event.EventMonitor;
 import org.apache.maven.profiles.ProfileManager;
+import org.apache.maven.project.DefaultProjectBuilderConfiguration;
+import org.apache.maven.project.ProjectBuilderConfiguration;
 import org.apache.maven.settings.Settings;
 
 import java.util.Date;
@@ -204,4 +206,15 @@
     {
         return userProperties;
     }
+
+    public ProjectBuilderConfiguration getProjectBuilderConfiguration()
+    {
+        ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration();
+        config.setLocalRepository( getLocalRepository() )
+              .setGlobalProfileManager( getGlobalProfileManager() )
+              .setExecutionProperties( getExecutionProperties() )
+              .setUserProperties( getUserProperties() );
+
+        return config;
+    }
 }

Modified: maven/components/branches/john-2.0.x-dynamicBuild/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java
URL: http://svn.apache.org/viewvc/maven/components/branches/john-2.0.x-dynamicBuild/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java?rev=666318&r1=666317&r2=666318&view=diff
==============================================================================
--- maven/components/branches/john-2.0.x-dynamicBuild/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java (original)
+++ maven/components/branches/john-2.0.x-dynamicBuild/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java Tue Jun 10 13:55:18 2008
@@ -23,6 +23,7 @@
 import org.apache.maven.monitor.event.EventDispatcher;
 import org.apache.maven.monitor.event.EventMonitor;
 import org.apache.maven.profiles.ProfileManager;
+import org.apache.maven.project.ProjectBuilderConfiguration;
 import org.apache.maven.settings.Settings;
 
 import java.util.Date;
@@ -76,4 +77,6 @@
     Date getStartTime();
 
     boolean isShowErrors();
+
+    ProjectBuilderConfiguration getProjectBuilderConfiguration();
 }

Modified: maven/components/branches/john-2.0.x-dynamicBuild/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java
URL: http://svn.apache.org/viewvc/maven/components/branches/john-2.0.x-dynamicBuild/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java?rev=666318&r1=666317&r2=666318&view=diff
==============================================================================
--- maven/components/branches/john-2.0.x-dynamicBuild/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java (original)
+++ maven/components/branches/john-2.0.x-dynamicBuild/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java Tue Jun 10 13:55:18 2008
@@ -22,7 +22,9 @@
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.monitor.event.EventDispatcher;
 import org.apache.maven.plugin.descriptor.PluginDescriptor;
+import org.apache.maven.project.DefaultProjectBuilderConfiguration;
 import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.ProjectBuilderConfiguration;
 import org.apache.maven.settings.Settings;
 import org.codehaus.plexus.PlexusContainer;
 import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
@@ -90,6 +92,8 @@
 
         this.executionProperties = executionProperties;
 
+        this.userProperties = userProperties;
+
         this.startTime = startTime;
     }
 
@@ -205,4 +209,17 @@
         this.userProperties = userProperties;
     }
 
+    /**
+     * NOTE: This varies from {@link DefaultMavenExecutionRequest#getProjectBuilderConfiguration()} in that
+     * it doesn't supply a global profile manager.
+     */
+    public ProjectBuilderConfiguration getProjectBuilderConfiguration()
+    {
+        ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration();
+        config.setLocalRepository( getLocalRepository() )
+              .setExecutionProperties( getExecutionProperties() )
+              .setUserProperties( getUserProperties() );
+
+        return config;
+    }
 }
\ No newline at end of file

Modified: maven/components/branches/john-2.0.x-dynamicBuild/maven-core/src/main/java/org/apache/maven/extension/DefaultExtensionManager.java
URL: http://svn.apache.org/viewvc/maven/components/branches/john-2.0.x-dynamicBuild/maven-core/src/main/java/org/apache/maven/extension/DefaultExtensionManager.java?rev=666318&r1=666317&r2=666318&view=diff
==============================================================================
--- maven/components/branches/john-2.0.x-dynamicBuild/maven-core/src/main/java/org/apache/maven/extension/DefaultExtensionManager.java (original)
+++ maven/components/branches/john-2.0.x-dynamicBuild/maven-core/src/main/java/org/apache/maven/extension/DefaultExtensionManager.java Tue Jun 10 13:55:18 2008
@@ -19,16 +19,6 @@
  * under the License.
  */
 
-import java.io.File;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import java.util.jar.JarFile;
-
 import org.apache.maven.MavenArtifactFilterManager;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.ArtifactUtils;
@@ -63,6 +53,15 @@
 import org.codehaus.plexus.util.xml.Xpp3Dom;
 import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
 
+import java.io.File;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.jar.JarFile;
+
 /**
  * Used to locate extensions.
  *
@@ -119,16 +118,15 @@
 
             // We use the same hack here to make sure that plexus 1.1 is available for extensions that do
             // not declare plexus-utils but need it. MNG-2900
-            DefaultPluginManager.checkPlexusUtils( resolutionGroup, artifactFactory );
-
-            Set dependencies = new HashSet( resolutionGroup.getArtifacts() );
+            Set rgArtifacts = resolutionGroup.getArtifacts();
+            rgArtifacts = DefaultPluginManager.checkPlexusUtils( rgArtifacts, artifactFactory );
 
-            dependencies.add( artifact );
+            rgArtifacts.add( artifact );
 
             // Make sure that we do not influence the dependenecy resolution of extensions with the project's
             // dependencyManagement
 
-            ArtifactResolutionResult result = artifactResolver.resolveTransitively( dependencies, project.getArtifact(),
+            ArtifactResolutionResult result = artifactResolver.resolveTransitively( rgArtifacts, project.getArtifact(),
                                                                                     Collections.EMPTY_MAP,
                                                                                     //project.getManagedVersionMap(),
                                                                                     localRepository,
@@ -278,7 +276,7 @@
     public void contextualize( Context context )
         throws ContextException
     {
-        this.container = (DefaultPlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
+        container = (DefaultPlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
     }
 
     private static final class ProjectArtifactExceptionFilter
@@ -292,7 +290,7 @@
                                         Artifact projectArtifact )
         {
             this.passThroughFilter = passThroughFilter;
-            this.projectDependencyConflictId = projectArtifact.getDependencyConflictId();
+            projectDependencyConflictId = projectArtifact.getDependencyConflictId();
         }
 
         public boolean include( Artifact artifact )

Modified: maven/components/branches/john-2.0.x-dynamicBuild/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
URL: http://svn.apache.org/viewvc/maven/components/branches/john-2.0.x-dynamicBuild/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java?rev=666318&r1=666317&r2=666318&view=diff
==============================================================================
--- maven/components/branches/john-2.0.x-dynamicBuild/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java (original)
+++ maven/components/branches/john-2.0.x-dynamicBuild/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java Tue Jun 10 13:55:18 2008
@@ -52,10 +52,8 @@
 import org.apache.maven.plugin.version.PluginVersionManager;
 import org.apache.maven.plugin.version.PluginVersionNotFoundException;
 import org.apache.maven.plugin.version.PluginVersionResolutionException;
-import org.apache.maven.project.DefaultProjectBuilderConfiguration;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.project.MavenProjectBuilder;
-import org.apache.maven.project.ProjectBuilderConfiguration;
 import org.apache.maven.project.ProjectBuildingException;
 import org.apache.maven.project.artifact.InvalidDependencyVersionException;
 import org.apache.maven.project.artifact.MavenMetadataSource;
@@ -417,10 +415,24 @@
         Mojo plugin;
 
         PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor();
+
         String goalId = mojoDescriptor.getGoal();
         String groupId = pluginDescriptor.getGroupId();
         String artifactId = pluginDescriptor.getArtifactId();
         String executionId = mojoExecution.getExecutionId();
+
+        if ( !project.isConcrete() )
+        {
+            try
+            {
+                mavenProjectBuilder.calculateConcreteState( project, session.getProjectBuilderConfiguration() );
+            }
+            catch ( ModelInterpolationException e )
+            {
+                throw new PluginManagerException( "Failed to calculate concrete state for project: " + project, e );
+            }
+        }
+
         Xpp3Dom dom = project.getGoalConfiguration( groupId, artifactId, executionId, goalId );
         Xpp3Dom reportDom = project.getReportConfiguration( groupId, artifactId, executionId );
         dom = Xpp3Dom.mergeXpp3Dom( dom, reportDom );
@@ -429,20 +441,6 @@
             dom = Xpp3Dom.mergeXpp3Dom( dom, mojoExecution.getConfiguration() );
         }
 
-        ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration();
-        config.setExecutionProperties( session.getExecutionProperties() );
-        config.setLocalRepository( session.getLocalRepository() );
-        config.setUserProperties( session.getUserProperties() );
-
-        try
-        {
-            mavenProjectBuilder.calculateConcreteState( project, config );
-        }
-        catch ( ModelInterpolationException e )
-        {
-            throw new PluginManagerException( "Failed to calculate concrete state for project: " + project, e );
-        }
-
         plugin = getConfiguredMojo( session, dom, project, false, mojoExecution );
 
         // Event monitoring.
@@ -542,7 +540,7 @@
 
         try
         {
-            mavenProjectBuilder.restoreDynamicState( project, config );
+            mavenProjectBuilder.restoreDynamicState( project, session.getProjectBuilderConfiguration() );
         }
         catch ( ModelInterpolationException e )
         {
@@ -715,7 +713,9 @@
                     pluginArtifact.getId() + "': " + e.getMessage(), pluginArtifact, e );
             }
 
-            checkPlexusUtils( resolutionGroup, artifactFactory );
+            Set rgArtifacts = resolutionGroup.getArtifacts();
+
+            rgArtifacts = checkPlexusUtils( rgArtifacts, artifactFactory );
 
             // [jdcasey; 20-March-2008]:
             // This is meant to eliminate the introduction of duplicated artifacts.
@@ -745,7 +745,7 @@
             all.addAll( pluginDescriptor.getIntroducedDependencyArtifacts() );
 
             // add in the deps from the plugin POM now.
-            all.addAll( resolutionGroup.getArtifacts() );
+            all.addAll( rgArtifacts );
 
             for ( Iterator it = all.iterator(); it.hasNext(); )
             {
@@ -857,7 +857,7 @@
         }
     }
 
-    public static void checkPlexusUtils( ResolutionGroup resolutionGroup, ArtifactFactory artifactFactory )
+    public static Set checkPlexusUtils( Set dependencyArtifacts, ArtifactFactory artifactFactory )
     {
         // ----------------------------------------------------------------------------
         // If the plugin already declares a dependency on plexus-utils then we're all
@@ -882,7 +882,7 @@
 
         boolean plexusUtilsPresent = false;
 
-        for ( Iterator i = resolutionGroup.getArtifacts().iterator(); i.hasNext(); )
+        for ( Iterator i = dependencyArtifacts.iterator(); i.hasNext(); )
         {
             Artifact a = (Artifact) i.next();
 
@@ -901,9 +901,19 @@
             // version to the latest version we know that works as of the 2.0.6 release. We set the scope to runtime
             // as this is what's implicitly happening in 2.0.6.
 
-            resolutionGroup.getArtifacts().add( artifactFactory.createArtifact( "org.codehaus.plexus",
-                                                                                "plexus-utils", "1.1",
-                                                                                Artifact.SCOPE_RUNTIME, "jar" ) );
+            Set result = new LinkedHashSet();
+            if ( !dependencyArtifacts.isEmpty() )
+            {
+                result.addAll( dependencyArtifacts );
+            }
+
+            result.add( artifactFactory.createArtifact( "org.codehaus.plexus", "plexus-utils", "1.1", Artifact.SCOPE_RUNTIME, "jar" ) );
+
+            return result;
+        }
+        else
+        {
+            return dependencyArtifacts;
         }
     }
 

Modified: maven/components/branches/john-2.0.x-dynamicBuild/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
URL: http://svn.apache.org/viewvc/maven/components/branches/john-2.0.x-dynamicBuild/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java?rev=666318&r1=666317&r2=666318&view=diff
==============================================================================
--- maven/components/branches/john-2.0.x-dynamicBuild/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java (original)
+++ maven/components/branches/john-2.0.x-dynamicBuild/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java Tue Jun 10 13:55:18 2008
@@ -46,6 +46,7 @@
 import org.apache.maven.model.Model;
 import org.apache.maven.model.Parent;
 import org.apache.maven.model.Plugin;
+import org.apache.maven.model.PluginManagement;
 import org.apache.maven.model.Profile;
 import org.apache.maven.model.ReportPlugin;
 import org.apache.maven.model.Repository;
@@ -906,6 +907,15 @@
             project.setFile( projectDescriptor );
         }
 
+//        try
+//        {
+//            calculateConcreteState( project, config );
+//        }
+//        catch ( ModelInterpolationException e )
+//        {
+//            throw new InvalidProjectModelException( projectId, pomLocation, e.getMessage(), e );
+//        }
+
         project.setManagedVersionMap( createManagedVersionMap( projectId,
                                                                project.getDependencyManagement(),
                                                                project.getParent() ) );
@@ -980,49 +990,13 @@
 
         activeProfiles.addAll( injectedProfiles );
 
-        // 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();
-
-        Build build = model.getBuild();
-
-        if ( projectDir != null )
-        {
-            context.put( "basedir", projectDir.getAbsolutePath() );
-
-            // MNG-1927, MNG-2124, MNG-3355:
-            // If the build section is present and the project directory is non-null, we should make
-            // sure interpolation of the directories below uses translated paths.
-            // Afterward, we'll double back and translate any paths that weren't covered during interpolation via the
-            // code below...
-            context.put( "build.directory", pathTranslator.alignToBaseDirectory( build.getDirectory(), projectDir ) );
-            context.put( "build.outputDirectory", pathTranslator.alignToBaseDirectory( build.getOutputDirectory(), projectDir ) );
-            context.put( "build.testOutputDirectory", pathTranslator.alignToBaseDirectory( build.getTestOutputDirectory(), projectDir ) );
-            context.put( "build.sourceDirectory", pathTranslator.alignToBaseDirectory( build.getSourceDirectory(), projectDir ) );
-            context.put( "build.testSourceDirectory", pathTranslator.alignToBaseDirectory( build.getTestSourceDirectory(), projectDir ) );
-        }
-
-        if ( !isSuperPom )
-        {
-            Properties userProps = config.getUserProperties();
-            if ( userProps != null )
-            {
-                context.putAll( userProps );
-            }
-        }
-
         Build dynamicBuild = model.getBuild();
-        model.setBuild( new Build() );
 
-        model = modelInterpolator.interpolate( model, context, strict );
+        model.setBuild( ModelUtils.cloneBuild( dynamicBuild ) );
 
-        // second pass allows ${user.home} to work, if it needs to.
-        // [MNG-2339] ensure the system properties are still interpolated for backwards compat, but the model values must win
-        if ( config.getExecutionProperties() != null && !config.getExecutionProperties().isEmpty() )
-        {
-            context.putAll( config.getExecutionProperties() );
-        }
+        model = interpolate( model, projectDir, isSuperPom, config, strict );
 
-        model = modelInterpolator.interpolate( model, context, strict );
+        mergeDeterministicBuildElements( model.getBuild(), dynamicBuild );
 
         model.setBuild( dynamicBuild );
 
@@ -1124,6 +1098,106 @@
         return project;
     }
 
+    private Model interpolate( Model model,
+                              File projectDir,
+                              boolean isSuperPom,
+                              ProjectBuilderConfiguration config,
+                              boolean strict )
+        throws ModelInterpolationException
+    {
+        // 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();
+
+        Build build = model.getBuild();
+
+        if ( projectDir != null )
+        {
+            context.put( "basedir", projectDir.getAbsolutePath() );
+
+            // MNG-1927, MNG-2124, MNG-3355:
+            // If the build section is present and the project directory is non-null, we should make
+            // sure interpolation of the directories below uses translated paths.
+            // Afterward, we'll double back and translate any paths that weren't covered during interpolation via the
+            // code below...
+            context.put( "build.directory", pathTranslator.alignToBaseDirectory( build.getDirectory(), projectDir ) );
+            context.put( "build.outputDirectory", pathTranslator.alignToBaseDirectory( build.getOutputDirectory(), projectDir ) );
+            context.put( "build.testOutputDirectory", pathTranslator.alignToBaseDirectory( build.getTestOutputDirectory(), projectDir ) );
+            context.put( "build.sourceDirectory", pathTranslator.alignToBaseDirectory( build.getSourceDirectory(), projectDir ) );
+            context.put( "build.testSourceDirectory", pathTranslator.alignToBaseDirectory( build.getTestSourceDirectory(), projectDir ) );
+        }
+
+        if ( !isSuperPom )
+        {
+            Properties userProps = config.getUserProperties();
+            if ( userProps != null )
+            {
+                getLogger().debug( "Using user-defined properties for interpolation:\n" + String.valueOf( userProps ).replace( ',', '\n' ) );
+                context.putAll( userProps );
+            }
+        }
+
+        model = modelInterpolator.interpolate( model, context, strict );
+
+        // second pass allows ${user.home} to work, if it needs to.
+        // [MNG-2339] ensure the system properties are still interpolated for backwards compat, but the model values must win
+        if ( config.getExecutionProperties() != null && !config.getExecutionProperties().isEmpty() )
+        {
+            context.putAll( config.getExecutionProperties() );
+        }
+
+        model = modelInterpolator.interpolate( model, context, strict );
+
+        return model;
+    }
+
+    private void mergeDeterministicBuildElements( Build interpolatedBuild,
+                                                  Build dynamicBuild )
+    {
+        List dPlugins = dynamicBuild.getPlugins();
+
+        if ( dPlugins != null )
+        {
+            List iPlugins = interpolatedBuild.getPlugins();
+
+            for ( int i = 0; i < dPlugins.size(); i++ )
+            {
+                Plugin dPlugin = (Plugin) dPlugins.get( i );
+                Plugin iPlugin = (Plugin) iPlugins.get( i );
+
+                dPlugin.setGroupId( iPlugin.getGroupId() );
+                dPlugin.setArtifactId( iPlugin.getArtifactId() );
+                dPlugin.setVersion( iPlugin.getVersion() );
+            }
+        }
+
+        PluginManagement dPluginMgmt = dynamicBuild.getPluginManagement();
+
+        if ( dPluginMgmt != null )
+        {
+            PluginManagement iPluginMgmt = interpolatedBuild.getPluginManagement();
+            dPlugins = dPluginMgmt.getPlugins();
+            if ( dPlugins != null )
+            {
+                List iPlugins = iPluginMgmt.getPlugins();
+
+                for ( int i = 0; i < dPlugins.size(); i++ )
+                {
+                    Plugin dPlugin = (Plugin) dPlugins.get( i );
+                    Plugin iPlugin = (Plugin) iPlugins.get( i );
+
+                    dPlugin.setGroupId( iPlugin.getGroupId() );
+                    dPlugin.setArtifactId( iPlugin.getArtifactId() );
+                    dPlugin.setVersion( iPlugin.getVersion() );
+                }
+            }
+        }
+
+        if ( dynamicBuild.getExtensions() != null )
+        {
+            dynamicBuild.setExtensions( interpolatedBuild.getExtensions() );
+        }
+    }
+
     /**
      * @noinspection CollectionDeclaredAsConcreteClass
      * @todo We need to find an effective way to unit test parts of this method!
@@ -1793,24 +1867,14 @@
         // 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();
 
-        populateBuildPaths( model.getBuild(), context, project.getBasedir() );
-        if ( project.getFile() != null )
-        {
-            Properties userProps = config.getUserProperties();
-            if ( userProps != null )
-            {
-                context.putAll( userProps );
-            }
-        }
-
-        model = modelInterpolator.interpolate( model, context, true );
-
-        populateExecutionProperties( config, context );
-
-        model = modelInterpolator.interpolate( model, context, true );
+        boolean isSuperPom = project.getGroupId().equals( STANDALONE_SUPERPOM_GROUPID )
+                             && project.getArtifactId().equals( STANDALONE_SUPERPOM_ARTIFACTID )
+                             && project.getVersion().equals( STANDALONE_SUPERPOM_VERSION );
 
         File basedir = project.getBasedir();
 
+        model = interpolate( model, basedir, isSuperPom, config, true );
+
         List originalInterpolatedCompileSourceRoots = interpolateListOfStrings( project.getCompileSourceRoots(),
                                                                            model,
                                                                            context );
@@ -1845,6 +1909,11 @@
 
         calculateConcreteProjectReferences( project, config );
 
+        if ( project.getExecutionProject() != null )
+        {
+            calculateConcreteState( project.getExecutionProject(), config );
+        }
+
         project.setConcrete( true );
     }
 
@@ -1906,6 +1975,10 @@
         restoreModelBuildSection( project, config, context );
 
         restoreDynamicProjectReferences( project, config );
+        if ( project.getExecutionProject() != null )
+        {
+            restoreDynamicState( project.getExecutionProject(), config );
+        }
 
         project.setConcrete( false );
     }
@@ -1978,6 +2051,18 @@
                                                            project,
                                                            context ) );
 
+        dynamicBuild.setFinalName( restoreString( dynamicBuild.getFinalName(),
+                                                  originalInterpolatedBuild.getFinalName(),
+                                                  changedBuild.getFinalName(),
+                                                  project,
+                                                  context ) );
+
+        dynamicBuild.setDefaultGoal( restoreString( dynamicBuild.getDefaultGoal(),
+                                                  originalInterpolatedBuild.getDefaultGoal(),
+                                                  changedBuild.getDefaultGoal(),
+                                                  project,
+                                                  context ) );
+
         dynamicBuild.setSourceDirectory( restoreString( dynamicBuild.getSourceDirectory(),
                                                             originalInterpolatedBuild.getSourceDirectory(),
                                                             changedBuild.getSourceDirectory(),
@@ -2060,7 +2145,15 @@
 
         Model model = project.getModel();
 
-        String relativeChangedString = pathTranslator.unalignFromBaseDirectory( changedString, project.getBasedir() );
+        String relativeChangedString;
+        if ( project.getBasedir() != null )
+        {
+            relativeChangedString = pathTranslator.unalignFromBaseDirectory( changedString, project.getBasedir() );
+        }
+        else
+        {
+            relativeChangedString = changedString;
+        }
 
         String interpolatedOriginal = modelInterpolator.interpolate( originalString, model, context );
         String interpolatedOriginal2 = modelInterpolator.interpolate( originalInterpolatedString,
@@ -2116,7 +2209,15 @@
         for ( Iterator it = changedStrings.iterator(); it.hasNext(); )
         {
             String changedString = (String) it.next();
-            String relativeChangedString = pathTranslator.unalignFromBaseDirectory( changedString, project.getBasedir() );
+            String relativeChangedString;
+            if ( project.getBasedir() != null )
+            {
+                relativeChangedString = pathTranslator.unalignFromBaseDirectory( changedString, project.getBasedir() );
+            }
+            else
+            {
+                relativeChangedString = changedString;
+            }
 
             String interpolated = modelInterpolator.interpolate( changedString, project.getModel(), orig );
             String relativeInterpolated = modelInterpolator.interpolate( relativeChangedString, project.getModel(), orig );
@@ -2170,7 +2271,17 @@
             Resource resource = (Resource) it.next();
             String rDir = modelInterpolator.interpolate( resource.getDirectory(), project.getModel(), orig );
 
-            String relativeDir = pathTranslator.unalignFromBaseDirectory( resource.getDirectory(), project.getBasedir() );
+            String relativeDir;
+            if ( project.getBasedir() != null )
+            {
+                relativeDir = pathTranslator.unalignFromBaseDirectory( resource.getDirectory(),
+                                                                       project.getBasedir() );
+            }
+            else
+            {
+                relativeDir = resource.getDirectory();
+            }
+
             String relativeRDir = modelInterpolator.interpolate( relativeDir, project.getModel(), context );
 
             Resource[] original = (Resource[]) orig.get( rDir );

Modified: maven/components/branches/john-2.0.x-dynamicBuild/maven-project/src/test/java/org/apache/maven/project/MavenProjectDynamismTest.java
URL: http://svn.apache.org/viewvc/maven/components/branches/john-2.0.x-dynamicBuild/maven-project/src/test/java/org/apache/maven/project/MavenProjectDynamismTest.java?rev=666318&r1=666317&r2=666318&view=diff
==============================================================================
--- maven/components/branches/john-2.0.x-dynamicBuild/maven-project/src/test/java/org/apache/maven/project/MavenProjectDynamismTest.java (original)
+++ maven/components/branches/john-2.0.x-dynamicBuild/maven-project/src/test/java/org/apache/maven/project/MavenProjectDynamismTest.java Tue Jun 10 13:55:18 2008
@@ -1,9 +1,11 @@
 package org.apache.maven.project;
 
 import org.apache.maven.model.Build;
+import org.apache.maven.model.Plugin;
 import org.apache.maven.model.Resource;
 import org.apache.maven.project.interpolation.ModelInterpolationException;
 import org.codehaus.plexus.PlexusTestCase;
+import org.codehaus.plexus.util.xml.Xpp3Dom;
 import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
 
 import java.io.File;
@@ -12,7 +14,6 @@
 import java.net.URL;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Properties;
 
 public class MavenProjectDynamismTest
     extends PlexusTestCase
@@ -28,120 +29,96 @@
         projectBuilder = (MavenProjectBuilder) lookup( MavenProjectBuilder.class.getName() );
     }
 
-    public void testRoundTrip()
-        throws IOException, XmlPullParserException, URISyntaxException,
-        ModelInterpolationException, ProjectBuildingException
+    public void testBuildSectionGroupIdInterpolation()
+        throws IOException, XmlPullParserException, URISyntaxException, ProjectBuildingException,
+        ModelInterpolationException
     {
-        MavenProject project = buildProject( "pom.xml" );
+        MavenProject project = buildProject( "pom-interp.xml" );
 
-        File baseDir = project.getBasedir();
-        System.out.println( "Project basedir is: " + project.getBasedir() );
+        projectBuilder.calculateConcreteState( project, new DefaultProjectBuilderConfiguration() );
 
-        File buildDir = new File( baseDir, "target" );
-
-        String basedirExpr = "${pom.basedir}";
-        String buildDirExpr = "${pom.build.directory}";
-
-        // --------------------------------------------------------------------
-        // FIRST, VERIFY THE INITIAL STATE FOR THE BUILD SECTION AND
-        // ASSOCIATED DIRECTORIES ATTACHED TO THE PROJECT INSTANCE.
-        // --------------------------------------------------------------------
+        String basepath = "/" + project.getGroupId();
 
         Build build = project.getBuild();
 
-        assertEquals( "Original source directory should be expressed in terms of the basedir.",
-                      basedirExpr + "/src/main/java",
-                      build.getSourceDirectory() );
+        assertTrue( build.getSourceDirectory().startsWith( basepath ) );
+        assertTrue( build.getTestSourceDirectory().startsWith( basepath ) );
+        assertTrue( build.getScriptSourceDirectory().startsWith( basepath ) );
 
-        assertEquals( "Original test-source directory should be expressed in terms of the basedir.",
-                      basedirExpr + "/src/test/java",
-                      build.getTestSourceDirectory() );
-
-        assertEquals( "Original script-source directory should be expressed in terms of the basedir.",
-                      basedirExpr + "/src/main/scripts",
-                      build.getScriptSourceDirectory() );
-
-        List compileSourceRoots = project.getCompileSourceRoots();
-
-        assertNotNull( "Original compile-source roots should not be null.", compileSourceRoots );
+        List plugins = build.getPlugins();
+        assertNotNull( plugins );
+        assertEquals( 1, plugins.size() );
 
-        assertEquals( "Original compile-source roots should contain one entry.",
-                      1,
-                      compileSourceRoots.size() );
-
-        assertEquals( "Original compile-source roots should contain uninterpolated source-directory value.",
-                      basedirExpr + "/src/main/java",
-                      compileSourceRoots.get( 0 ) );
+        Plugin plugin = (Plugin) plugins.get( 0 );
+        assertEquals( "my-plugin", plugin.getArtifactId() );
 
-        List testCompileSourceRoots = project.getTestCompileSourceRoots();
+        Xpp3Dom conf = (Xpp3Dom) plugin.getConfiguration();
+        assertNotNull( conf );
 
-        assertNotNull( "Original test-compile-source roots should not be null.",
-                       testCompileSourceRoots );
+        Xpp3Dom[] children = conf.getChildren();
+        assertEquals( 3, children.length );
 
-        assertEquals( "Original test-compile-source roots should contain one entry.",
-                      1,
-                      testCompileSourceRoots.size() );
-
-        assertEquals( "Original test-compile-source roots should contain uninterpolated test-source-directory value.",
-                      basedirExpr + "/src/test/java",
-                      testCompileSourceRoots.get( 0 ) );
-
-        List scriptSourceRoots = project.getScriptSourceRoots();
-
-        assertNotNull( "Original script-source roots should not be null.", scriptSourceRoots );
-
-        assertEquals( "Original script-source roots should contain one entry.",
-                      1,
-                      scriptSourceRoots.size() );
-
-        assertEquals( "Original script-source roots should contain uninterpolated script-source-directory value.",
-                      basedirExpr + "/src/main/scripts",
-                      scriptSourceRoots.get( 0 ) );
-
-        List resources = build.getResources();
+        for ( int i = 0; i < children.length; i++ )
+        {
+            assertEquals( "Configuration parameter: "
+                                          + children[i].getName()
+                                          + " should have a an interpolated POM groupId as its value.",
+                          children[i].getValue(),
+                          project.getGroupId() );
+        }
 
-        assertNotNull( "Original resources should not be null.", resources );
+        projectBuilder.restoreDynamicState( project, new DefaultProjectBuilderConfiguration() );
 
-        assertEquals( "Original resources should contain one entry.", 1, resources.size() );
+        String projectGidExpr = "${project.groupId}";
+        String pomGidExpr = "${pom.groupId}";
+        String nakedGidExpr = "${groupId}";
 
-        assertEquals( "Original resource should contain uninterpolated reference to build directory.",
-                      buildDirExpr + "/generated-resources/plexus",
-                      ( (Resource) resources.get( 0 ) ).getDirectory() );
+        build = project.getBuild();
 
-        List filters = build.getFilters();
+        assertTrue( build.getSourceDirectory().startsWith( "/" + projectGidExpr ) );
+        assertTrue( build.getTestSourceDirectory().startsWith( "/" + pomGidExpr ) );
+        assertTrue( build.getScriptSourceDirectory().startsWith( "/" + nakedGidExpr ) );
 
-        assertNotNull( "Original filters should not be null.", filters );
+        plugins = build.getPlugins();
+        assertNotNull( plugins );
+        assertEquals( 1, plugins.size() );
 
-        assertEquals( "Original filters should contain one entry.", 1, filters.size() );
+        plugin = (Plugin) plugins.get( 0 );
+        assertEquals( "my-plugin", plugin.getArtifactId() );
 
-        assertEquals( "Original filter entry should contain uninterpolated reference to build directory.",
-                      buildDirExpr + "/generated-filters.properties",
-                      filters.get( 0 ) );
+        conf = (Xpp3Dom) plugin.getConfiguration();
+        assertNotNull( conf );
 
-        assertEquals( "Original output-directory should be expressed in terms of the build-directory.",
-                      buildDirExpr + "/classes",
-                      build.getOutputDirectory() );
+        children = conf.getChildren();
+        assertEquals( 3, children.length );
 
-        assertEquals( "Original test-output-directory should be expressed in terms of the build-directory.",
-                      buildDirExpr + "/test-classes",
-                      build.getTestOutputDirectory() );
+        assertEquals( "Configuration parameter: " + children[0].getName() + " should have "
+                      + projectGidExpr + " as its value.", children[0].getValue(), projectGidExpr );
 
-        assertEquals( "Original build directory should be relative.",
-                      "target",
-                      build.getDirectory() );
+        assertEquals( "Configuration parameter: " + children[1].getName() + " should have "
+                      + pomGidExpr + " as its value.", children[1].getValue(), pomGidExpr );
 
-        // --------------------------------------------------------------------
-        // NOW, CALCULATE THE CONCRETE STATE FOR THE BUILD SECTION AND
-        // ASSOCIATED DIRECTORIES ATTACHED TO THE PROJECT INSTANCE.
-        // --------------------------------------------------------------------
+        assertEquals( "Configuration parameter: " + children[2].getName() + " should have "
+                      + nakedGidExpr + " as its value.", children[2].getValue(), nakedGidExpr );
+    }
 
+    public void testRoundTrip()
+        throws IOException, XmlPullParserException, URISyntaxException,
+        ModelInterpolationException, ProjectBuildingException
+    {
+        MavenProject project = buildProject( "pom.xml" );
         ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration();
-
         projectBuilder.calculateConcreteState( project, config );
 
+        File baseDir = project.getBasedir();
+        File buildDir = new File( baseDir, "target" );
+
+        String basedirExpr = "${pom.basedir}";
+        String buildDirExpr = "${pom.build.directory}";
+
         assertTrue( project.isConcrete() );
 
-        build = project.getBuild();
+        Build build = project.getBuild();
 
         assertEquals( "Concrete source directory should be absolute.",
                       new File( baseDir, "/src/main/java" ).getAbsolutePath(),
@@ -155,7 +132,7 @@
                       new File( baseDir, "/src/main/scripts" ).getAbsolutePath(),
                       build.getScriptSourceDirectory() );
 
-        compileSourceRoots = project.getCompileSourceRoots();
+        List compileSourceRoots = project.getCompileSourceRoots();
 
         assertNotNull( "Concrete compile-source roots should not be null.", compileSourceRoots );
 
@@ -167,7 +144,7 @@
                       new File( baseDir, "/src/main/java" ).getAbsolutePath(),
                       compileSourceRoots.get( 0 ) );
 
-        testCompileSourceRoots = project.getTestCompileSourceRoots();
+        List testCompileSourceRoots = project.getTestCompileSourceRoots();
 
         assertNotNull( "Concrete test-compile-source roots should not be null.",
                        testCompileSourceRoots );
@@ -180,7 +157,7 @@
                       new File( baseDir, "/src/test/java" ).getAbsolutePath(),
                       testCompileSourceRoots.get( 0 ) );
 
-        scriptSourceRoots = project.getScriptSourceRoots();
+        List scriptSourceRoots = project.getScriptSourceRoots();
 
         assertNotNull( "Concrete script-source roots should not be null.", scriptSourceRoots );
 
@@ -192,7 +169,7 @@
                       new File( baseDir, "/src/main/scripts" ).getAbsolutePath(),
                       scriptSourceRoots.get( 0 ) );
 
-        resources = build.getResources();
+        List resources = build.getResources();
 
         assertNotNull( "Concrete resources should not be null.", resources );
 
@@ -202,7 +179,7 @@
                       new File( buildDir, "generated-resources/plexus" ).getAbsolutePath(),
                       ( (Resource) resources.get( 0 ) ).getDirectory() );
 
-        filters = build.getFilters();
+        List filters = build.getFilters();
 
         assertNotNull( "Concrete filters should not be null.", filters );
 
@@ -256,7 +233,7 @@
                       compileSourceRoots.size() );
 
         assertEquals( "Restored compile-source roots should contain uninterpolated source-directory value.",
-                      basedirExpr + "/src/main/java",
+                      "src/main/java",
                       compileSourceRoots.get( 0 ) );
 
         testCompileSourceRoots = project.getTestCompileSourceRoots();
@@ -269,7 +246,7 @@
                       testCompileSourceRoots.size() );
 
         assertEquals( "Restored test-compile-source roots should contain uninterpolated test-source-directory value.",
-                      basedirExpr + "/src/test/java",
+                      "src/test/java",
                       testCompileSourceRoots.get( 0 ) );
 
         scriptSourceRoots = project.getScriptSourceRoots();
@@ -281,7 +258,7 @@
                       scriptSourceRoots.size() );
 
         assertEquals( "Restored script-source roots should contain uninterpolated script-source-directory value.",
-                      basedirExpr + "/src/main/scripts",
+                      "src/main/scripts",
                       scriptSourceRoots.get( 0 ) );
 
         resources = build.getResources();
@@ -323,27 +300,18 @@
     {
         MavenProject project = buildProject( "pom.xml" );
 
-        Build build = project.getBuild();
-
-        List resources = build.getResources();
-        assertNotNull( "Original resources should not be null.", resources );
-        assertEquals( "Original resources should contain only one entry.", 1, resources.size() );
-        assertResourcePresent( "original resources",
-                               "${pom.build.directory}/generated-resources/plexus",
-                               resources );
-
         ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration();
 
         projectBuilder.calculateConcreteState( project, config );
 
-        build = project.getBuild();
+        Build build = project.getBuild();
 
         Resource r = new Resource();
         r.setDirectory( "myDir" );
 
         build.addResource( r );
 
-        resources = build.getResources();
+        List resources = build.getResources();
         assertNotNull( "Concrete resources should not be null.", resources );
         assertEquals( "Concrete resources should contain two entries.", 2, resources.size() );
         assertResourcePresent( "concrete resources",
@@ -370,24 +338,14 @@
     {
         MavenProject project = buildProject( "pom.xml" );
 
-        Build build = project.getBuild();
-
-        List filters = build.getFilters();
-        assertNotNull( "Original filters should not be null.", filters );
-        assertEquals( "Original filters should contain only one entry.", 1, filters.size() );
-        assertFilterPresent( "original filters",
-                             "${pom.build.directory}/generated-filters.properties",
-                             filters );
-
         ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration();
-
         projectBuilder.calculateConcreteState( project, config );
 
-        build = project.getBuild();
+        Build build = project.getBuild();
 
         build.addFilter( "myDir/filters.properties" );
 
-        filters = build.getFilters();
+        List filters = build.getFilters();
         assertNotNull( "Concrete filters should not be null.", filters );
         assertEquals( "Concrete filters should contain two entries.", 2, filters.size() );
         assertFilterPresent( "concrete filters",
@@ -416,7 +374,6 @@
         MavenProject project = buildProject( "pom.xml" );
 
         ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration();
-
         projectBuilder.calculateConcreteState( project, config );
 
         Build build = project.getBuild();
@@ -456,25 +413,20 @@
     {
         MavenProject project = buildProject( "pom.xml" );
 
-        String buildDir = new File( project.getBasedir(), project.getBuild().getDirectory() ).getAbsolutePath();
-        Properties props = project.getProperties();
-
-        assertEquals( "Original property value for 'myProperty' should be the absolute initial build directory.",
-                      buildDir,
-                      props.getProperty( "myProperty" ) );
-
         ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration();
         projectBuilder.calculateConcreteState( project, config );
 
         project.getBuild().setDirectory( "target2" );
 
+        String originalValue = project.getProperties().getProperty( "myProperty" );
+
         projectBuilder.restoreDynamicState( project, config );
         projectBuilder.calculateConcreteState( project, config );
 
         assertEquals( "After resetting build-directory and going through a recalculation phase for the project, "
                                       + "property value for 'myProperty' should STILL be the absolute initial build directory.",
-                      buildDir,
-                      props.getProperty( "myProperty" ) );
+                      originalValue,
+                      project.getProperties().getProperty( "myProperty" ) );
     }
 
     public void testShouldAlignCompileSourceRootsInConcreteState()
@@ -483,38 +435,53 @@
     {
         MavenProject project = buildProject( "pom-relative.xml" );
 
-        List compileSourceRoots = project.getCompileSourceRoots();
-        assertNotNull( "Original dynamic state compile-source roots should not be null.", compileSourceRoots );
-        assertEquals( "Original dynamic state should contain one compile-source root.", 1, compileSourceRoots.size() );
-        assertEquals( "Original dynamic state should have a relative path for compile-source root.", "src/main/java", compileSourceRoots.get( 0 ) );
-
         ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration();
         projectBuilder.calculateConcreteState( project, config );
 
-        compileSourceRoots = project.getCompileSourceRoots();
-        assertNotNull( "First concrete state compile-source roots should not be null.", compileSourceRoots );
-        assertEquals( "First concrete state should contain one compile-source root.", 1, compileSourceRoots.size() );
-        assertEquals( "First concrete state should have an absolute path for compile-source root.", new File( project.getBasedir(), "src/main/java" ).getAbsolutePath(), compileSourceRoots.get( 0 ) );
+        List compileSourceRoots = project.getCompileSourceRoots();
+        assertNotNull( "First concrete state compile-source roots should not be null.",
+                       compileSourceRoots );
+        assertEquals( "First concrete state should contain one compile-source root.",
+                      1,
+                      compileSourceRoots.size() );
+        assertEquals( "First concrete state should have an absolute path for compile-source root.",
+                      new File( project.getBasedir(), "src/main/java" ).getAbsolutePath(),
+                      compileSourceRoots.get( 0 ) );
 
-        String newSourceRoot = new File( project.getBuild().getDirectory(), "generated-sources/modello" ).getAbsolutePath();
+        String newSourceRoot = new File( project.getBuild().getDirectory(),
+                                         "generated-sources/modello" ).getAbsolutePath();
 
         project.addCompileSourceRoot( newSourceRoot );
 
         projectBuilder.restoreDynamicState( project, config );
 
         compileSourceRoots = project.getCompileSourceRoots();
-        assertNotNull( "Restored dynamic state compile-source roots should not be null.", compileSourceRoots );
-        assertEquals( "Restored dynamic state should contain two compile-source roots.", 2, compileSourceRoots.size() );
-        assertEquals( "Restored dynamic state should have a relative path for original compile-source root.", "src/main/java", compileSourceRoots.get( 0 ) );
-        assertEquals( "Restored dynamic state should have a relative path for new compile-source root.", "target/generated-sources/modello", compileSourceRoots.get( 1 ) );
+        assertNotNull( "Restored dynamic state compile-source roots should not be null.",
+                       compileSourceRoots );
+        assertEquals( "Restored dynamic state should contain two compile-source roots.",
+                      2,
+                      compileSourceRoots.size() );
+        assertEquals( "Restored dynamic state should have a relative path for original compile-source root.",
+                      "src/main/java",
+                      compileSourceRoots.get( 0 ) );
+        assertEquals( "Restored dynamic state should have a relative path for new compile-source root.",
+                      "target/generated-sources/modello",
+                      compileSourceRoots.get( 1 ) );
 
         projectBuilder.calculateConcreteState( project, config );
 
         compileSourceRoots = project.getCompileSourceRoots();
-        assertNotNull( "Second concrete state compile-source roots should not be null.", compileSourceRoots );
-        assertEquals( "Second concrete state should contain two compile-source roots.", 2, compileSourceRoots.size() );
-        assertEquals( "Second concrete state should have an absolute path for original compile-source root.", new File( project.getBasedir(), "src/main/java" ).getAbsolutePath(), compileSourceRoots.get( 0 ) );
-        assertEquals( "Second concrete state should have an absolute path for new compile-source root.", newSourceRoot, compileSourceRoots.get( 1 ) );
+        assertNotNull( "Second concrete state compile-source roots should not be null.",
+                       compileSourceRoots );
+        assertEquals( "Second concrete state should contain two compile-source roots.",
+                      2,
+                      compileSourceRoots.size() );
+        assertEquals( "Second concrete state should have an absolute path for original compile-source root.",
+                      new File( project.getBasedir(), "src/main/java" ).getAbsolutePath(),
+                      compileSourceRoots.get( 0 ) );
+        assertEquals( "Second concrete state should have an absolute path for new compile-source root.",
+                      newSourceRoot,
+                      compileSourceRoots.get( 1 ) );
     }
 
     // Useful for diagnostics.
@@ -591,7 +558,8 @@
         File pomFile = new File( resource.getPath() );
         pomFile = pomFile.getAbsoluteFile();
 
-        MavenProject project = projectBuilder.build( pomFile, new DefaultProjectBuilderConfiguration() );
+        MavenProject project = projectBuilder.build( pomFile,
+                                                     new DefaultProjectBuilderConfiguration() );
 
         assertEquals( pomFile, project.getFile() );
 

Added: maven/components/branches/john-2.0.x-dynamicBuild/maven-project/src/test/resources/project-dynamism/pom-interp.xml
URL: http://svn.apache.org/viewvc/maven/components/branches/john-2.0.x-dynamicBuild/maven-project/src/test/resources/project-dynamism/pom-interp.xml?rev=666318&view=auto
==============================================================================
--- maven/components/branches/john-2.0.x-dynamicBuild/maven-project/src/test/resources/project-dynamism/pom-interp.xml (added)
+++ maven/components/branches/john-2.0.x-dynamicBuild/maven-project/src/test/resources/project-dynamism/pom-interp.xml Tue Jun 10 13:55:18 2008
@@ -0,0 +1,28 @@
+<?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>
+  
+  <build>
+    <sourceDirectory>/${project.groupId}/src/main/java</sourceDirectory>
+    <testSourceDirectory>/${pom.groupId}/src/test/java</testSourceDirectory>
+    <scriptSourceDirectory>/${groupId}/src/main/scripts</scriptSourceDirectory>
+    
+    <plugins>
+      <plugin>
+        <artifactId>my-plugin</artifactId>
+        <configuration>
+          <testOne>${project.groupId}</testOne>
+          <testTwo>${pom.groupId}</testTwo>
+          <testThree>${groupId}</testThree>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>
\ No newline at end of file

Propchange: maven/components/branches/john-2.0.x-dynamicBuild/maven-project/src/test/resources/project-dynamism/pom-interp.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/branches/john-2.0.x-dynamicBuild/maven-project/src/test/resources/project-dynamism/pom-interp.xml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"



Mime
View raw message