maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sisb...@apache.org
Subject svn commit: r672884 [3/3] - in /maven/sandbox/branches/maven-2.1: ./ maven-core/src/main/aspect/org/apache/maven/compat/ maven-core/src/main/aspect/org/apache/maven/errors/ maven-core/src/main/java/org/apache/maven/extension/ maven-core/src/main/java/o...
Date Mon, 30 Jun 2008 19:52:52 GMT
Modified: maven/sandbox/branches/maven-2.1/maven-project/src/main/java/org/apache/maven/profiles/activation/FileProfileActivator.java
URL: http://svn.apache.org/viewvc/maven/sandbox/branches/maven-2.1/maven-project/src/main/java/org/apache/maven/profiles/activation/FileProfileActivator.java?rev=672884&r1=672883&r2=672884&view=diff
==============================================================================
--- maven/sandbox/branches/maven-2.1/maven-project/src/main/java/org/apache/maven/profiles/activation/FileProfileActivator.java (original)
+++ maven/sandbox/branches/maven-2.1/maven-project/src/main/java/org/apache/maven/profiles/activation/FileProfileActivator.java Mon Jun 30 12:52:51 2008
@@ -30,6 +30,8 @@
 import org.codehaus.plexus.util.interpolation.MapBasedValueSource;
 import org.codehaus.plexus.util.interpolation.RegexBasedInterpolator;
 
+import hidden.org.codehaus.plexus.interpolation.InterpolationException;
+
 import java.io.IOException;
 
 public class FileProfileActivator
@@ -67,7 +69,21 @@
 
             if ( StringUtils.isNotEmpty( fileString ) )
             {
-                fileString = StringUtils.replace( interpolator.interpolate( fileString, "" ), "\\", "/" );
+                try
+                {
+                    fileString = StringUtils.replace( interpolator.interpolate( fileString, "" ), "\\", "/" );
+                }
+                catch ( InterpolationException e )
+                {
+                    if ( logger.isDebugEnabled() )
+                    {
+                        logger.debug( "Failed to interpolate exists file location for profile activator: " + fileString, e );
+                    }
+                    else
+                    {
+                        logger.warn( "Failed to interpolate exists file location for profile activator: " + fileString + ". Run in debug mode (-X) for more information." );
+                    }
+                }
 
                 boolean result = FileUtils.fileExists( fileString );
 
@@ -84,7 +100,21 @@
 
             if ( StringUtils.isNotEmpty( fileString ) )
             {
-                fileString = StringUtils.replace( interpolator.interpolate( fileString, "" ), "\\", "/" );
+                try
+                {
+                    fileString = StringUtils.replace( interpolator.interpolate( fileString, "" ), "\\", "/" );
+                }
+                catch ( InterpolationException e )
+                {
+                    if ( logger.isDebugEnabled() )
+                    {
+                        logger.debug( "Failed to interpolate missing file location for profile activator: " + fileString, e );
+                    }
+                    else
+                    {
+                        logger.warn( "Failed to interpolate missing file location for profile activator: " + fileString + ". Run in debug mode (-X) for more information." );
+                    }
+                }
 
                 boolean result = !FileUtils.fileExists( fileString );
 

Modified: maven/sandbox/branches/maven-2.1/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
URL: http://svn.apache.org/viewvc/maven/sandbox/branches/maven-2.1/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java?rev=672884&r1=672883&r2=672884&view=diff
==============================================================================
--- maven/sandbox/branches/maven-2.1/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java (original)
+++ maven/sandbox/branches/maven-2.1/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java Mon Jun 30 12:52:51 2008
@@ -45,8 +45,10 @@
 import org.apache.maven.model.Extension;
 import org.apache.maven.model.Model;
 import org.apache.maven.model.Plugin;
+import org.apache.maven.model.PluginManagement;
 import org.apache.maven.model.ReportPlugin;
 import org.apache.maven.model.Repository;
+import org.apache.maven.model.Resource;
 import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
 import org.apache.maven.profiles.MavenProfilesBuilder;
 import org.apache.maven.profiles.ProfileManager;
@@ -317,7 +319,7 @@
             // we shouldn't be swallowing exceptions, no matter how unlikely.
             // or, if we do, we should pay attention to the one coming from getSuperModel()...
             throw new ProjectBuildingException( STANDALONE_SUPERPOM_GROUPID + ":"
-                                                + STANDALONE_SUPERPOM_ARTIFACTID,
+                                             + STANDALONE_SUPERPOM_ARTIFACTID,
                                                 "Maven super-POM contains an invalid repository!",
                                                 e );
         }
@@ -326,7 +328,7 @@
             // we shouldn't be swallowing exceptions, no matter how unlikely.
             // or, if we do, we should pay attention to the one coming from getSuperModel()...
             throw new ProjectBuildingException( STANDALONE_SUPERPOM_GROUPID + ":"
-                                                + STANDALONE_SUPERPOM_ARTIFACTID,
+                                             + STANDALONE_SUPERPOM_ARTIFACTID,
                                                 "Maven super-POM contains an invalid expressions!",
                                                 e );
         }
@@ -537,8 +539,8 @@
         else
         {
             getLogger().warn( "Attempting to build MavenProject instance for Artifact (" + artifact.getGroupId() + ":"
-                + artifact.getArtifactId() + ":" + artifact.getVersion() + ") of type: "
-                + artifact.getType() + "; constructing POM artifact instead." );
+             + artifact.getArtifactId() + ":" + artifact.getVersion() + ") of type: "
+             + artifact.getType() + "; constructing POM artifact instead." );
 
             projectArtifact = artifactFactory.createProjectArtifact( artifact.getGroupId(),
                 artifact.getArtifactId(),
@@ -829,9 +831,6 @@
             // the plugin tools compose basedir and scriptSourceRoot into a single file.
             project.addScriptSourceRoot( build.getScriptSourceDirectory() );
 
-            getLogger().debug( "Aligning project: " + project.getId() + " to base directory: " + projectDescriptor.getParentFile() );
-            pathTranslator.alignToBaseDirectory( project.getModel(), projectDescriptor.getParentFile() );
-
             project.addCompileSourceRoot( build.getSourceDirectory() );
 
             project.addTestCompileSourceRoot( build.getTestSourceDirectory() );
@@ -906,8 +905,8 @@
             catch ( InvalidRepositoryException e )
             {
                 throw new ProjectBuildingException( safeVersionlessKey( model.getGroupId(), model.getArtifactId() ),
-                    "Failed to construct ArtifactRepository instances for repositories declared in: "
-                        + model.getId(), e );
+                    "Failed to construct ArtifactRepository instances for repositories declared in: " +
+                     model.getId(), e );
             }
         }
     }
@@ -973,8 +972,14 @@
             projectDir = pomFile.getAbsoluteFile().getParentFile();
         }
 
+        Build dynamicBuild = model.getBuild();
+        model.setBuild( ModelUtils.cloneBuild( dynamicBuild ) );
+
         model = modelInterpolator.interpolate( model, projectDir, config, getLogger().isDebugEnabled() );
 
+        mergeDeterministicBuildElements( model.getBuild(), dynamicBuild );
+        model.setBuild( dynamicBuild );
+
         // We must inject any imported dependencyManagement information ahead of the defaults injection.
         if ( !isSuperPom )
         {
@@ -1063,6 +1068,510 @@
         return project;
     }
 
+    // TODO: Remove this!
+    @SuppressWarnings("unchecked")
+    private void mergeDeterministicBuildElements( Build interpolatedBuild,
+                                                  Build dynamicBuild )
+    {
+        List<Plugin> dPlugins = dynamicBuild.getPlugins();
+
+        if ( dPlugins != null )
+        {
+            List<Plugin> iPlugins = interpolatedBuild.getPlugins();
+
+            for ( int i = 0; i < dPlugins.size(); i++ )
+            {
+                Plugin dPlugin = dPlugins.get( i );
+                Plugin iPlugin = 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<Plugin> iPlugins = iPluginMgmt.getPlugins();
+
+                for ( int i = 0; i < dPlugins.size(); i++ )
+                {
+                    Plugin dPlugin = dPlugins.get( i );
+                    Plugin iPlugin = iPlugins.get( i );
+
+                    dPlugin.setGroupId( iPlugin.getGroupId() );
+                    dPlugin.setArtifactId( iPlugin.getArtifactId() );
+                    dPlugin.setVersion( iPlugin.getVersion() );
+                }
+            }
+        }
+
+        if ( dynamicBuild.getExtensions() != null )
+        {
+            dynamicBuild.setExtensions( interpolatedBuild.getExtensions() );
+        }
+    }
+
+    public void calculateConcreteState( MavenProject project, ProjectBuilderConfiguration config )
+        throws ModelInterpolationException
+    {
+        if ( project.isConcrete() )
+        {
+            return;
+        }
+
+        Model model = ModelUtils.cloneModel( project.getModel() );
+
+        File basedir = project.getBasedir();
+
+        model = modelInterpolator.interpolate( model, basedir, config, getLogger().isDebugEnabled() );
+
+        List originalInterpolatedCompileSourceRoots = interpolateListOfStrings( project.getCompileSourceRoots(),
+                                                                           model,
+                                                                           project.getBasedir(),
+                                                                           config );
+
+        project.preserveCompileSourceRoots( originalInterpolatedCompileSourceRoots );
+
+        project.setCompileSourceRoots( originalInterpolatedCompileSourceRoots == null ? null
+                        : translateListOfPaths( originalInterpolatedCompileSourceRoots, basedir ) );
+
+        List originalInterpolatedTestCompileSourceRoots = interpolateListOfStrings( project.getTestCompileSourceRoots(),
+                                                                               model,
+                                                                               project.getBasedir(),
+                                                                               config );
+
+        project.preserveTestCompileSourceRoots( originalInterpolatedTestCompileSourceRoots );
+        project.setTestCompileSourceRoots( originalInterpolatedTestCompileSourceRoots == null ? null
+                        : translateListOfPaths( originalInterpolatedTestCompileSourceRoots, basedir ) );
+
+        List originalInterpolatedScriptSourceRoots = interpolateListOfStrings( project.getScriptSourceRoots(),
+                                                                          model,
+                                                                          project.getBasedir(),
+                                                                          config );
+
+        project.preserveScriptSourceRoots( originalInterpolatedScriptSourceRoots );
+        project.setScriptSourceRoots( originalInterpolatedScriptSourceRoots == null ? null
+                        : translateListOfPaths( originalInterpolatedScriptSourceRoots, basedir ) );
+
+        Model model2 = ModelUtils.cloneModel( model );
+
+        pathTranslator.alignToBaseDirectory( model, basedir );
+
+        project.preserveBuild( model2.getBuild() );
+        project.setBuild( model.getBuild() );
+
+        calculateConcreteProjectReferences( project, config );
+
+        MavenProject executionProject = project.getExecutionProject();
+        if ( executionProject != null && executionProject != project )
+        {
+            calculateConcreteState( executionProject, config );
+        }
+
+        project.setConcrete( true );
+    }
+
+    private void calculateConcreteProjectReferences( MavenProject project,
+                                                     ProjectBuilderConfiguration config )
+        throws ModelInterpolationException
+    {
+        Map projectRefs = project.getProjectReferences();
+
+        if ( projectRefs != null )
+        {
+            for ( Iterator it = projectRefs.values().iterator(); it.hasNext(); )
+            {
+                MavenProject reference = (MavenProject) it.next();
+                calculateConcreteState( reference, config );
+            }
+        }
+    }
+
+    private List translateListOfPaths( List paths, File basedir )
+    {
+        if ( paths == null )
+        {
+            return null;
+        }
+        else if ( basedir == null )
+        {
+            return paths;
+        }
+
+        List result = new ArrayList( paths.size() );
+        for ( Iterator it = paths.iterator(); it.hasNext(); )
+        {
+            String path = (String) it.next();
+
+            String aligned = pathTranslator.alignToBaseDirectory( path, basedir );
+
+            result.add( aligned );
+        }
+
+        return result;
+    }
+
+    public void restoreDynamicState( MavenProject project, ProjectBuilderConfiguration config )
+        throws ModelInterpolationException
+    {
+        if ( !project.isConcrete() )
+        {
+            return;
+        }
+
+        restoreBuildRoots( project, config );
+        restoreModelBuildSection( project, config );
+
+        restoreDynamicProjectReferences( project, config );
+
+        MavenProject executionProject = project.getExecutionProject();
+        if ( executionProject != null && executionProject != project )
+        {
+            restoreDynamicState( executionProject, config );
+        }
+
+        project.setConcrete( false );
+    }
+
+    private void restoreDynamicProjectReferences( MavenProject project,
+                                                  ProjectBuilderConfiguration config )
+        throws ModelInterpolationException
+    {
+        Map projectRefs = project.getProjectReferences();
+        if ( projectRefs != null )
+        {
+            for ( Iterator it = projectRefs.values().iterator(); it.hasNext(); )
+            {
+                MavenProject projectRef = (MavenProject) it.next();
+                restoreDynamicState( projectRef, config );
+            }
+        }
+    }
+
+    private void restoreBuildRoots( MavenProject project,
+                                    ProjectBuilderConfiguration config )
+        throws ModelInterpolationException
+    {
+        project.setCompileSourceRoots( restoreListOfStrings( project.getDynamicCompileSourceRoots(),
+                                                             project.getOriginalInterpolatedCompileSourceRoots(),
+                                                             project.getCompileSourceRoots(),
+                                                             project,
+                                                             config ) );
+
+        project.setTestCompileSourceRoots( restoreListOfStrings( project.getDynamicTestCompileSourceRoots(),
+                                                                 project.getOriginalInterpolatedTestCompileSourceRoots(),
+                                                                 project.getTestCompileSourceRoots(),
+                                                                 project,
+                                                                 config ) );
+
+        project.setScriptSourceRoots( restoreListOfStrings( project.getDynamicScriptSourceRoots(),
+                                                            project.getOriginalInterpolatedScriptSourceRoots(),
+                                                            project.getScriptSourceRoots(),
+                                                            project,
+                                                            config ) );
+
+        project.clearRestorableRoots();
+    }
+
+    private void restoreModelBuildSection( MavenProject project,
+                                           ProjectBuilderConfiguration config )
+        throws ModelInterpolationException
+    {
+        Build changedBuild = project.getBuild();
+        Build dynamicBuild = project.getDynamicBuild();
+        Build originalInterpolatedBuild = project.getOriginalInterpolatedBuild();
+
+        dynamicBuild.setResources( restoreResources( dynamicBuild.getResources(),
+                                                         originalInterpolatedBuild.getResources(),
+                                                         changedBuild.getResources(),
+                                                         project,
+                                                         config ) );
+
+        dynamicBuild.setTestResources( restoreResources( dynamicBuild.getTestResources(),
+                                                         originalInterpolatedBuild.getTestResources(),
+                                                         changedBuild.getTestResources(),
+                                                         project,
+                                                         config ) );
+
+        dynamicBuild.setFilters( restoreListOfStrings( dynamicBuild.getFilters(),
+                                                           originalInterpolatedBuild.getFilters(),
+                                                           changedBuild.getFilters(),
+                                                           project,
+                                                           config ) );
+
+        dynamicBuild.setFinalName( restoreString( dynamicBuild.getFinalName(),
+                                                  originalInterpolatedBuild.getFinalName(),
+                                                  changedBuild.getFinalName(),
+                                                  project,
+                                                  config ) );
+
+        dynamicBuild.setDefaultGoal( restoreString( dynamicBuild.getDefaultGoal(),
+                                                  originalInterpolatedBuild.getDefaultGoal(),
+                                                  changedBuild.getDefaultGoal(),
+                                                  project,
+                                                  config ) );
+
+        dynamicBuild.setSourceDirectory( restoreString( dynamicBuild.getSourceDirectory(),
+                                                            originalInterpolatedBuild.getSourceDirectory(),
+                                                            changedBuild.getSourceDirectory(),
+                                                            project,
+                                                            config ) );
+
+        dynamicBuild.setTestSourceDirectory( restoreString( dynamicBuild.getTestSourceDirectory(),
+                                                                originalInterpolatedBuild.getTestSourceDirectory(),
+                                                                changedBuild.getTestSourceDirectory(),
+                                                                project,
+                                                                config ) );
+
+        dynamicBuild.setScriptSourceDirectory( restoreString( dynamicBuild.getScriptSourceDirectory(),
+                                                                  originalInterpolatedBuild.getScriptSourceDirectory(),
+                                                                  changedBuild.getScriptSourceDirectory(),
+                                                                  project,
+                                                                  config ) );
+
+        dynamicBuild.setOutputDirectory( restoreString( dynamicBuild.getOutputDirectory(),
+                                                            originalInterpolatedBuild.getOutputDirectory(),
+                                                            changedBuild.getOutputDirectory(),
+                                                            project,
+                                                            config ) );
+
+        dynamicBuild.setTestOutputDirectory( restoreString( dynamicBuild.getTestOutputDirectory(),
+                                                                originalInterpolatedBuild.getTestOutputDirectory(),
+                                                                changedBuild.getTestOutputDirectory(),
+                                                                project,
+                                                                config ) );
+
+        dynamicBuild.setDirectory( restoreString( dynamicBuild.getDirectory(),
+                                                      originalInterpolatedBuild.getDirectory(),
+                                                      changedBuild.getDirectory(),
+                                                      project,
+                                                      config ) );
+
+        project.setBuild( dynamicBuild );
+
+        project.clearRestorableBuild();
+    }
+
+    private List interpolateListOfStrings( List originalStrings,
+                                           Model model,
+                                           File projectDir,
+                                           ProjectBuilderConfiguration config )
+        throws ModelInterpolationException
+    {
+        if ( originalStrings == null )
+        {
+            return null;
+        }
+
+        List result = new ArrayList();
+
+        for ( Iterator it = originalStrings.iterator(); it.hasNext(); )
+        {
+            String original = (String) it.next();
+            String interpolated = modelInterpolator.interpolate( original, model, projectDir, config, getLogger().isDebugEnabled() );
+
+            result.add( interpolated );
+        }
+
+        return result;
+    }
+
+    private String restoreString( String originalString,
+                                      String originalInterpolatedString,
+                                      String changedString,
+                                      MavenProject project,
+                                      ProjectBuilderConfiguration config )
+        throws ModelInterpolationException
+    {
+        if ( originalString == null )
+        {
+            return changedString;
+        }
+        else if ( changedString == null )
+        {
+            return originalString;
+        }
+
+        Model model = project.getModel();
+
+        String relativeChangedString;
+        if ( project.getBasedir() != null )
+        {
+            relativeChangedString = pathTranslator.unalignFromBaseDirectory( changedString, project.getBasedir() );
+        }
+        else
+        {
+            relativeChangedString = changedString;
+        }
+
+        String interpolatedOriginal = modelInterpolator.interpolate( originalString, model, project.getBasedir(), config, getLogger().isDebugEnabled() );
+        String interpolatedOriginal2 = modelInterpolator.interpolate( originalInterpolatedString,
+                                                                 model,
+                                                                 project.getBasedir(), config, getLogger().isDebugEnabled() );
+
+        String interpolatedChanged = modelInterpolator.interpolate( changedString, model, project.getBasedir(), config, getLogger().isDebugEnabled() );
+        String relativeInterpolatedChanged = modelInterpolator.interpolate( relativeChangedString, model, project.getBasedir(), config, getLogger().isDebugEnabled() );
+
+        if ( interpolatedOriginal.equals( interpolatedChanged )
+             || interpolatedOriginal2.equals( interpolatedChanged ) )
+        {
+            return originalString;
+        }
+        else if ( interpolatedOriginal.equals( relativeInterpolatedChanged )
+                        || interpolatedOriginal2.equals( relativeInterpolatedChanged ) )
+       {
+           return originalString;
+       }
+
+        return relativeChangedString;
+    }
+
+    private List restoreListOfStrings( List originalStrings,
+                                           List originalInterpolatedStrings,
+                                           List changedStrings,
+                                           MavenProject project,
+                                           ProjectBuilderConfiguration config )
+        throws ModelInterpolationException
+    {
+        if ( originalStrings == null )
+        {
+            return changedStrings;
+        }
+        else if ( changedStrings == null )
+        {
+            return originalStrings;
+        }
+
+        List result = new ArrayList();
+
+        Map orig = new HashMap();
+        for ( int idx = 0; idx < originalStrings.size(); idx++ )
+        {
+            String[] permutations = new String[2];
+
+            permutations[0] = (String) originalInterpolatedStrings.get( idx );
+            permutations[1] = (String) originalStrings.get( idx );
+
+            orig.put( permutations[0], permutations );
+        }
+
+        for ( Iterator it = changedStrings.iterator(); it.hasNext(); )
+        {
+            String changedString = (String) it.next();
+            String relativeChangedString;
+            if ( project.getBasedir() != null )
+            {
+                relativeChangedString = pathTranslator.unalignFromBaseDirectory( changedString, project.getBasedir() );
+            }
+            else
+            {
+                relativeChangedString = changedString;
+            }
+
+            String interpolated = modelInterpolator.interpolate( changedString,
+                                                                 project.getModel(),
+                                                                 project.getBasedir(),
+                                                                 config,
+                                                                 getLogger().isDebugEnabled() );
+
+            String relativeInterpolated = modelInterpolator.interpolate( relativeChangedString,
+                                                                         project.getModel(),
+                                                                         project.getBasedir(),
+                                                                         config,
+                                                                         getLogger().isDebugEnabled() );
+
+            String[] original = (String[]) orig.get( interpolated );
+            if ( original == null )
+            {
+                original = (String[]) orig.get( relativeInterpolated );
+            }
+
+            if ( original == null )
+            {
+                result.add( relativeChangedString );
+            }
+            else
+            {
+                result.add( original[1] );
+            }
+        }
+
+        return result;
+    }
+
+    private List restoreResources( List originalResources,
+                                       List originalInterpolatedResources,
+                                       List changedResources,
+                                       MavenProject project,
+                                       ProjectBuilderConfiguration config )
+        throws ModelInterpolationException
+    {
+        if ( originalResources == null || changedResources == null )
+        {
+            return originalResources;
+        }
+
+        List result = new ArrayList();
+
+        Map orig = new HashMap();
+        for ( int idx = 0; idx < originalResources.size(); idx++ )
+        {
+            Resource[] permutations = new Resource[2];
+
+            permutations[0] = (Resource) originalInterpolatedResources.get( idx );
+            permutations[1] = (Resource) originalResources.get( idx );
+
+            orig.put( permutations[0].getDirectory(), permutations );
+        }
+
+        for ( Iterator it = changedResources.iterator(); it.hasNext(); )
+        {
+            Resource resource = (Resource) it.next();
+            String rDir = modelInterpolator.interpolate( resource.getDirectory(), project.getModel(), project.getBasedir(), config, getLogger().isDebugEnabled() );
+
+            String relativeDir;
+            if ( project.getBasedir() != null )
+            {
+                relativeDir = pathTranslator.unalignFromBaseDirectory( resource.getDirectory(),
+                                                                       project.getBasedir() );
+            }
+            else
+            {
+                relativeDir = resource.getDirectory();
+            }
+
+            String relativeRDir = modelInterpolator.interpolate( relativeDir, project.getModel(), project.getBasedir(), config, getLogger().isDebugEnabled() );
+
+            Resource[] original = (Resource[]) orig.get( rDir );
+            if ( original == null )
+            {
+                original = (Resource[]) orig.get( relativeRDir );
+            }
+
+            if ( original == null )
+            {
+                result.add( resource );
+            }
+            else
+            {
+                // TODO: Synchronize all non-directory fields, such as targetPath, includes, and excludes.
+//                String target = interpolator.interpolate( resource.getTargetPath(), model, context );
+//                String oTarget = interpolator.interpolate( originalResource.getTargetPath(), model, context );
+
+                result.add( original[1] );
+            }
+        }
+
+        return result;
+    }
+
     private void validateModel( Model model,
                                 File pomFile )
         throws InvalidProjectModelException

Modified: maven/sandbox/branches/maven-2.1/maven-project/src/main/java/org/apache/maven/project/MavenProject.java
URL: http://svn.apache.org/viewvc/maven/sandbox/branches/maven-2.1/maven-project/src/main/java/org/apache/maven/project/MavenProject.java?rev=672884&r1=672883&r2=672884&view=diff
==============================================================================
--- maven/sandbox/branches/maven-2.1/maven-project/src/main/java/org/apache/maven/project/MavenProject.java (original)
+++ maven/sandbox/branches/maven-2.1/maven-project/src/main/java/org/apache/maven/project/MavenProject.java Mon Jun 30 12:52:51 2008
@@ -98,9 +98,9 @@
 
     private Artifact parentArtifact;
 
-    private Set pluginArtifacts;
+    private Set<Artifact> pluginArtifacts;
 
-    private List remoteArtifactRepositories;
+    private List<ArtifactRepository> remoteArtifactRepositories;
 
     private List collectedProjects = Collections.EMPTY_LIST;
 
@@ -172,6 +172,7 @@
     /**
      * @deprecated use {@link #clone()} so subclasses can provide a copy of the same class
      */
+    @Deprecated
     public MavenProject( MavenProject project )
     {
         deepCopy( project );
@@ -282,6 +283,38 @@
         {
             setSnapshotArtifactRepository( project.getSnapshotArtifactRepository() );
         }
+
+        if ( project.isConcrete() )
+        {
+            setDynamicBuild( ModelUtils.cloneBuild( project.getDynamicBuild() ) );
+            setOriginalInterpolatedBuild( ModelUtils.cloneBuild( project.getOriginalInterpolatedBuild() ) );
+
+            List dynamicRoots = project.getDynamicCompileSourceRoots();
+            if ( dynamicRoots != null )
+            {
+                setDynamicCompileSourceRoots( new ArrayList( dynamicRoots ) );
+                setOriginalInterpolatedCompileSourceRoots( new ArrayList(
+                                                                          project.getOriginalInterpolatedCompileSourceRoots() ) );
+            }
+
+            dynamicRoots = project.getDynamicTestCompileSourceRoots();
+            if ( dynamicRoots != null )
+            {
+                setDynamicTestCompileSourceRoots( new ArrayList( dynamicRoots ) );
+                setOriginalInterpolatedTestCompileSourceRoots( new ArrayList(
+                                                                              project.getOriginalInterpolatedTestCompileSourceRoots() ) );
+            }
+
+            dynamicRoots = project.getDynamicScriptSourceRoots();
+            if ( dynamicRoots != null )
+            {
+                setDynamicScriptSourceRoots( new ArrayList( dynamicRoots ) );
+                setOriginalInterpolatedScriptSourceRoots( new ArrayList(
+                                                                         project.getOriginalInterpolatedScriptSourceRoots() ) );
+            }
+        }
+
+        setConcrete( project.isConcrete() );
     }
 
     // TODO: Find a way to use <relativePath/> here...it's tricky, because the moduleProject
@@ -376,7 +409,7 @@
         this.remoteArtifactRepositories = remoteArtifactRepositories;
     }
 
-    public List getRemoteArtifactRepositories()
+    public List<ArtifactRepository> getRemoteArtifactRepositories()
     {
         return remoteArtifactRepositories;
     }
@@ -1537,6 +1570,7 @@
         return managedVersionMap;
     }
 
+    @Override
     public boolean equals( Object other )
     {
         if ( other == this )
@@ -1555,6 +1589,7 @@
         }
     }
 
+    @Override
     public int hashCode()
     {
         return getId().hashCode();
@@ -1598,6 +1633,7 @@
     /**
      * @deprecated Use MavenProjectHelper.attachArtifact(..) instead.
      */
+    @Deprecated
     public void attachArtifact( String type, String classifier, File file )
     {
     }
@@ -1807,6 +1843,7 @@
     /**
      * Default toString
      */
+    @Override
     public String toString()
     {
         StringBuffer sb = new StringBuffer(30);
@@ -1834,6 +1871,7 @@
      * @throws CloneNotSupportedException
      * @since 2.0.9
      */
+    @Override
     public Object clone()
         throws CloneNotSupportedException
     {
@@ -1842,4 +1880,159 @@
         return clone;
     }
 
+// ----------------------------------------------------------------------------
+// CODE BELOW IS USED TO PRESERVE DYNAMISM IN THE BUILD SECTION OF THE POM.
+// ----------------------------------------------------------------------------
+
+    private Build dynamicBuild;
+
+    private Build originalInterpolatedBuild;
+
+    private List dynamicCompileSourceRoots;
+
+    private List originalInterpolatedCompileSourceRoots;
+
+    private List dynamicTestCompileSourceRoots;
+
+    private List originalInterpolatedTestCompileSourceRoots;
+
+    private List dynamicScriptSourceRoots;
+
+    private List originalInterpolatedScriptSourceRoots;
+
+    private boolean isConcrete = false;
+
+    public boolean isConcrete()
+    {
+        return isConcrete;
+    }
+
+    public void setConcrete( boolean concrete )
+    {
+        isConcrete = concrete;
+    }
+
+    public Build getDynamicBuild()
+    {
+        return dynamicBuild;
+    }
+
+    public Build getOriginalInterpolatedBuild()
+    {
+        return originalInterpolatedBuild;
+    }
+
+    public List getDynamicCompileSourceRoots()
+    {
+        return dynamicCompileSourceRoots;
+    }
+
+    public List getOriginalInterpolatedCompileSourceRoots()
+    {
+        return originalInterpolatedCompileSourceRoots;
+    }
+
+    public List getDynamicTestCompileSourceRoots()
+    {
+        return dynamicTestCompileSourceRoots;
+    }
+
+    public List getOriginalInterpolatedTestCompileSourceRoots()
+    {
+        return originalInterpolatedTestCompileSourceRoots;
+    }
+
+    public List getDynamicScriptSourceRoots()
+    {
+        return dynamicScriptSourceRoots;
+    }
+
+    public List getOriginalInterpolatedScriptSourceRoots()
+    {
+        return originalInterpolatedScriptSourceRoots;
+    }
+
+    public void clearRestorableRoots()
+    {
+        dynamicCompileSourceRoots = null;
+        dynamicTestCompileSourceRoots = null;
+        dynamicScriptSourceRoots = null;
+        originalInterpolatedCompileSourceRoots = null;
+        originalInterpolatedScriptSourceRoots = null;
+        originalInterpolatedTestCompileSourceRoots = null;
+    }
+
+    public void clearRestorableBuild()
+    {
+        dynamicBuild = null;
+        originalInterpolatedBuild = null;
+    }
+
+    public void preserveCompileSourceRoots( List originalInterpolatedCompileSourceRoots )
+    {
+        dynamicCompileSourceRoots = getCompileSourceRoots();
+        this.originalInterpolatedCompileSourceRoots = originalInterpolatedCompileSourceRoots;
+    }
+
+    public void preserveTestCompileSourceRoots( List originalInterpolatedTestCompileSourceRoots )
+    {
+        dynamicTestCompileSourceRoots = getTestCompileSourceRoots();
+        this.originalInterpolatedTestCompileSourceRoots = originalInterpolatedTestCompileSourceRoots;
+    }
+
+    public void preserveScriptSourceRoots( List originalInterpolatedScriptSourceRoots )
+    {
+        dynamicScriptSourceRoots = getScriptSourceRoots();
+        this.originalInterpolatedScriptSourceRoots = originalInterpolatedScriptSourceRoots;
+    }
+
+    public void preserveBuild( Build originalInterpolatedBuild )
+    {
+        dynamicBuild = getBuild();
+        this.originalInterpolatedBuild = originalInterpolatedBuild;
+
+        this.originalInterpolatedBuild.setPluginManagement( null );
+        this.originalInterpolatedBuild.setPlugins( null );
+    }
+
+    protected void setDynamicBuild( Build dynamicBuild )
+    {
+        this.dynamicBuild = dynamicBuild;
+    }
+
+    protected void setOriginalInterpolatedBuild( Build originalInterpolatedBuild )
+    {
+        this.originalInterpolatedBuild = originalInterpolatedBuild;
+    }
+
+    protected void setDynamicCompileSourceRoots( List dynamicCompileSourceRoots )
+    {
+        this.dynamicCompileSourceRoots = dynamicCompileSourceRoots;
+    }
+
+    protected void setOriginalInterpolatedCompileSourceRoots( List originalInterpolatedCompileSourceRoots )
+    {
+        this.originalInterpolatedCompileSourceRoots = originalInterpolatedCompileSourceRoots;
+    }
+
+    protected void setDynamicTestCompileSourceRoots( List dynamicTestCompileSourceRoots )
+    {
+        this.dynamicTestCompileSourceRoots = dynamicTestCompileSourceRoots;
+    }
+
+    protected void setOriginalInterpolatedTestCompileSourceRoots( List originalInterpolatedTestCompileSourceRoots )
+    {
+        this.originalInterpolatedTestCompileSourceRoots = originalInterpolatedTestCompileSourceRoots;
+    }
+
+    protected void setDynamicScriptSourceRoots( List dynamicScriptSourceRoots )
+    {
+        this.dynamicScriptSourceRoots = dynamicScriptSourceRoots;
+    }
+
+    protected void setOriginalInterpolatedScriptSourceRoots( List originalInterpolatedScriptSourceRoots )
+    {
+        this.originalInterpolatedScriptSourceRoots = originalInterpolatedScriptSourceRoots;
+    }
+
 }

Modified: maven/sandbox/branches/maven-2.1/maven-project/src/main/java/org/apache/maven/project/MavenProjectBuilder.java
URL: http://svn.apache.org/viewvc/maven/sandbox/branches/maven-2.1/maven-project/src/main/java/org/apache/maven/project/MavenProjectBuilder.java?rev=672884&r1=672883&r2=672884&view=diff
==============================================================================
--- maven/sandbox/branches/maven-2.1/maven-project/src/main/java/org/apache/maven/project/MavenProjectBuilder.java (original)
+++ maven/sandbox/branches/maven-2.1/maven-project/src/main/java/org/apache/maven/project/MavenProjectBuilder.java Mon Jun 30 12:52:51 2008
@@ -22,6 +22,7 @@
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.profiles.ProfileManager;
+import org.apache.maven.project.interpolation.ModelInterpolationException;
 
 import java.io.File;
 import java.util.List;
@@ -41,6 +42,7 @@
     /**
      * @deprecated Use {@link MavenProjectBuilder#build(File, ProjectBuilderConfiguration)} instead.
      */
+    @Deprecated
     MavenProject build( File project,
                         ArtifactRepository localRepository,
                         ProfileManager globalProfileManager )
@@ -62,6 +64,7 @@
     /**
      * @deprecated Use {@link MavenProjectBuilder#buildProjectWithDependencies(File, ProjectBuilderConfiguration)} instead.
      */
+    @Deprecated
     MavenProjectBuildingResult buildProjectWithDependencies( File project,
                                                              ArtifactRepository localRepository,
                                                              ProfileManager globalProfileManager )
@@ -74,6 +77,7 @@
         throws ProjectBuildingException;
 
     /** @deprecated We do not want to allow projects to not have POMs. Maven 1.x repositories be damned. */
+    @Deprecated
     MavenProject buildFromRepository( Artifact artifact,
                                       List remoteArtifactRepositories,
                                       ArtifactRepository localRepository,
@@ -83,15 +87,29 @@
     /**
      * @deprecated Use {@link MavenProjectBuilder#buildStandaloneSuperProject(ProjectBuilderConfiguration)} instead.
      */
+    @Deprecated
     MavenProject buildStandaloneSuperProject()
         throws ProjectBuildingException;
 
     /**
      * @deprecated Use {@link MavenProjectBuilder#buildStandaloneSuperProject(ProjectBuilderConfiguration)} instead.
      */
+    @Deprecated
     MavenProject buildStandaloneSuperProject( ProfileManager profileManager )
         throws ProjectBuildingException;
 
     MavenProject buildStandaloneSuperProject( ProjectBuilderConfiguration config )
         throws ProjectBuildingException;
+
+    // ----------------------------------------------------------------------------
+    // API BELOW IS USED TO PRESERVE DYNAMISM IN THE BUILD SECTION OF THE POM.
+    // ----------------------------------------------------------------------------
+
+    void calculateConcreteState( MavenProject project,
+                                 ProjectBuilderConfiguration config )
+        throws ModelInterpolationException;
+
+    void restoreDynamicState( MavenProject project,
+                              ProjectBuilderConfiguration config )
+        throws ModelInterpolationException;
 }

Modified: maven/sandbox/branches/maven-2.1/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java
URL: http://svn.apache.org/viewvc/maven/sandbox/branches/maven-2.1/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java?rev=672884&r1=672883&r2=672884&view=diff
==============================================================================
--- maven/sandbox/branches/maven-2.1/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java (original)
+++ maven/sandbox/branches/maven-2.1/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java Mon Jun 30 12:52:51 2008
@@ -581,6 +581,17 @@
         return newModel;
     }
 
+    public static Build cloneBuild( Build build )
+    {
+        ModelInheritanceAssembler assembler = new DefaultModelInheritanceAssembler();
+
+        Build clone = new Build();
+
+        assembler.assembleBuildInheritance( clone, build );
+
+        return clone;
+    }
+
     private static List cloneProfiles( List profiles )
     {
         if ( profiles == null )

Modified: maven/sandbox/branches/maven-2.1/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
URL: http://svn.apache.org/viewvc/maven/sandbox/branches/maven-2.1/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java?rev=672884&r1=672883&r2=672884&view=diff
==============================================================================
--- maven/sandbox/branches/maven-2.1/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java (original)
+++ maven/sandbox/branches/maven-2.1/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java Mon Jun 30 12:52:51 2008
@@ -363,15 +363,15 @@
      * @todo desperately needs refactoring. It's just here because it's implementation is maven-project specific
      * @return {@link Set} &lt; {@link Artifact} >
      */
-    public static Set createArtifacts( ArtifactFactory artifactFactory, List dependencies, String inheritedScope,
+    public static Set<Artifact> createArtifacts( ArtifactFactory artifactFactory, List<Dependency> dependencies, String inheritedScope,
                                        ArtifactFilter dependencyFilter, MavenProject project )
         throws InvalidDependencyVersionException
     {
-        Set projectArtifacts = new LinkedHashSet( dependencies.size() );
+        Set<Artifact> projectArtifacts = new LinkedHashSet<Artifact>( dependencies.size() );
 
-        for ( Iterator i = dependencies.iterator(); i.hasNext(); )
+        for ( Iterator<Dependency> i = dependencies.iterator(); i.hasNext(); )
         {
-            Dependency d = (Dependency) i.next();
+            Dependency d = i.next();
 
             String scope = d.getScope();
 
@@ -406,10 +406,10 @@
             {
                 if ( ( d.getExclusions() != null ) && !d.getExclusions().isEmpty() )
                 {
-                    List exclusions = new ArrayList();
-                    for ( Iterator j = d.getExclusions().iterator(); j.hasNext(); )
+                    List<String> exclusions = new ArrayList<String>();
+                    for ( Iterator<Exclusion> j = d.getExclusions().iterator(); j.hasNext(); )
                     {
-                        Exclusion e = (Exclusion) j.next();
+                        Exclusion e = j.next();
                         exclusions.add( e.getGroupId() + ":" + e.getArtifactId() );
                     }
 

Modified: maven/sandbox/branches/maven-2.1/maven-project/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java
URL: http://svn.apache.org/viewvc/maven/sandbox/branches/maven-2.1/maven-project/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java?rev=672884&r1=672883&r2=672884&view=diff
==============================================================================
--- maven/sandbox/branches/maven-2.1/maven-project/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java (original)
+++ maven/sandbox/branches/maven-2.1/maven-project/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java Mon Jun 30 12:52:51 2008
@@ -27,6 +27,7 @@
 import org.apache.maven.model.Model;
 import org.apache.maven.model.PluginManagement;
 import org.apache.maven.model.Reporting;
+import org.apache.maven.model.Resource;
 import org.apache.maven.model.Scm;
 import org.apache.maven.model.Site;
 import org.apache.maven.project.ModelUtils;
@@ -184,6 +185,8 @@
         child.setProperties( props );
     }
 
+    // TODO: Remove this!
+    @SuppressWarnings("unchecked")
     private void assembleDependencyManagementInheritance( Model child, Model parent )
     {
         DependencyManagement parentDepMgmt = parent.getDependencyManagement();
@@ -198,18 +201,18 @@
             }
             else
             {
-                List childDeps = childDepMgmt.getDependencies();
+                List<Dependency> childDeps = childDepMgmt.getDependencies();
 
-                Map mappedChildDeps = new TreeMap();
-                for ( Iterator it = childDeps.iterator(); it.hasNext(); )
+                Map<String, Dependency> mappedChildDeps = new TreeMap<String, Dependency>();
+                for ( Iterator<Dependency> it = childDeps.iterator(); it.hasNext(); )
                 {
-                    Dependency dep = (Dependency) it.next();
+                    Dependency dep = it.next();
                     mappedChildDeps.put( dep.getManagementKey(), dep );
                 }
 
-                for ( Iterator it = parentDepMgmt.getDependencies().iterator(); it.hasNext(); )
+                for ( Iterator<Dependency> it = parentDepMgmt.getDependencies().iterator(); it.hasNext(); )
                 {
-                    Dependency dep = (Dependency) it.next();
+                    Dependency dep = it.next();
                     if ( !mappedChildDeps.containsKey( dep.getManagementKey() ) )
                     {
                         childDepMgmt.addDependency( dep );
@@ -244,17 +247,19 @@
         }
     }
 
+    // TODO: Remove this!
+    @SuppressWarnings("unchecked")
     private void assembleDependencyInheritance( Model child, Model parent )
     {
-        Map depsMap = new LinkedHashMap();
+        Map<String, Dependency> depsMap = new LinkedHashMap<String, Dependency>();
 
-        List deps = parent.getDependencies();
+        List<Dependency> deps = parent.getDependencies();
 
         if ( deps != null )
         {
-            for ( Iterator it = deps.iterator(); it.hasNext(); )
+            for ( Iterator<Dependency> it = deps.iterator(); it.hasNext(); )
             {
-                Dependency dependency = (Dependency) it.next();
+                Dependency dependency = it.next();
                 depsMap.put( dependency.getManagementKey(), dependency );
             }
         }
@@ -263,14 +268,14 @@
 
         if ( deps != null )
         {
-            for ( Iterator it = deps.iterator(); it.hasNext(); )
+            for ( Iterator<Dependency> it = deps.iterator(); it.hasNext(); )
             {
-                Dependency dependency = (Dependency) it.next();
+                Dependency dependency = it.next();
                 depsMap.put( dependency.getManagementKey(), dependency );
             }
         }
 
-        child.setDependencies( new ArrayList( depsMap.values() ) );
+        child.setDependencies( new ArrayList<Dependency>( depsMap.values() ) );
     }
 
     private void assembleBuildInheritance( Model child, Model parent )
@@ -286,83 +291,91 @@
                 child.setBuild( childBuild );
             }
 
-            // The build has been set but we want to step in here and fill in
-            // values that have not been set by the child.
+            assembleBuildInheritance( childBuild, parentBuild );
+        }
+    }
 
-            if ( childBuild.getSourceDirectory() == null )
-            {
-                childBuild.setSourceDirectory( parentBuild.getSourceDirectory() );
-            }
+    // TODO: Remove this!
+    @SuppressWarnings("unchecked")
+    public void assembleBuildInheritance( Build childBuild,
+                                           Build parentBuild )
+    {
+        // The build has been set but we want to step in here and fill in
+        // values that have not been set by the child.
 
-            if ( childBuild.getScriptSourceDirectory() == null )
-            {
-                childBuild.setScriptSourceDirectory( parentBuild.getScriptSourceDirectory() );
-            }
+        if ( childBuild.getSourceDirectory() == null )
+        {
+            childBuild.setSourceDirectory( parentBuild.getSourceDirectory() );
+        }
 
-            if ( childBuild.getTestSourceDirectory() == null )
-            {
-                childBuild.setTestSourceDirectory( parentBuild.getTestSourceDirectory() );
-            }
+        if ( childBuild.getScriptSourceDirectory() == null )
+        {
+            childBuild.setScriptSourceDirectory( parentBuild.getScriptSourceDirectory() );
+        }
 
-            if ( childBuild.getOutputDirectory() == null )
-            {
-                childBuild.setOutputDirectory( parentBuild.getOutputDirectory() );
-            }
+        if ( childBuild.getTestSourceDirectory() == null )
+        {
+            childBuild.setTestSourceDirectory( parentBuild.getTestSourceDirectory() );
+        }
 
-            if ( childBuild.getTestOutputDirectory() == null )
-            {
-                childBuild.setTestOutputDirectory( parentBuild.getTestOutputDirectory() );
-            }
+        if ( childBuild.getOutputDirectory() == null )
+        {
+            childBuild.setOutputDirectory( parentBuild.getOutputDirectory() );
+        }
 
-            // Extensions are accumlated
-            ModelUtils.mergeExtensionLists( childBuild, parentBuild );
+        if ( childBuild.getTestOutputDirectory() == null )
+        {
+            childBuild.setTestOutputDirectory( parentBuild.getTestOutputDirectory() );
+        }
 
-            if ( childBuild.getDirectory() == null )
-            {
-                childBuild.setDirectory( parentBuild.getDirectory() );
-            }
+        // Extensions are accumlated
+        ModelUtils.mergeExtensionLists( childBuild, parentBuild );
 
-            if ( childBuild.getDefaultGoal() == null )
-            {
-                childBuild.setDefaultGoal( parentBuild.getDefaultGoal() );
-            }
+        if ( childBuild.getDirectory() == null )
+        {
+            childBuild.setDirectory( parentBuild.getDirectory() );
+        }
 
-            if ( childBuild.getFinalName() == null )
-            {
-                childBuild.setFinalName( parentBuild.getFinalName() );
-            }
+        if ( childBuild.getDefaultGoal() == null )
+        {
+            childBuild.setDefaultGoal( parentBuild.getDefaultGoal() );
+        }
 
-            ModelUtils.mergeFilterLists( childBuild.getFilters(), parentBuild.getFilters() );
+        if ( childBuild.getFinalName() == null )
+        {
+            childBuild.setFinalName( parentBuild.getFinalName() );
+        }
 
-            List resources = childBuild.getResources();
-            if ( ( resources == null ) || resources.isEmpty() )
-            {
-                childBuild.setResources( parentBuild.getResources() );
-            }
+        ModelUtils.mergeFilterLists( childBuild.getFilters(), parentBuild.getFilters() );
 
-            resources = childBuild.getTestResources();
-            if ( ( resources == null ) || resources.isEmpty() )
-            {
-                childBuild.setTestResources( parentBuild.getTestResources() );
-            }
+        List<Resource> resources = childBuild.getResources();
+        if ( ( resources == null ) || resources.isEmpty() )
+        {
+            childBuild.setResources( parentBuild.getResources() );
+        }
 
-            // Plugins are aggregated if Plugin.inherit != false
-            ModelUtils.mergePluginLists( childBuild, parentBuild, true );
+        resources = childBuild.getTestResources();
+        if ( ( resources == null ) || resources.isEmpty() )
+        {
+            childBuild.setTestResources( parentBuild.getTestResources() );
+        }
 
-            // Plugin management :: aggregate
-            PluginManagement dominantPM = childBuild.getPluginManagement();
-            PluginManagement recessivePM = parentBuild.getPluginManagement();
+        // Plugins are aggregated if Plugin.inherit != false
+        ModelUtils.mergePluginLists( childBuild, parentBuild, true );
 
-            if ( ( dominantPM == null ) && ( recessivePM != null ) )
-            {
-                // FIXME: Filter out the inherited == false stuff!
-                childBuild.setPluginManagement( recessivePM );
-            }
-            else
-            {
-                ModelUtils.mergePluginLists( childBuild.getPluginManagement(), parentBuild.getPluginManagement(),
-                                             false );
-            }
+        // Plugin management :: aggregate
+        PluginManagement dominantPM = childBuild.getPluginManagement();
+        PluginManagement recessivePM = parentBuild.getPluginManagement();
+
+        if ( ( dominantPM == null ) && ( recessivePM != null ) )
+        {
+            // FIXME: Filter out the inherited == false stuff!
+            childBuild.setPluginManagement( recessivePM );
+        }
+        else
+        {
+            ModelUtils.mergePluginLists( childBuild.getPluginManagement(), parentBuild.getPluginManagement(),
+                                         false );
         }
     }
 
@@ -525,7 +538,7 @@
     // TODO: Move this to plexus-utils' PathTool.
     private static String resolvePath( String uncleanPath )
     {
-        LinkedList pathElements = new LinkedList();
+        LinkedList<String> pathElements = new LinkedList<String>();
 
         StringTokenizer tokenizer = new StringTokenizer( uncleanPath, "/" );
 

Modified: maven/sandbox/branches/maven-2.1/maven-project/src/main/java/org/apache/maven/project/inheritance/ModelInheritanceAssembler.java
URL: http://svn.apache.org/viewvc/maven/sandbox/branches/maven-2.1/maven-project/src/main/java/org/apache/maven/project/inheritance/ModelInheritanceAssembler.java?rev=672884&r1=672883&r2=672884&view=diff
==============================================================================
--- maven/sandbox/branches/maven-2.1/maven-project/src/main/java/org/apache/maven/project/inheritance/ModelInheritanceAssembler.java (original)
+++ maven/sandbox/branches/maven-2.1/maven-project/src/main/java/org/apache/maven/project/inheritance/ModelInheritanceAssembler.java Mon Jun 30 12:52:51 2008
@@ -19,6 +19,7 @@
  * under the License.
  */
 
+import org.apache.maven.model.Build;
 import org.apache.maven.model.Model;
 
 /**
@@ -33,5 +34,8 @@
 
     void assembleModelInheritance( Model child, Model parent );
 
+    void assembleBuildInheritance( Build childBuild,
+                                          Build parentBuild );
+
     void copyModel( Model dest, Model source );
 }

Modified: maven/sandbox/branches/maven-2.1/maven-project/src/main/java/org/apache/maven/project/path/DefaultPathTranslator.java
URL: http://svn.apache.org/viewvc/maven/sandbox/branches/maven-2.1/maven-project/src/main/java/org/apache/maven/project/path/DefaultPathTranslator.java?rev=672884&r1=672883&r2=672884&view=diff
==============================================================================
--- maven/sandbox/branches/maven-2.1/maven-project/src/main/java/org/apache/maven/project/path/DefaultPathTranslator.java (original)
+++ maven/sandbox/branches/maven-2.1/maven-project/src/main/java/org/apache/maven/project/path/DefaultPathTranslator.java Mon Jun 30 12:52:51 2008
@@ -31,6 +31,12 @@
 public class DefaultPathTranslator
     implements PathTranslator
 {
+    private static final String[] BASEDIR_EXPRESSIONS = {
+        "${basedir}",
+        "${pom.basedir}",
+        "${project.basedir}"
+    };
+
     private String FILE_SEPARATOR = "/";
 
     public void alignToBaseDirectory( Model model, File basedir )
@@ -91,18 +97,28 @@
 
     private String stripBasedirToken( String s )
     {
-        String basedirExpr = "${basedir}";
-
         if ( s != null )
         {
-            s = s.trim();
+            String basedirExpr = null;
+            for ( int i = 0; i < BASEDIR_EXPRESSIONS.length; i++ )
+            {
+                basedirExpr = BASEDIR_EXPRESSIONS[i];
+                if ( s.startsWith( basedirExpr ) )
+                {
+                    break;
+                }
+                else
+                {
+                    basedirExpr = null;
+                }
+            }
 
-            if ( s.startsWith( basedirExpr ) )
+            if ( basedirExpr != null )
             {
                 if ( s.length() > basedirExpr.length() )
                 {
-                    // Take out ${basedir} and the leading slash
-                    s = s.substring( basedirExpr.length() + 1 );
+                    // Take out basedir expression and the leading slash
+                    s = chopLeadingFileSeparator( s.substring( basedirExpr.length() ) );
                 }
                 else
                 {
@@ -114,6 +130,25 @@
         return s;
     }
 
+    /**
+     * Removes the leading directory separator from the specified filesystem path (if any). For platform-independent
+     * behavior, this method accepts both the forward slash and the backward slash as separator.
+     *
+     * @param path The filesystem path, may be <code>null</code>.
+     * @return The altered filesystem path or <code>null</code> if the input path was <code>null</code>.
+     */
+    private String chopLeadingFileSeparator( String path )
+    {
+        if ( path != null )
+        {
+            if ( path.startsWith( "/" ) || path.startsWith( "\\" ) )
+            {
+                path = path.substring( 1 );
+            }
+        }
+        return path;
+    }
+
     private boolean requiresBaseDirectoryAlignment( String s )
     {
         if ( s != null )

Modified: maven/sandbox/branches/maven-2.1/maven-project/src/test/java/org/apache/maven/project/DefaultMavenProjectBuilderTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/branches/maven-2.1/maven-project/src/test/java/org/apache/maven/project/DefaultMavenProjectBuilderTest.java?rev=672884&r1=672883&r2=672884&view=diff
==============================================================================
--- maven/sandbox/branches/maven-2.1/maven-project/src/test/java/org/apache/maven/project/DefaultMavenProjectBuilderTest.java (original)
+++ maven/sandbox/branches/maven-2.1/maven-project/src/test/java/org/apache/maven/project/DefaultMavenProjectBuilderTest.java Mon Jun 30 12:52:51 2008
@@ -42,6 +42,7 @@
 
     private DefaultMavenProjectBuilder projectBuilder;
 
+    @Override
     public void setUp()
         throws Exception
     {
@@ -55,6 +56,7 @@
         filesToDelete.add( localRepoDir );
     }
 
+    @Override
     public void tearDown()
         throws Exception
     {
@@ -114,6 +116,8 @@
 
         MavenProject project = getProject( pom );
 
+        projectBuilder.calculateConcreteState( project, new DefaultProjectBuilderConfiguration() );
+
         Build build = project.getBuild();
         assertNotNull( "Project should have a build section containing the test resource.", build );
 
@@ -132,6 +136,7 @@
         System.out.println( "Interpolated, translated resource directory is: " + res.getDirectory() );
     }
 
+    @Override
     protected ArtifactRepository getLocalRepository()
         throws Exception
     {

Modified: maven/sandbox/branches/maven-2.1/maven-project/src/test/java/org/apache/maven/project/ProjectBaseDirectoryAlignmentTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/branches/maven-2.1/maven-project/src/test/java/org/apache/maven/project/ProjectBaseDirectoryAlignmentTest.java?rev=672884&r1=672883&r2=672884&view=diff
==============================================================================
--- maven/sandbox/branches/maven-2.1/maven-project/src/test/java/org/apache/maven/project/ProjectBaseDirectoryAlignmentTest.java (original)
+++ maven/sandbox/branches/maven-2.1/maven-project/src/test/java/org/apache/maven/project/ProjectBaseDirectoryAlignmentTest.java Mon Jun 30 12:52:51 2008
@@ -35,6 +35,7 @@
         File f = getTestFile( dir + "project-which-needs-directory-alignment.xml" );
 
         MavenProject project = getProject( f );
+        projectBuilder.calculateConcreteState( project, new DefaultProjectBuilderConfiguration() );
 
         assertNotNull( "Test project can't be null!", project );
 

Modified: maven/sandbox/branches/maven-2.1/pom.xml
URL: http://svn.apache.org/viewvc/maven/sandbox/branches/maven-2.1/pom.xml?rev=672884&r1=672883&r2=672884&view=diff
==============================================================================
--- maven/sandbox/branches/maven-2.1/pom.xml (original)
+++ maven/sandbox/branches/maven-2.1/pom.xml Mon Jun 30 12:52:51 2008
@@ -47,8 +47,24 @@
   <!-- TODO: TAKE THIS OUT BEFORE WE RELEASE! -->
   <repositories>
     <repository>
+      <id>apache.snapshots</id>
+      <url>http://people.apache.org/repo/m2-snapshot-repository/</url>
+      <snapshots>
+        <enabled>true</enabled>
+      </snapshots>
+      <releases>
+        <enabled>false</enabled>
+      </releases>
+    </repository>
+    <repository>
       <id>codehaus.snapshots</id>
       <url>http://snapshots.repository.codehaus.org/</url>
+      <snapshots>
+        <enabled>true</enabled>
+      </snapshots>
+      <releases>
+        <enabled>false</enabled>
+      </releases>
     </repository>
   </repositories>
   
@@ -166,7 +182,7 @@
         <plugin>
           <groupId>org.codehaus.modello</groupId>
           <artifactId>modello-maven-plugin</artifactId>
-          <version>1.0-alpha-17</version>
+          <version>1.0-alpha-18</version>
           <executions>
             <execution>
               <id>site-docs</id>
@@ -221,6 +237,9 @@
   <properties>
     <plexusVersion>1.0-alpha-48</plexusVersion>
     <wagonVersion>1.0-beta-3</wagonVersion>
+    <!-- Not used, yet...
+    <artifactVersion>3.0-20080630.163621-65</artifactVersion>
+    -->
   </properties>
   
   <!--start-->
@@ -291,6 +310,11 @@
       <artifactId>maven-core</artifactId>
       <version>2.1-SNAPSHOT</version>
     </dependency>  
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-utils</artifactId>
+      <version>1.5.4</version>
+    </dependency>
       <dependency>
         <groupId>org.codehaus.plexus</groupId>
         <artifactId>plexus-container-default</artifactId>
@@ -303,11 +327,6 @@
       </dependency>
       <dependency>
         <groupId>org.codehaus.plexus</groupId>
-        <artifactId>plexus-utils</artifactId>
-        <version>1.5.1</version>
-      </dependency>
-      <dependency>
-        <groupId>org.codehaus.plexus</groupId>
         <artifactId>plexus-interpolation</artifactId>
         <version>1.0</version>
       </dependency>
@@ -339,6 +358,9 @@
       <dependency>
         <groupId>org.apache.maven.artifact</groupId>
         <artifactId>maven-artifact</artifactId>
+        <!--
+        <version>${artifactVersion}</version>
+        -->
         <version>3.0-SNAPSHOT</version>
       </dependency>
       <dependency>
@@ -394,7 +416,7 @@
     <!--start-->
   </dependencyManagement>
   <!--end--> 
-   
+  
   <distributionManagement>
     <site>
       <id>apache.website</id>



Mime
View raw message