You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by be...@apache.org on 2009/06/01 14:17:53 UTC

svn commit: r780627 [1/2] - in /maven/components/trunk: maven-compat/src/main/java/org/apache/maven/profiles/ maven-core/src/main/java/org/apache/maven/project/ maven-core/src/test/java/org/apache/maven/project/ maven-model-builder/src/main/java/org/ap...

Author: bentmann
Date: Mon Jun  1 12:17:53 2009
New Revision: 780627

URL: http://svn.apache.org/viewvc?rev=780627&view=rev
Log:
o Introduced ModelBuilder component that now hosts most of the logic from the project builder to construct the effective model. With maven-model-builder we now should have a rather slim module that tools can re-use for building models. The project builder is simply layered on top of the model builder.

Added:
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/RepositoryModelResolver.java   (with props)
    maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/DefaultModelBuilder.java   (with props)
    maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/DefaultModelBuildingRequest.java   (with props)
    maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/DefaultModelBuildingResult.java   (with props)
    maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/FileModelSource.java   (with props)
    maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/InvalidModelException.java   (with props)
    maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/InvalidProfileException.java   (with props)
    maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/ModelBuilder.java   (with props)
    maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/ModelBuildingException.java   (with props)
    maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/ModelBuildingRequest.java   (with props)
    maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/ModelBuildingResult.java   (with props)
    maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/ModelSource.java   (with props)
    maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/ModelUtils.java
      - copied, changed from r779760, maven/components/branches/maven-2.2.x/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java
    maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/UnparseableModelException.java   (with props)
    maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/UnresolvableParentException.java   (with props)
    maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/UrlModelSource.java   (with props)
    maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileActivationContext.java   (with props)
    maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/resolver/   (with props)
    maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/resolver/InvalidRepositoryException.java   (with props)
    maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/resolver/ModelResolver.java   (with props)
    maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/resolver/UnresolvableModelException.java   (with props)
Modified:
    maven/components/trunk/maven-compat/src/main/java/org/apache/maven/profiles/ProfileActivationContext.java
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilderConfiguration.java
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingRequest.java
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingRequest.java
    maven/components/trunk/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java
    maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/ProfileActivationContext.java
    maven/components/trunk/maven-model-builder/src/test/java/org/apache/maven/model/profile/activator/AbstractProfileActivatorTest.java
    maven/components/trunk/maven-model/src/main/mdo/maven.mdo

Modified: maven/components/trunk/maven-compat/src/main/java/org/apache/maven/profiles/ProfileActivationContext.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-compat/src/main/java/org/apache/maven/profiles/ProfileActivationContext.java?rev=780627&r1=780626&r2=780627&view=diff
==============================================================================
--- maven/components/trunk/maven-compat/src/main/java/org/apache/maven/profiles/ProfileActivationContext.java (original)
+++ maven/components/trunk/maven-compat/src/main/java/org/apache/maven/profiles/ProfileActivationContext.java Mon Jun  1 12:17:53 2009
@@ -160,4 +160,25 @@
         return getExplicitlyInactiveProfileIds();
     }
 
+    public org.apache.maven.model.profile.ProfileActivationContext setActiveProfileIds( List<String> activeProfileIds )
+    {
+        setExplicitlyActiveProfileIds( activeProfileIds );
+        return this;
+    }
+
+    public org.apache.maven.model.profile.ProfileActivationContext setExecutionProperties(
+                                                                                           Properties executionProperties )
+    {
+        this.executionProperties.clear();
+        this.executionProperties.putAll( executionProperties );
+        return this;
+    }
+
+    public org.apache.maven.model.profile.ProfileActivationContext setInactiveProfileIds(
+                                                                                          List<String> inactiveProfileIds )
+    {
+        setExplicitlyInactiveProfileIds( inactiveProfileIds );
+        return this;
+    }
+
 }

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java?rev=780627&r1=780626&r2=780627&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java Mon Jun  1 12:17:53 2009
@@ -17,16 +17,10 @@
 
 import java.io.File;
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
 
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.ArtifactUtils;
 import org.apache.maven.artifact.InvalidRepositoryException;
-import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.artifact.resolver.ArtifactResolutionException;
 import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
 import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
@@ -35,21 +29,11 @@
 import org.apache.maven.lifecycle.LifecycleExecutor;
 import org.apache.maven.model.Build;
 import org.apache.maven.model.Model;
-import org.apache.maven.model.Parent;
-import org.apache.maven.model.Profile;
-import org.apache.maven.model.Repository;
-import org.apache.maven.model.inheritance.InheritanceAssembler;
-import org.apache.maven.model.interpolator.Interpolator;
+import org.apache.maven.model.ModelBuilder;
+import org.apache.maven.model.ModelBuildingException;
+import org.apache.maven.model.ModelBuildingResult;
 import org.apache.maven.model.io.ModelReader;
-import org.apache.maven.model.management.ManagementInjector;
-import org.apache.maven.model.normalization.ModelNormalizer;
-import org.apache.maven.model.plugin.LifecycleBindingsInjector;
-import org.apache.maven.model.plugin.PluginConfigurationExpander;
-import org.apache.maven.model.profile.ProfileActivationException;
-import org.apache.maven.model.profile.ProfileInjector;
-import org.apache.maven.model.profile.ProfileSelector;
-import org.apache.maven.model.validation.ModelValidationResult;
-import org.apache.maven.model.validation.ModelValidator;
+import org.apache.maven.model.resolver.ModelResolver;
 import org.apache.maven.project.artifact.ProjectArtifact;
 import org.apache.maven.repository.RepositorySystem;
 import org.codehaus.plexus.component.annotations.Component;
@@ -68,10 +52,10 @@
     private Logger logger;
 
     @Requirement
-    private ModelReader modelReader;
+    private ModelBuilder modelBuilder;
 
     @Requirement
-    private ModelValidator validator;
+    private ModelReader modelReader;
 
     @Requirement
     private LifecycleExecutor lifecycle;
@@ -80,30 +64,6 @@
     private RepositorySystem repositorySystem;
 
     @Requirement
-    private ModelNormalizer normalizer;
-
-    @Requirement
-    private InheritanceAssembler inheritanceAssembler;
-
-    @Requirement
-    private Interpolator interpolator;
-
-    @Requirement
-    private ProfileSelector profileSelector;
-
-    @Requirement
-    private ProfileInjector profileInjector;
-
-    @Requirement
-    private ManagementInjector managementInjector;
-
-    @Requirement
-    private LifecycleBindingsInjector lifecycleBindingsInjector;
-
-    @Requirement
-    private PluginConfigurationExpander pluginConfigurationExpander;
-
-    @Requirement
     private ResolutionErrorHandler resolutionErrorHandler;
     
     @Requirement
@@ -133,80 +93,31 @@
             return project;
         }
         
-        List<Model> models;
-        
-        try
-        {
-            models = build( "unknown", pomFile, configuration );
-        }
-        catch ( IOException e )
-        {
-            throw new ProjectBuildingException( "", "", e );
-        }
-
-        Model model = models.get(0);
-        
-        model.setProjectDirectory( projectDirectory );
-
-        //Profiles
-        //
-        // Active profiles can be contributed to the MavenExecutionRequest as well as from the POM
-
-        List<Profile> projectProfiles;
+        ModelResolver resolver =
+            new RepositoryModelResolver( repositorySystem, resolutionErrorHandler, configuration.getLocalRepository(),
+                                         configuration.getRemoteRepositories() );
 
+        ModelBuildingResult result;
         try
         {
-            projectProfiles = new ArrayList<Profile>();
-            projectProfiles.addAll( model.getProfiles() );
-            if ( configuration.getProfiles() != null )
-            {
-                projectProfiles.addAll( configuration.getProfiles() );
-            }
-            projectProfiles = profileSelector.getActiveProfiles( projectProfiles, configuration );
+            result = modelBuilder.build( pomFile, configuration.getModelBuildingRequest(), resolver );
         }
-        catch ( ProfileActivationException e )
+        catch ( ModelBuildingException e )
         {
-            throw new ProjectBuildingException( model.getId(), "Failed to activate pom profiles.", e );
-        }
-
-        for ( Profile p : projectProfiles )
-        {
-            if ( !"pom".equals( p.getSource() ) )
-            {
-                logger.debug( "Merging profile into model (build): Model = " + model.getId() + ", Profile = "
-                    + p.getId() );
-                profileInjector.injectProfile( model, p );
-            }
+            throw new ProjectBuildingException( "[unknown]", "Failed to build project for " + pomFile, pomFile, e );
         }
         
+        Model model = result.getEffectiveModel();
+
+        project = fromModelToMavenProject( model, result.getRawModels().get( 1 ).getPomFile(), configuration, model.getPomFile() );
+     
         try
         {
-            model = interpolateModel( model, configuration, pomFile );
-
-            if ( configuration.isProcessPlugins() )
-            {                
-                lifecycleBindingsInjector.injectLifecycleBindings( model );
-            }
-
-            managementInjector.injectManagement( model );
-
-            validateModel( model, pomFile, configuration.istLenientValidation() );
-
-            File parentFile = ( models.size() > 1 ) ? models.get( 1 ).getPomFile() : null;
-
-            project = fromModelToMavenProject( model, parentFile, configuration, pomFile );
-
             if ( configuration.isProcessPlugins() )
             {
-                pluginConfigurationExpander.expandPluginConfiguration( project.getModel() );
-
-                lifecycle.populateDefaultConfigurationForPlugins( project.getModel().getBuild().getPlugins(), configuration.getLocalRepository(), project.getRemoteArtifactRepositories() );
+                lifecycle.populateDefaultConfigurationForPlugins( model.getBuild().getPlugins(), configuration.getLocalRepository(), project.getRemoteArtifactRepositories() );
             }
         }
-        catch ( IOException e )
-        {
-            throw new ProjectBuildingException( "", "", e );
-        }
         catch ( LifecycleExecutionException e )
         {
             throw new ProjectBuildingException( "", e.getMessage(), e );
@@ -219,7 +130,7 @@
         project.addCompileSourceRoot( build.getSourceDirectory() );
         project.addTestCompileSourceRoot( build.getTestSourceDirectory() );
         project.setFile( pomFile );
-        project.setActiveProfiles( projectProfiles );
+        project.setActiveProfiles( result.getActiveProfiles( result.getRawModel() ) );
                 
         projectCache.put( cacheKey, project );
                 
@@ -321,24 +232,8 @@
         return new MavenProjectBuildingResult( project, result );
     }
 
-    private Model interpolateModel( Model model, ProjectBuildingRequest config, File projectDescriptor )
-        throws ProjectBuildingException
-    {
-        try
-        {
-            model = interpolator.interpolateModel( model, config.getExecutionProperties(), model.getProjectDirectory() );
-        }
-        catch ( IOException e )
-        {
-            String projectId = safeVersionlessKey( model.getGroupId(), model.getArtifactId() );
-            throw new ProjectBuildingException( projectId, "", projectDescriptor, e );
-        }
-
-        return model;
-    }
-
     private MavenProject fromModelToMavenProject( Model model, File parentFile, ProjectBuildingRequest config, File projectDescriptor )
-        throws InvalidProjectModelException, IOException
+        throws InvalidProjectModelException
     {
         MavenProject project;
         String projectId = safeVersionlessKey( model.getGroupId(), model.getArtifactId() );
@@ -360,134 +255,6 @@
         return project;
     }
 
-    private List<Model> build( String projectId, File pomFile, ProjectBuildingRequest projectBuilderConfiguration )
-        throws ProjectBuildingException, IOException
-    {
-        Model mainModel = readModel( projectId, pomFile, !projectBuilderConfiguration.istLenientValidation() );
-        mainModel.setProjectDirectory( pomFile.getParentFile() );
-
-        List<Model> domainModels = new ArrayList<Model>();
-
-        domainModels.add( mainModel );
-
-        ArtifactRepository localRepository = projectBuilderConfiguration.getLocalRepository();
-
-        List<ArtifactRepository> remoteRepositories = new ArrayList<ArtifactRepository>();
-        try
-        {
-            for ( Profile profile : profileSelector.getActiveProfiles( projectBuilderConfiguration.getProfiles(),
-                                                                       projectBuilderConfiguration ) )
-            {
-                for ( Repository repository : profile.getRepositories() )
-                {
-                    try
-                    {
-                        remoteRepositories.add( repositorySystem.buildArtifactRepository( repository ) );
-                    }
-                    catch ( InvalidRepositoryException e )
-                    {
-                        throw new ProjectBuildingException( projectId, "Failed to create remote repository "
-                            + repository, pomFile, e );
-                    }
-                }
-            }
-            remoteRepositories = repositorySystem.getMirrors( remoteRepositories );
-        }
-        catch ( ProfileActivationException e )
-        {
-            throw new ProjectBuildingException( projectId, "Failed to determine active profiles", pomFile, e );
-        }
-        remoteRepositories.addAll( projectBuilderConfiguration.getRemoteRepositories() );
-
-        if ( mainModel.getParent() != null )
-        {
-            List<Model> mavenParents;
-            
-            if ( isParentLocal( mainModel.getParent().getRelativePath(), pomFile.getParentFile() ) )
-            {
-                mavenParents = getDomainModelParentsFromLocalPath( mainModel, localRepository, remoteRepositories, pomFile.getParentFile(), projectBuilderConfiguration );
-            }
-            else
-            {
-                mavenParents = getDomainModelParentsFromRepository( mainModel, localRepository, remoteRepositories );
-            }
-
-            domainModels.addAll( mavenParents );
-        }
-
-        for ( Model model : domainModels )
-        {
-            normalizer.mergeDuplicates( model );
-        }
-
-        domainModels.add( getSuperModel() );
-        List<Model> profileModels = new ArrayList<Model>();
-        //Process Profiles
-        for ( Model model : domainModels )
-        {
-            if ( !model.getProfiles().isEmpty() )
-            {
-                Collection<Profile> profiles;
-                try
-                {
-                    profiles =
-                        profileSelector.getActiveProfiles( model.getProfiles(), projectBuilderConfiguration );
-                }
-                catch ( ProfileActivationException e )
-                {
-                    throw new ProjectBuildingException( projectId, "Failed to determine active profiles", pomFile, e );
-                }
-                if ( !profiles.isEmpty() )
-                {
-                    for ( Profile p : profiles )
-                    {
-                        logger.debug( "Merging profile into model: Model = " + model.getId() + ", Profile = " + p.getId() );
-                        profileInjector.injectProfile( model, p );
-                    }
-                }
-            }
-            profileModels.add( model );
-        }
-
-        processModelsForInheritance( profileModels );
-
-        return profileModels;
-    }
-
-    private Model processModelsForInheritance( List<Model> models )
-    {
-        List<Model> parentsFirst = new ArrayList<Model>( models );
-        Collections.reverse( parentsFirst );
-
-        Model previousModel = null;
-
-        for ( Model currentModel : parentsFirst )
-        {
-            inheritanceAssembler.assembleModelInheritance( currentModel, previousModel );
-            previousModel = currentModel;
-        }
-
-        return previousModel;
-    }
-
-    private void validateModel( Model model, File pomFile, boolean lenient )
-        throws InvalidProjectModelException
-    {
-        // Must validate before artifact construction to make sure dependencies are good
-        ModelValidationResult validationResult = validator.validateEffectiveModel( model, lenient );
-
-        String projectId = safeVersionlessKey( model.getGroupId(), model.getArtifactId() );
-
-        if ( validationResult.getMessageCount() > 0 )
-        {
-            for ( String s : validationResult.getMessages() )
-            {
-                logger.error( s );
-            }
-            throw new InvalidProjectModelException( projectId, "Failed to validate POM", pomFile, validationResult );
-        }
-    }
-
     private static String safeVersionlessKey( String groupId, String artifactId )
     {
         String gid = groupId;
@@ -507,208 +274,6 @@
         return ArtifactUtils.versionlessKey( gid, aid );
     }
 
-    /**
-     * Returns true if the relative path of the specified parent references a pom, otherwise returns
-     * false.
-     * 
-     * @param relativePath the parent model info
-     * @param projectDirectory the project directory of the child pom
-     * @return true if the relative path of the specified parent references a pom, otherwise returns
-     *         fals
-     */
-    private static boolean isParentLocal( String relativePath, File projectDirectory )
-    {
-        File f = new File( projectDirectory, relativePath ).getAbsoluteFile();
-
-        if ( f.isDirectory() )
-        {
-            f = new File( f, "pom.xml" );
-        }
-
-        return f.isFile();
-    }
-
-    private List<Model> getDomainModelParentsFromRepository( Model model, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
-        throws IOException, ProjectBuildingException
-    {
-        List<Model> models = new ArrayList<Model>();
-
-        Parent parent = model.getParent();
-
-        if ( parent == null || localRepository == null )
-        {
-            return models;
-        }
-        
-        Artifact artifactParent =
-            repositorySystem.createProjectArtifact( parent.getGroupId(), parent.getArtifactId(), parent.getVersion() );
-
-        ArtifactResolutionRequest request = new ArtifactResolutionRequest()
-            .setArtifact( artifactParent )
-            .setLocalRepository( localRepository )
-            .setRemoteRepostories( remoteRepositories );
-        
-        ArtifactResolutionResult result;
-        try
-        {
-            result = repositorySystem.resolve( request );
-        }
-        catch ( Exception e )
-        {
-            throw (IOException) new IOException( "The parent POM " + artifactParent + " could not be retrieved from any repository" ).initCause( e );
-        }
-
-        try
-        {
-            resolutionErrorHandler.throwErrors( request, result );
-        }
-        catch ( ArtifactResolutionException e )
-        {
-            throw (IOException) new IOException( "The parent POM " + artifactParent + " could not be retrieved from any repository" ).initCause( e );
-        }
-        
-        Model parentModel = readModel( parent.getId(), artifactParent.getFile(), true );
-
-        if ( !isMatchingParent( parentModel, parent ) )
-        {
-            //shane: what does this mean exactly and why does it occur
-            logger.debug( "Parent pom ids do not match: Parent File = " + artifactParent.getFile().getAbsolutePath() + ": Child ID = " + model.getId() );
-
-            // return domainModels;
-            // TODO: review the proper handling of this, can it happen at all and if should we really continue or error out?
-        }
-
-        models.add( parentModel );
-
-        models.addAll( getDomainModelParentsFromRepository( parentModel, localRepository, remoteRepositories ) );
-        return models;
-    }
-
-    /**
-     * Returns list of domain model parents of the specified domain model. The parent domain models
-     * are part
-     * 
-     * @param domainModel
-     * @param projectDirectory
-     * @return
-     * @throws IOException
-     * @throws ProjectBuildingException 
-     */
-    private List<Model> getDomainModelParentsFromLocalPath( Model model, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories, File projectDirectory,
-                                                                  ProjectBuildingRequest projectBuilderConfiguration )
-        throws IOException, ProjectBuildingException
-    {
-        List<Model> models = new ArrayList<Model>();
-
-        Parent parent = model.getParent();
-
-        if ( parent == null )
-        {
-            return models;
-        }
-
-        File parentFile = new File( projectDirectory, parent.getRelativePath() ).getCanonicalFile();
-        if ( parentFile.isDirectory() )
-        {
-            parentFile = new File( parentFile.getAbsolutePath(), "pom.xml" );
-        }
-        
-        if ( !parentFile.isFile() )
-        {
-            throw new IOException( "File does not exist: File = " + parentFile.getAbsolutePath() );
-        }
-        
-        Model parentModel = readModel( parent.getId(), parentFile, true );
-        parentModel.setProjectDirectory( parentFile.getParentFile() );
-
-        if ( !isMatchingParent( parentModel, parent ) )
-        {
-            logger.info( "Parent pom ids do not match: Parent File = " + parentFile.getAbsolutePath() + ", Parent ID = " + parentModel.getId() + ", Child ID = " + model.getId()
-                + ", Expected Parent ID = " + parent.getId() );
-
-            List<Model> parentModels = getDomainModelParentsFromRepository( model, localRepository, remoteRepositories );
-
-            if ( parentModels.isEmpty() )
-            {
-                throw new IOException( "Unable to find parent pom on local path or repo: " + parent.getId() );
-            }
-
-            models.addAll( parentModels );
-            return models;
-        }
-
-        models.add( parentModel );
-
-        if ( parentModel.getParent() != null )
-        {
-            if ( isParentLocal( parentModel.getParent().getRelativePath(), parentFile.getParentFile() ) )
-            {
-                models.addAll( getDomainModelParentsFromLocalPath( parentModel, localRepository, remoteRepositories,
-                                                                   parentFile.getParentFile(),
-                                                                   projectBuilderConfiguration ) );
-            }
-            else
-            {
-                models.addAll( getDomainModelParentsFromRepository( parentModel, localRepository, remoteRepositories ) );
-            }
-        }
-
-        return models;
-    }
-
-    private boolean isMatchingParent( Model parentModel, Parent parent )
-    {
-        if ( parentModel.getGroupId() != null )
-        {
-            if ( !parent.getGroupId().equals( parentModel.getGroupId() ) )
-            {
-                return false;
-            }
-        }
-        else if ( parentModel.getParent() == null || !parent.getGroupId().equals( parentModel.getParent().getGroupId() ) )
-        {
-            return false;
-        }
-        if ( !parent.getArtifactId().equals( parentModel.getArtifactId() ) )
-        {
-            return false;
-        }
-        if ( parentModel.getVersion() != null )
-        {
-            if ( !parent.getVersion().equals( parentModel.getVersion() ) )
-            {
-                return false;
-            }
-        }
-        else if ( parentModel.getParent() == null || !parent.getVersion().equals( parentModel.getParent().getVersion() ) )
-        {
-            return false;
-        }
-        return true;
-    }
-
-    private Model readModel( String projectId, File pomFile, boolean strict )
-        throws ProjectBuildingException
-    {
-        Model model;
-
-        Map<String, Object> options =
-            Collections.<String, Object> singletonMap( ModelReader.IS_STRICT, Boolean.valueOf( strict ) );
-        try
-        {
-            model = modelReader.read( pomFile, options );
-        }
-        catch ( IOException e )
-        {
-            throw new ProjectBuildingException( projectId, "Failed to read POM for " + projectId + " from " + pomFile
-                + ": " + e.getMessage(), pomFile, e );
-        }
-
-        validator.validateRawModel( model, !strict );
-
-        return model;
-    }
-
     // Super Model Handling
 
     private static final String MAVEN_MODEL_VERSION = "4.0.0";

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilderConfiguration.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilderConfiguration.java?rev=780627&r1=780626&r2=780627&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilderConfiguration.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilderConfiguration.java Mon Jun  1 12:17:53 2009
@@ -19,171 +19,52 @@
  * under the License.
  */
 
-import java.util.ArrayList;
 import java.util.List;
 import java.util.Properties;
 
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.model.ModelEventListener;
-import org.apache.maven.model.Profile;
 
+@Deprecated
 public class DefaultProjectBuilderConfiguration
+    extends DefaultProjectBuildingRequest
     implements ProjectBuilderConfiguration
 {
-    private ArtifactRepository localRepository;
-
-    private List<ArtifactRepository> remoteRepositories;
-    
-    private Properties executionProperties;
-
-    private List<ModelEventListener> listeners;
-    
-    private MavenProject topProject;
-    
-    private boolean processPlugins = true;
-
-    private boolean lenientValidation;
-
-    private List<String> activeProfileIds;
-    
-    private List<String> inactiveProfileIds;
-    
-    private List<Profile> profiles;
-        
-    public MavenProject getTopLevelProjectFromReactor()
-    {
-    	return topProject;
-    }
-    
-    public void setTopLevelProjectForReactor(MavenProject mavenProject)
-    {
-    	this.topProject = mavenProject;
-    }       
 
     public ProjectBuilderConfiguration setLocalRepository( ArtifactRepository localRepository )
     {
-        this.localRepository = localRepository;
+        super.setLocalRepository( localRepository );
         return this;
     }
 
-    public ArtifactRepository getLocalRepository()
-    {
-        return localRepository;
-    }
-        
-    public List<ArtifactRepository> getRemoteRepositories()
-    {
-        if ( remoteRepositories == null )
-        {
-            remoteRepositories = new ArrayList<ArtifactRepository>();
-        }
-        return remoteRepositories;
-    }
-
     public ProjectBuilderConfiguration setRemoteRepositories( List<ArtifactRepository> remoteRepositories )
     {
-        this.remoteRepositories = remoteRepositories;
+        super.setRemoteRepositories( remoteRepositories );
         return this;
     }
-    
-    public Properties getExecutionProperties()
-    {
-        if ( executionProperties == null )
-        {
-            executionProperties = new Properties();
-        }
-        return executionProperties;
-    }
 
     public ProjectBuilderConfiguration setExecutionProperties( Properties executionProperties )
     {
-        this.executionProperties = executionProperties;
+        super.setExecutionProperties( executionProperties );
         return this;
     }
 
-    public List<ModelEventListener> getModelEventListeners()
-    {
-        return listeners;
-    }
-
     public ProjectBuilderConfiguration setModelEventListeners( List<ModelEventListener> listeners )
     {
-        this.listeners = listeners;
+        super.setModelEventListeners( listeners );
         return this;
     }
 
-    public boolean isProcessPlugins()
-    {
-        return processPlugins;
-    }
-
     public ProjectBuilderConfiguration setProcessPlugins( boolean processPlugins )
     {
-        this.processPlugins = processPlugins;
+        super.setProcessPlugins( processPlugins );
         return this;
     }
 
     public ProjectBuilderConfiguration setLenientValidation( boolean lenientValidation )
     {
-        this.lenientValidation = lenientValidation;
+        super.setLenientValidation( lenientValidation );
         return this;
     }
 
-    public boolean istLenientValidation()
-    {
-        return lenientValidation;
-    }
-
-    public List<String> getActiveProfileIds()
-    {
-        if ( activeProfileIds == null )
-        {
-            activeProfileIds = new ArrayList<String>();
-        }
-        return activeProfileIds;        
-    }
-
-    public void setActiveProfileIds( List<String> activeProfileIds )
-    {
-        this.activeProfileIds = activeProfileIds;      
-    }
-
-    public List<String> getInactiveProfileIds()
-    {
-        if ( inactiveProfileIds == null )
-        {
-            inactiveProfileIds = new ArrayList<String>();
-        }
-        return inactiveProfileIds;
-    }
-
-    public void setInactiveProfileIds( List<String> inactiveProfileIds )
-    {
-        this.inactiveProfileIds = inactiveProfileIds;
-    }
-
-    public void setProfiles( List<Profile> profiles )
-    {
-        this.profiles = profiles;
-    }
-    
-    public void addProfile( Profile profile )
-    {
-        if ( profiles == null )
-        {
-            profiles = new ArrayList<Profile>();
-        }
-        
-        profiles.add( profile );
-    }
-
-    public List<Profile> getProfiles()
-    {
-        if ( profiles == null )
-        {
-            profiles = new ArrayList<Profile>();
-        }
-        return profiles;
-    }
-
 }

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingRequest.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingRequest.java?rev=780627&r1=780626&r2=780627&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingRequest.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingRequest.java Mon Jun  1 12:17:53 2009
@@ -24,6 +24,8 @@
 import java.util.Properties;
 
 import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.model.DefaultModelBuildingRequest;
+import org.apache.maven.model.ModelBuildingRequest;
 import org.apache.maven.model.ModelEventListener;
 import org.apache.maven.model.Profile;
 
@@ -33,23 +35,13 @@
     private ArtifactRepository localRepository;
 
     private List<ArtifactRepository> remoteRepositories;
-    
-    private Properties executionProperties;
 
     private List<ModelEventListener> listeners;
     
     private MavenProject topProject;
-    
-    private boolean processPlugins = true;
 
-    private boolean lenientValidation;
+    private ModelBuildingRequest modelBuildingRequest = new DefaultModelBuildingRequest().setProcessPlugins( true );
 
-    private List<String> activeProfileIds;
-    
-    private List<String> inactiveProfileIds;
-    
-    private List<Profile> profiles;
-        
     public MavenProject getTopLevelProjectFromReactor()
     {
     	return topProject;
@@ -88,16 +80,12 @@
     
     public Properties getExecutionProperties()
     {
-        if ( executionProperties == null )
-        {
-            executionProperties = new Properties();
-        }
-        return executionProperties;
+        return modelBuildingRequest.getExecutionProperties();
     }
 
     public ProjectBuildingRequest setExecutionProperties( Properties executionProperties )
     {
-        this.executionProperties = executionProperties;
+        modelBuildingRequest.setExecutionProperties( executionProperties );
         return this;
     }
 
@@ -114,76 +102,64 @@
 
     public boolean isProcessPlugins()
     {
-        return processPlugins;
+        return modelBuildingRequest.isProcessPlugins();
     }
 
     public ProjectBuildingRequest setProcessPlugins( boolean processPlugins )
     {
-        this.processPlugins = processPlugins;
+        modelBuildingRequest.setProcessPlugins( processPlugins );
         return this;
     }
 
     public ProjectBuildingRequest setLenientValidation( boolean lenientValidation )
     {
-        this.lenientValidation = lenientValidation;
+        modelBuildingRequest.setLenientValidation( lenientValidation );
         return this;
     }
 
     public boolean istLenientValidation()
     {
-        return lenientValidation;
+        return modelBuildingRequest.istLenientValidation();
     }
 
     public List<String> getActiveProfileIds()
     {
-        if ( activeProfileIds == null )
-        {
-            activeProfileIds = new ArrayList<String>();
-        }
-        return activeProfileIds;        
+        return modelBuildingRequest.getActiveProfileIds();
     }
 
     public void setActiveProfileIds( List<String> activeProfileIds )
     {
-        this.activeProfileIds = activeProfileIds;      
+        modelBuildingRequest.setActiveProfileIds( activeProfileIds );
     }
 
     public List<String> getInactiveProfileIds()
     {
-        if ( inactiveProfileIds == null )
-        {
-            inactiveProfileIds = new ArrayList<String>();
-        }
-        return inactiveProfileIds;
+        return modelBuildingRequest.getInactiveProfileIds();
     }
 
     public void setInactiveProfileIds( List<String> inactiveProfileIds )
     {
-        this.inactiveProfileIds = inactiveProfileIds;
+        modelBuildingRequest.setInactiveProfileIds( inactiveProfileIds );
     }
 
     public void setProfiles( List<Profile> profiles )
     {
-        this.profiles = profiles;
+        modelBuildingRequest.setProfiles( profiles );
     }
     
     public void addProfile( Profile profile )
     {
-        if ( profiles == null )
-        {
-            profiles = new ArrayList<Profile>();
-        }
-        
-        profiles.add( profile );
+        modelBuildingRequest.getProfiles().add(profile);
     }
 
     public List<Profile> getProfiles()
     {
-        if ( profiles == null )
-        {
-            profiles = new ArrayList<Profile>();
-        }
-        return profiles;
+        return modelBuildingRequest.getProfiles();
+    }
+
+    public ModelBuildingRequest getModelBuildingRequest()
+    {
+        return modelBuildingRequest;
     }
 
 }

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingRequest.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingRequest.java?rev=780627&r1=780626&r2=780627&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingRequest.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingRequest.java Mon Jun  1 12:17:53 2009
@@ -4,11 +4,10 @@
 import java.util.Properties;
 
 import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.model.ModelBuildingRequest;
 import org.apache.maven.model.Profile;
-import org.apache.maven.model.profile.ProfileActivationContext;
 
 public interface ProjectBuildingRequest
-    extends ProfileActivationContext
 {
     ProjectBuildingRequest setLocalRepository( ArtifactRepository localRepository );
     
@@ -72,4 +71,7 @@
     void setProfiles( List<Profile> profiles );
     
     List<Profile> getProfiles();
+
+    ModelBuildingRequest getModelBuildingRequest();
+
 }

Added: maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/RepositoryModelResolver.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/RepositoryModelResolver.java?rev=780627&view=auto
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/RepositoryModelResolver.java (added)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/RepositoryModelResolver.java Mon Jun  1 12:17:53 2009
@@ -0,0 +1,126 @@
+package org.apache.maven.project;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.resolver.ArtifactResolutionException;
+import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
+import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
+import org.apache.maven.artifact.resolver.ResolutionErrorHandler;
+import org.apache.maven.model.FileModelSource;
+import org.apache.maven.model.ModelSource;
+import org.apache.maven.model.Repository;
+import org.apache.maven.model.resolver.InvalidRepositoryException;
+import org.apache.maven.model.resolver.ModelResolver;
+import org.apache.maven.model.resolver.UnresolvableModelException;
+import org.apache.maven.repository.RepositorySystem;
+
+/**
+ * Implements a model resolver backed by the Maven Repository API.
+ * 
+ * @author Benjamin Bentmann
+ */
+class RepositoryModelResolver
+    implements ModelResolver
+{
+
+    private RepositorySystem repositorySystem;
+
+    private ResolutionErrorHandler resolutionErrorHandler;
+
+    private ArtifactRepository localRepository;
+
+    private List<ArtifactRepository> remoteRepositories;
+
+    public RepositoryModelResolver( RepositorySystem repositorySystem, ResolutionErrorHandler resolutionErrorHandler,
+                                    ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
+    {
+        if ( repositorySystem == null )
+        {
+            throw new IllegalArgumentException( "no repository system specified" );
+        }
+        this.repositorySystem = repositorySystem;
+
+        if ( resolutionErrorHandler == null )
+        {
+            throw new IllegalArgumentException( "no resolution error handler specified" );
+        }
+        this.resolutionErrorHandler = resolutionErrorHandler;
+
+        if ( localRepository == null )
+        {
+            throw new IllegalArgumentException( "no local repository specified" );
+        }
+        this.localRepository = localRepository;
+
+        if ( remoteRepositories == null )
+        {
+            throw new IllegalArgumentException( "no remote repositories specified" );
+        }
+        this.remoteRepositories = new ArrayList<ArtifactRepository>( remoteRepositories );
+    }
+
+    public void addRepository( Repository repository )
+        throws InvalidRepositoryException
+    {
+        try
+        {
+            ArtifactRepository repo = repositorySystem.buildArtifactRepository( repository );
+            remoteRepositories.addAll( 0, repositorySystem.getMirrors( Arrays.asList( repo ) ) );
+        }
+        catch ( org.apache.maven.artifact.InvalidRepositoryException e )
+        {
+            throw new InvalidRepositoryException( "Failed to create artifact repository for " + repository.getId()
+                + " with layout " + repository.getLayout() + " and URL " + repository.getUrl(), repository, e );
+        }
+
+    }
+
+    public ModelSource resolveModel( String groupId, String artifactId, String version )
+        throws UnresolvableModelException
+    {
+        Artifact artifactParent = repositorySystem.createProjectArtifact( groupId, artifactId, version );
+
+        ArtifactResolutionRequest request = new ArtifactResolutionRequest();
+        request.setArtifact( artifactParent );
+        request.setLocalRepository( localRepository );
+        request.setRemoteRepostories( remoteRepositories );
+
+        ArtifactResolutionResult result = repositorySystem.resolve( request );
+
+        try
+        {
+            resolutionErrorHandler.throwErrors( request, result );
+        }
+        catch ( ArtifactResolutionException e )
+        {
+            throw new UnresolvableModelException( "Failed to resolve POM for " + groupId + ":" + artifactId + ":"
+                + version, e );
+        }
+
+        return new FileModelSource( artifactParent.getFile() );
+    }
+
+}

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

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

Modified: maven/components/trunk/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java?rev=780627&r1=780626&r2=780627&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java (original)
+++ maven/components/trunk/maven-core/src/test/java/org/apache/maven/project/PomConstructionTest.java Mon Jun  1 12:17:53 2009
@@ -221,7 +221,6 @@
         throws Exception
     {
         PomTestWrapper pom = buildPom( "reporting-interpolation" );
-        pom = new PomTestWrapper(pom.getMavenProject());
         assertEquals( createPath(Arrays.asList(System.getProperty("user.dir"),
                 "src", "test", "resources-project-builder", "reporting-interpolation", "target", "site")),
                 pom.getValue( "reporting/outputDirectory" ) );

Added: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/DefaultModelBuilder.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/DefaultModelBuilder.java?rev=780627&view=auto
==============================================================================
--- maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/DefaultModelBuilder.java (added)
+++ maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/DefaultModelBuilder.java Mon Jun  1 12:17:53 2009
@@ -0,0 +1,481 @@
+package org.apache.maven.model;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.maven.model.inheritance.InheritanceAssembler;
+import org.apache.maven.model.interpolator.Interpolator;
+import org.apache.maven.model.io.ModelParseException;
+import org.apache.maven.model.io.ModelReader;
+import org.apache.maven.model.management.ManagementInjector;
+import org.apache.maven.model.normalization.ModelNormalizer;
+import org.apache.maven.model.plugin.LifecycleBindingsInjector;
+import org.apache.maven.model.plugin.PluginConfigurationExpander;
+import org.apache.maven.model.profile.ProfileActivationException;
+import org.apache.maven.model.profile.ProfileInjector;
+import org.apache.maven.model.profile.ProfileSelector;
+import org.apache.maven.model.resolver.InvalidRepositoryException;
+import org.apache.maven.model.resolver.ModelResolver;
+import org.apache.maven.model.resolver.UnresolvableModelException;
+import org.apache.maven.model.validation.ModelValidationResult;
+import org.apache.maven.model.validation.ModelValidator;
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
+
+/**
+ * @author Benjamin Bentmann
+ */
+@Component( role = ModelBuilder.class )
+public class DefaultModelBuilder
+    implements ModelBuilder
+{
+
+    private Model superModel;
+
+    @Requirement
+    private ModelReader modelReader;
+
+    @Requirement
+    private ModelValidator modelValidator;
+
+    @Requirement
+    private ModelNormalizer modelNormalizer;
+
+    @Requirement
+    private Interpolator modelInterpolator;
+
+    @Requirement
+    private InheritanceAssembler inheritanceAssembler;
+
+    @Requirement
+    private ProfileSelector profileSelector;
+
+    @Requirement
+    private ProfileInjector profileInjector;
+
+    @Requirement
+    private ManagementInjector managementInjector;
+
+    @Requirement
+    private LifecycleBindingsInjector lifecycleBindingsInjector;
+
+    @Requirement
+    private PluginConfigurationExpander pluginConfigurationExpander;
+
+    public ModelBuildingResult build( File pomFile, ModelBuildingRequest request, ModelResolver modelResolver )
+        throws ModelBuildingException
+    {
+        return build( new FileModelSource( pomFile ), pomFile, request, modelResolver );
+    }
+
+    public ModelBuildingResult build( ModelSource modelSource, ModelBuildingRequest request, ModelResolver modelResolver )
+        throws ModelBuildingException
+    {
+        return build( modelSource, null, request, modelResolver );
+    }
+
+    private ModelBuildingResult build( ModelSource modelSource, File pomFile, ModelBuildingRequest request,
+                                       ModelResolver modelResolver )
+        throws ModelBuildingException
+    {
+        DefaultModelBuildingResult result = new DefaultModelBuildingResult();
+
+        List<Profile> activeExternalProfiles = getActiveExternalProfiles( request );
+
+        Model model = readModel( modelSource, request );
+        model.setPomFile( pomFile );
+
+        List<Model> rawModels = new ArrayList<Model>();
+        List<Model> resultModels = new ArrayList<Model>();
+
+        for ( Model current = model; current != null; current = readParent( current, request, modelResolver ) )
+        {
+            Model resultModel = current;
+            resultModels.add( resultModel );
+
+            Model rawModel = ModelUtils.cloneModel( current );
+            rawModels.add( rawModel );
+
+            modelNormalizer.mergeDuplicates( resultModel );
+
+            List<Profile> activeProjectProfiles = getActiveProjectProfiles( rawModel, request );
+
+            List<Profile> activeProfiles = activeProjectProfiles;
+            if ( current == model )
+            {
+                activeProfiles = new ArrayList<Profile>( activeProjectProfiles.size() + activeExternalProfiles.size() );
+                activeProfiles.addAll( activeProjectProfiles );
+                activeProfiles.addAll( activeExternalProfiles );
+            }
+
+            for ( Profile activeProfile : activeProfiles )
+            {
+                profileInjector.injectProfile( resultModel, activeProfile );
+            }
+
+            result.setActiveProfiles( rawModel, activeProfiles );
+
+            configureResolver( modelResolver, resultModel );
+        }
+
+        Model superModel = getSuperModel();
+        rawModels.add( superModel );
+        resultModels.add( superModel );
+
+        result.setRawModels( rawModels );
+
+        assembleInheritance( resultModels );
+
+        Model resultModel = resultModels.get( 0 );
+
+        resultModel = interpolateModel( resultModel, request );
+        resultModels.set( 0, resultModel );
+
+        if ( request.isProcessPlugins() )
+        {
+            lifecycleBindingsInjector.injectLifecycleBindings( resultModel );
+        }
+
+        managementInjector.injectManagement( resultModel );
+
+        if ( request.isProcessPlugins() )
+        {
+            pluginConfigurationExpander.expandPluginConfiguration( resultModel );
+        }
+
+        validateModel( resultModel, false, request );
+
+        result.setEffectiveModel( resultModel );
+
+        return result;
+    }
+
+    private Model readModel( ModelSource modelSource, ModelBuildingRequest request )
+        throws ModelBuildingException
+    {
+        Model model;
+
+        try
+        {
+            Map<String, Object> options =
+                Collections.<String, Object> singletonMap( ModelReader.IS_STRICT,
+                                                           Boolean.valueOf( !request.istLenientValidation() ) );
+            model = modelReader.read( modelSource.getInputStream(), options );
+        }
+        catch ( ModelParseException e )
+        {
+            throw new UnparseableModelException( "Failed to parse POM " + modelSource.getLocation(), e.getLineNumber(),
+                                                 e.getColumnNumber(), e );
+        }
+        catch ( IOException e )
+        {
+            throw new UnparseableModelException( "Failed to read POM " + modelSource.getLocation(), -1, -1, e );
+        }
+
+        validateModel( model, true, request );
+
+        return model;
+    }
+
+    private void validateModel( Model model, boolean raw, ModelBuildingRequest request )
+        throws ModelBuildingException
+    {
+        ModelValidationResult result;
+
+        if ( raw )
+        {
+            result = modelValidator.validateRawModel( model, request.istLenientValidation() );
+        }
+        else
+        {
+            result = modelValidator.validateEffectiveModel( model, request.istLenientValidation() );
+        }
+
+        if ( result.getMessageCount() > 0 )
+        {
+            throw new InvalidModelException( "Failed to validate POM " + toSourceHint( model ), result );
+        }
+    }
+
+    private List<Profile> getActiveExternalProfiles( ModelBuildingRequest request )
+        throws ModelBuildingException
+    {
+        try
+        {
+            return profileSelector.getActiveProfiles( request.getProfiles(), request.getProfileActivationContext() );
+        }
+        catch ( ProfileActivationException e )
+        {
+            throw new InvalidProfileException( "Failed to determine activation status of external profile "
+                + e.getProfile(), e.getProfile(), e );
+        }
+    }
+
+    private List<Profile> getActiveProjectProfiles( Model model, ModelBuildingRequest request )
+        throws ModelBuildingException
+    {
+        try
+        {
+            return profileSelector.getActiveProfiles( model.getProfiles(), request.getProfileActivationContext() );
+        }
+        catch ( ProfileActivationException e )
+        {
+            throw new InvalidProfileException( "Failed to determine activation status of project profile "
+                + e.getProfile() + " for POM " + toSourceHint( model ), e.getProfile(), e );
+        }
+    }
+
+    private void configureResolver( ModelResolver modelResolver, Model model )
+        throws ModelBuildingException
+    {
+        for ( Repository repository : model.getRepositories() )
+        {
+            try
+            {
+                modelResolver.addRepository( repository );
+            }
+            catch ( InvalidRepositoryException e )
+            {
+                throw new InvalidModelException( "Failed to validate repository " + repository.getId() + " for POM "
+                    + toSourceHint( model ), e );
+            }
+        }
+    }
+
+    private void assembleInheritance( List<Model> models )
+    {
+        for ( int i = models.size() - 2; i >= 0; i-- )
+        {
+            Model parent = models.get( i + 1 );
+            Model child = models.get( i );
+            inheritanceAssembler.assembleModelInheritance( child, parent );
+        }
+    }
+
+    private Model interpolateModel( Model model, ModelBuildingRequest request )
+        throws ModelBuildingException
+    {
+        try
+        {
+            Model result =
+                modelInterpolator.interpolateModel( model,
+                                                    request.getProfileActivationContext().getExecutionProperties(),
+                                                    model.getProjectDirectory() );
+            result.setPomFile( model.getPomFile() );
+            return result;
+        }
+        catch ( IOException e )
+        {
+            throw new ModelBuildingException( "Failed to interpolate model " + toSourceHint( model ), e );
+        }
+    }
+
+    private Model readParent( Model childModel, ModelBuildingRequest request, ModelResolver modelResolver )
+        throws ModelBuildingException
+    {
+        Model parentModel;
+
+        Parent parent = childModel.getParent();
+
+        if ( parent != null )
+        {
+            parentModel = readParentLocally( childModel, request );
+
+            if ( parentModel == null )
+            {
+                parentModel = readParentExternally( childModel, request, modelResolver );
+            }
+        }
+        else
+        {
+            parentModel = null;
+        }
+
+        return parentModel;
+    }
+
+    private Model readParentLocally( Model childModel, ModelBuildingRequest request )
+        throws ModelBuildingException
+    {
+        File projectDirectory = childModel.getProjectDirectory();
+        if ( projectDirectory == null )
+        {
+            return null;
+        }
+
+        Parent parent = childModel.getParent();
+
+        File pomFile = new File( new File( projectDirectory, parent.getRelativePath() ).toURI().normalize() );
+        if ( !pomFile.isFile() )
+        {
+            return null;
+        }
+
+        Model candidateModel = readModel( new FileModelSource( pomFile ), request );
+        candidateModel.setPomFile( pomFile );
+
+        String groupId = candidateModel.getGroupId();
+        if ( groupId == null && candidateModel.getParent() != null )
+        {
+            groupId = candidateModel.getParent().getGroupId();
+        }
+        String artifactId = candidateModel.getArtifactId();
+        String version = candidateModel.getVersion();
+        if ( version == null && candidateModel.getParent() != null )
+        {
+            version = candidateModel.getParent().getVersion();
+        }
+
+        if ( groupId == null || !groupId.equals( parent.getGroupId() ) )
+        {
+            return null;
+        }
+        if ( artifactId == null || !artifactId.equals( parent.getArtifactId() ) )
+        {
+            return null;
+        }
+        if ( version == null || !version.equals( parent.getVersion() ) )
+        {
+            return null;
+        }
+
+        return candidateModel;
+    }
+
+    private Model readParentExternally( Model childModel, ModelBuildingRequest request, ModelResolver modelResolver )
+        throws ModelBuildingException
+    {
+        Parent parent = childModel.getParent();
+
+        ModelSource modelSource;
+        try
+        {
+            modelSource = modelResolver.resolveModel( parent.getGroupId(), parent.getArtifactId(), parent.getVersion() );
+        }
+        catch ( UnresolvableModelException e )
+        {
+            throw new UnresolvableParentException( "Failed to resolve parent POM " + toId( parent ) + " for POM "
+                + toSourceHint( childModel ), e );
+        }
+
+        return readModel( modelSource, request );
+    }
+
+    private Model getSuperModel()
+    {
+        if ( superModel == null )
+        {
+            InputStream is = getClass().getResourceAsStream( "/org/apache/maven/project/pom-4.0.0.xml" );
+            try
+            {
+                superModel = modelReader.read( is, null );
+            }
+            catch ( IOException e )
+            {
+                throw new IllegalStateException( "The super POM is damaged"
+                    + ", please verify the integrity of your Maven installation", e );
+            }
+        }
+
+        return ModelUtils.cloneModel( superModel );
+    }
+
+    private String toSourceHint( Model model )
+    {
+        StringBuilder buffer = new StringBuilder( 128 );
+
+        buffer.append( toId( model ) );
+
+        File pomFile = model.getPomFile();
+        if ( pomFile != null )
+        {
+            buffer.append( " (" ).append( pomFile ).append( ")" );
+        }
+
+        return buffer.toString();
+    }
+
+    private String toId( Model model )
+    {
+        StringBuilder buffer = new StringBuilder( 64 );
+
+        if ( model.getGroupId() != null )
+        {
+            buffer.append( model.getGroupId() );
+        }
+        else if ( model.getParent() != null && model.getParent().getGroupId() != null )
+        {
+            buffer.append( model.getParent().getGroupId() );
+        }
+        else
+        {
+            buffer.append( "[unknown-group-id]" );
+        }
+
+        buffer.append( ':' );
+
+        if ( model.getArtifactId() != null )
+        {
+            buffer.append( model.getArtifactId() );
+        }
+        else
+        {
+            buffer.append( "[unknown-artifact-id]" );
+        }
+
+        buffer.append( ':' );
+
+        if ( model.getVersion() != null )
+        {
+            buffer.append( model.getVersion() );
+        }
+        else if ( model.getParent() != null && model.getParent().getVersion() != null )
+        {
+            buffer.append( model.getParent().getVersion() );
+        }
+        else
+        {
+            buffer.append( "[unknown-version]" );
+        }
+
+        return buffer.toString();
+    }
+
+    private String toId( Parent parent )
+    {
+        StringBuilder buffer = new StringBuilder( 64 );
+
+        buffer.append( parent.getGroupId() );
+        buffer.append( ':' );
+        buffer.append( parent.getArtifactId() );
+        buffer.append( ':' );
+        buffer.append( parent.getVersion() );
+
+        return buffer.toString();
+    }
+
+}

Propchange: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/DefaultModelBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/DefaultModelBuilder.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/DefaultModelBuildingRequest.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/DefaultModelBuildingRequest.java?rev=780627&view=auto
==============================================================================
--- maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/DefaultModelBuildingRequest.java (added)
+++ maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/DefaultModelBuildingRequest.java Mon Jun  1 12:17:53 2009
@@ -0,0 +1,142 @@
+package org.apache.maven.model;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+import org.apache.maven.model.profile.DefaultProfileActivationContext;
+import org.apache.maven.model.profile.ProfileActivationContext;
+
+/**
+ * Collects settings that control building of effective models.
+ * 
+ * @author Benjamin Bentmann
+ */
+public class DefaultModelBuildingRequest
+    implements ModelBuildingRequest
+{
+
+    private boolean lenientValidation;
+
+    private boolean processPlugins;
+
+    private List<Profile> profiles;
+
+    private ProfileActivationContext profileActivationContext;
+
+    public DefaultModelBuildingRequest()
+    {
+        profiles = new ArrayList<Profile>();
+        profileActivationContext = new DefaultProfileActivationContext();
+    }
+
+    public boolean istLenientValidation()
+    {
+        return lenientValidation;
+    }
+
+    public DefaultModelBuildingRequest setLenientValidation( boolean lenientValidation )
+    {
+        this.lenientValidation = lenientValidation;
+
+        return this;
+    }
+
+    public boolean isProcessPlugins()
+    {
+        return processPlugins;
+    }
+
+    public DefaultModelBuildingRequest setProcessPlugins( boolean processPlugins )
+    {
+        this.processPlugins = processPlugins;
+
+        return this;
+    }
+
+    public List<Profile> getProfiles()
+    {
+        return profiles;
+    }
+
+    public DefaultModelBuildingRequest setProfiles( List<Profile> profiles )
+    {
+        this.profiles.clear();
+        if ( profiles != null )
+        {
+            this.profiles.addAll( profiles );
+        }
+
+        return this;
+    }
+
+    public List<String> getActiveProfileIds()
+    {
+        return profileActivationContext.getActiveProfileIds();
+    }
+
+    public ModelBuildingRequest setActiveProfileIds( List<String> activeProfileIds )
+    {
+        profileActivationContext.setActiveProfileIds( activeProfileIds );
+        return this;
+    }
+
+    public List<String> getInactiveProfileIds()
+    {
+        return profileActivationContext.getInactiveProfileIds();
+    }
+
+    public ModelBuildingRequest setInactiveProfileIds( List<String> inactiveProfileIds )
+    {
+        profileActivationContext.setInactiveProfileIds( inactiveProfileIds );
+        return this;
+    }
+
+    public Properties getExecutionProperties()
+    {
+        return profileActivationContext.getExecutionProperties();
+    }
+
+    public ModelBuildingRequest setExecutionProperties( Properties executionProperties )
+    {
+        profileActivationContext.setExecutionProperties( executionProperties );
+        return this;
+    }
+
+    public ProfileActivationContext getProfileActivationContext()
+    {
+        return profileActivationContext;
+    }
+
+    public DefaultModelBuildingRequest setProfileActivationContext( ProfileActivationContext profileActivationContext )
+    {
+        if ( profileActivationContext == null )
+        {
+            throw new IllegalArgumentException( "no profile activation context specified" );
+        }
+
+        this.profileActivationContext = profileActivationContext;
+
+        return this;
+    }
+
+}

Propchange: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/DefaultModelBuildingRequest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/DefaultModelBuildingRequest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/DefaultModelBuildingResult.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/DefaultModelBuildingResult.java?rev=780627&view=auto
==============================================================================
--- maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/DefaultModelBuildingResult.java (added)
+++ maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/DefaultModelBuildingResult.java Mon Jun  1 12:17:53 2009
@@ -0,0 +1,125 @@
+package org.apache.maven.model;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Collects the output of the model builder.
+ * 
+ * @author Benjamin Bentmann
+ */
+public class DefaultModelBuildingResult
+    implements ModelBuildingResult
+{
+
+    private Model model;
+
+    private List<Model> rawModels;
+
+    private Map<Model, List<Profile>> activeProfiles;
+
+    public DefaultModelBuildingResult()
+    {
+        rawModels = new ArrayList<Model>();
+        activeProfiles = new HashMap<Model, List<Profile>>();
+    }
+
+    public Model getEffectiveModel()
+    {
+        return model;
+    }
+
+    public DefaultModelBuildingResult setEffectiveModel( Model model )
+    {
+        this.model = model;
+
+        return this;
+    }
+
+    public Model getRawModel()
+    {
+        return rawModels.get( 0 );
+    }
+
+    public List<Model> getRawModels()
+    {
+        return Collections.unmodifiableList( rawModels );
+    }
+
+    public DefaultModelBuildingResult setRawModels( List<Model> rawModels )
+    {
+        this.rawModels.clear();
+        if ( rawModels != null )
+        {
+            this.rawModels.addAll( rawModels );
+        }
+
+        return this;
+    }
+
+    public List<Profile> getActiveProfiles( Model rawModel )
+    {
+        List<Profile> profiles = this.activeProfiles.get( rawModel );
+        return ( profiles == null ) ? Collections.<Profile> emptyList() : Collections.unmodifiableList( profiles );
+    }
+
+    public DefaultModelBuildingResult setActiveProfiles( Model rawModel, List<Profile> activeProfiles )
+    {
+        if ( rawModel == null )
+        {
+            throw new IllegalArgumentException( "no model specified" );
+        }
+
+        if ( activeProfiles != null )
+        {
+            this.activeProfiles.put( rawModel, new ArrayList<Profile>( activeProfiles ) );
+        }
+        else
+        {
+            this.activeProfiles.remove( rawModel );
+        }
+
+        return this;
+    }
+
+    public DefaultModelBuildingResult addActiveProfiles( Model rawModel, List<Profile> activeProfiles )
+    {
+        if ( rawModel == null )
+        {
+            throw new IllegalArgumentException( "no model specified" );
+        }
+
+        List<Profile> currentProfiles = this.activeProfiles.get( rawModel );
+        if ( currentProfiles == null )
+        {
+            currentProfiles = new ArrayList<Profile>( activeProfiles.size() );
+            this.activeProfiles.put( rawModel, currentProfiles );
+        }
+        currentProfiles.addAll( activeProfiles );
+
+        return this;
+    }
+
+}

Propchange: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/DefaultModelBuildingResult.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/DefaultModelBuildingResult.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/FileModelSource.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/FileModelSource.java?rev=780627&view=auto
==============================================================================
--- maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/FileModelSource.java (added)
+++ maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/FileModelSource.java Mon Jun  1 12:17:53 2009
@@ -0,0 +1,79 @@
+package org.apache.maven.model;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * Wraps an ordinary {@link File} as a model source.
+ * 
+ * @author Benjamin Bentmann
+ */
+public class FileModelSource
+    implements ModelSource
+{
+
+    private File pomFile;
+
+    /**
+     * Creates a new model source backed by the specified file.
+     * 
+     * @param pomFile The POM file, must not be {@code null}.
+     */
+    public FileModelSource( File pomFile )
+    {
+        if ( pomFile == null )
+        {
+            throw new IllegalArgumentException( "no POM file specified" );
+        }
+        this.pomFile = pomFile;
+    }
+
+    public InputStream getInputStream()
+        throws IOException
+    {
+        return new FileInputStream( pomFile );
+    }
+
+    public String getLocation()
+    {
+        return pomFile.getPath();
+    }
+
+    /**
+     * Gets the POM file of this model source.
+     * 
+     * @return The underlying POM file, never {@code null}.
+     */
+    public File getPomFile()
+    {
+        return pomFile;
+    }
+
+    @Override
+    public String toString()
+    {
+        return getLocation();
+    }
+
+}

Propchange: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/FileModelSource.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/FileModelSource.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/InvalidModelException.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/InvalidModelException.java?rev=780627&view=auto
==============================================================================
--- maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/InvalidModelException.java (added)
+++ maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/InvalidModelException.java Mon Jun  1 12:17:53 2009
@@ -0,0 +1,53 @@
+package org.apache.maven.model;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.model.validation.ModelValidationResult;
+
+/**
+ * Signals an error due to invalid or missing model values.
+ * 
+ * @author Benjamin Bentmann
+ */
+public class InvalidModelException
+    extends ModelBuildingException
+{
+
+    private ModelValidationResult validationResult;
+
+    public InvalidModelException( String message, ModelValidationResult validationResult )
+    {
+        super( message );
+        this.validationResult = validationResult;
+    }
+
+    public InvalidModelException( String message, Throwable cause )
+    {
+        super( message, cause );
+        validationResult = new ModelValidationResult();
+        validationResult.addMessage( ( cause != null ) ? cause.getMessage() : message );
+    }
+
+    public ModelValidationResult getValidationResult()
+    {
+        return validationResult;
+    }
+
+}

Propchange: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/InvalidModelException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/InvalidModelException.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/InvalidProfileException.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/InvalidProfileException.java?rev=780627&view=auto
==============================================================================
--- maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/InvalidProfileException.java (added)
+++ maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/InvalidProfileException.java Mon Jun  1 12:17:53 2009
@@ -0,0 +1,59 @@
+package org.apache.maven.model;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Signals an error during profile activation.
+ * 
+ * @author Benjamin Bentmann
+ */
+public class InvalidProfileException
+    extends ModelBuildingException
+{
+
+    /**
+     * The profile which raised this error, can be {@code null}.
+     */
+    private Profile profile;
+
+    /**
+     * Creates a new exception with specified detail message and cause for the given profile.
+     * 
+     * @param message The detail message, may be {@code null}.
+     * @param profile The profile that caused the error, may be {@code null}.
+     * @param cause The cause, may be {@code null}.
+     */
+    public InvalidProfileException( String message, Profile profile, Throwable cause )
+    {
+        super( message );
+        this.profile = profile;
+    }
+
+    /**
+     * Gets the profile that causes this error (if any).
+     * 
+     * @return The profile that causes this error or {@code null} if not applicable.
+     */
+    public Profile getProfile()
+    {
+        return profile;
+    }
+
+}

Propchange: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/InvalidProfileException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/InvalidProfileException.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/ModelBuilder.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/ModelBuilder.java?rev=780627&view=auto
==============================================================================
--- maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/ModelBuilder.java (added)
+++ maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/ModelBuilder.java Mon Jun  1 12:17:53 2009
@@ -0,0 +1,38 @@
+package org.apache.maven.model;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+
+import org.apache.maven.model.resolver.ModelResolver;
+
+/**
+ * @author Benjamin Bentmann
+ */
+public interface ModelBuilder
+{
+
+    ModelBuildingResult build( File pomFile, ModelBuildingRequest request, ModelResolver modelResolver )
+        throws ModelBuildingException;
+
+    ModelBuildingResult build( ModelSource modelSource, ModelBuildingRequest request, ModelResolver modelResolver )
+        throws ModelBuildingException;
+
+}

Propchange: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/ModelBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/ModelBuilder.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/ModelBuildingException.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/ModelBuildingException.java?rev=780627&view=auto
==============================================================================
--- maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/ModelBuildingException.java (added)
+++ maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/ModelBuildingException.java Mon Jun  1 12:17:53 2009
@@ -0,0 +1,41 @@
+package org.apache.maven.model;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Signals an error during model building.
+ * 
+ * @author Benjamin Bentmann
+ */
+public class ModelBuildingException
+    extends Exception
+{
+
+    public ModelBuildingException( String message )
+    {
+        super( message );
+    }
+
+    public ModelBuildingException( String message, Throwable cause )
+    {
+        super( message, cause );
+    }
+
+}

Propchange: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/ModelBuildingException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/ModelBuildingException.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision