Author: jvanzyl
Date: Sat Mar 21 20:18:36 2009
New Revision: 757003

URL: http://svn.apache.org/viewvc?rev=757003&view=rev
Log:
o working creating a clean path of plugin resolution logic, and separting 
report processing from plugin processing

Modified:
    
maven/components/branches/MNG-2766/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java
    
maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/DefaultArtifactFilterManager.java
    
maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
    
maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
    
maven/components/branches/MNG-2766/maven-embedder/src/test/embedder-test-project/pom.xml
    
maven/components/branches/MNG-2766/maven-embedder/src/test/java/org/apache/maven/embedder/MavenEmbedderTest.java

Modified: 
maven/components/branches/MNG-2766/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java
URL: 
http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java?rev=757003&r1=757002&r2=757003&view=diff
==============================================================================
--- 
maven/components/branches/MNG-2766/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java
 (original)
+++ 
maven/components/branches/MNG-2766/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java
 Sat Mar 21 20:18:36 2009
@@ -428,13 +428,7 @@
                                 
         // After the collection we will have the artifact object in the result 
but they will not be resolved yet.
         result = artifactCollector.collect( artifacts, rootArtifact, 
managedVersions, localRepository, remoteRepositories, source, filter, listeners 
);
-        
-        if ( !isDummy( request ) )
-        {
-            // Add the root artifact
-            result.addArtifact( rootArtifact );                        
-        }                
-        
+                
         // We have metadata retrieval problems, or there are cycles that have 
been detected
         // so we give this back to the calling code and let them deal with 
this information
         // appropriately.
@@ -469,6 +463,14 @@
             }
         }
                 
+        // We want to send the root artifact back in the result but we need to 
do this after the other dependencies
+        // have been resolved.
+        if ( !isDummy( request ) )
+        {
+            // Add the root artifact
+            result.addArtifact( rootArtifact );                        
+        }                        
+        
         return result;
     }
 

Modified: 
maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/DefaultArtifactFilterManager.java
URL: 
http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/DefaultArtifactFilterManager.java?rev=757003&r1=757002&r2=757003&view=diff
==============================================================================
--- 
maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/DefaultArtifactFilterManager.java
 (original)
+++ 
maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/DefaultArtifactFilterManager.java
 Sat Mar 21 20:18:36 2009
@@ -59,6 +59,7 @@
         artifacts.add( "maven-plugin-api" );
         artifacts.add( "maven-plugin-descriptor" );
         artifacts.add( "maven-plugin-parameter-documenter" );
+        artifacts.add( "maven-plugin-registry" );
         artifacts.add( "maven-profile" );
         artifacts.add( "maven-project" );
         artifacts.add( "maven-reporting-api" );
@@ -70,6 +71,7 @@
         artifacts.add( "plexus-component-api" );
         artifacts.add( "plexus-container-default" );
         artifacts.add( "plexus-interactivity-api" );
+        artifacts.add( "plexus-interpolation" );        
         artifacts.add( "wagon-provider-api" );
         artifacts.add( "wagon-file" );
         artifacts.add( "wagon-http-lightweight" );

Modified: 
maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
URL: 
http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java?rev=757003&r1=757002&r2=757003&view=diff
==============================================================================
--- 
maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
 (original)
+++ 
maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
 Sat Mar 21 20:18:36 2009
@@ -54,11 +54,9 @@
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.reporting.MavenReport;
 import org.apache.maven.settings.Settings;
-import org.codehaus.plexus.component.annotations.Component;
 import org.codehaus.plexus.component.annotations.Requirement;
 import 
org.codehaus.plexus.component.repository.exception.ComponentLookupException;
 import org.codehaus.plexus.logging.AbstractLogEnabled;
-import org.codehaus.plexus.logging.Logger;
 import org.codehaus.plexus.util.StringUtils;
 import org.codehaus.plexus.util.xml.Xpp3Dom;
 import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
@@ -1302,7 +1300,6 @@
         project.addPlugin( plugin );
 
         MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo( goal );
-        
         return mojoDescriptor;
     }
 

Modified: 
maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
URL: 
http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java?rev=757003&r1=757002&r2=757003&view=diff
==============================================================================
--- 
maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
 (original)
+++ 
maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
 Sat Mar 21 20:18:36 2009
@@ -46,6 +46,7 @@
 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.artifact.resolver.filter.AndArtifactFilter;
 import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
 import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter;
 import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
@@ -169,7 +170,9 @@
         if ( ( pluginVersion == null ) || Artifact.LATEST_VERSION.equals( 
pluginVersion ) || Artifact.RELEASE_VERSION.equals( pluginVersion ) )
         {
             logger.debug( "Resolving version for plugin: " + plugin.getKey() );
+            
             pluginVersion = resolvePluginVersion( plugin.getGroupId(), 
plugin.getArtifactId(), project, session );
+            
             plugin.setVersion( pluginVersion );
 
             logger.debug( "Resolved to version: " + pluginVersion );
@@ -188,10 +191,8 @@
         // and no ChildContainer exists. The check for that below fixes
         // the 'Can't find plexus container for plugin: xxx' error.
         try
-        {
-            Artifact pluginArtifact = resolvePluginArtifact( plugin, project, 
session );
-            
-            addPlugin( plugin, pluginArtifact, project, session );
+        {            
+            addPlugin( plugin, project, session );
 
             project.addPlugin( plugin );
         }
@@ -230,9 +231,29 @@
         return plugin.getGroupId() + ":" + plugin.getArtifactId() + ":" + 
plugin.getVersion();
     }
     
-    protected void addPlugin( Plugin plugin, Artifact pluginArtifact, 
MavenProject project, MavenSession session )
-        throws ArtifactNotFoundException, ArtifactResolutionException, 
PluginManagerException, InvalidPluginException
-    {
+    protected void addPlugin( Plugin plugin, MavenProject project, 
MavenSession session )
+        throws ArtifactNotFoundException, ArtifactResolutionException, 
PluginManagerException, InvalidPluginException, PluginVersionResolutionException
+    {                
+        logger.debug( "Resolving plugin artifact " + plugin.getKey() + " from 
" + project.getRemoteArtifactRepositories() );
+
+        ArtifactRepository localRepository = session.getLocalRepository();
+
+        MavenProject pluginProject = buildPluginProject( plugin, 
localRepository, project.getRemoteArtifactRepositories() );
+
+        Artifact pluginArtifact = repositorySystem.createPluginArtifact( 
plugin );
+
+        checkRequiredMavenVersion( plugin, pluginProject, localRepository, 
project.getRemoteArtifactRepositories() );
+
+        checkPluginDependencySpec( plugin, pluginProject );
+
+        pluginArtifact = project.replaceWithActiveArtifact( pluginArtifact );
+
+        ArtifactResolutionRequest request = new ArtifactResolutionRequest( 
pluginArtifact, localRepository, project.getRemoteArtifactRepositories() );
+
+        ArtifactResolutionResult result = repositorySystem.resolve( request );
+
+        resolutionErrorHandler.throwErrors( request, result );        
+        
         // 
----------------------------------------------------------------------------
         // Get the dependencies for the Plugin
         // 
----------------------------------------------------------------------------
@@ -240,6 +261,8 @@
         // the only Plugin instance which will have dependencies is the one 
specified in the project.
         // We need to look for a Plugin instance there, in case the instance 
we're using didn't come from
         // the project.
+        
+        // Trying to cache the version of the plugin for a project?
         Plugin projectPlugin = project.getPlugin( plugin.getKey() );
 
         if ( projectPlugin == null )
@@ -272,7 +295,7 @@
                     // Not going to happen
                 }
             }
-                        
+                              
             try
             {
                 logger.debug( "Discovering components in realm: " + 
pluginRealm );
@@ -319,11 +342,18 @@
         }
     }
 
+    // plugin artifact
+    //   its dependencies while filtering out what's in the core
+    //   layering on the project level plugin dependencies
+    
+    
     private Set<Artifact> getPluginArtifacts( Artifact pluginArtifact, Plugin 
plugin, MavenProject project, ArtifactRepository localRepository )
         throws InvalidPluginException, ArtifactNotFoundException, 
ArtifactResolutionException
     {
-        ArtifactFilter filter = new ScopeArtifactFilter( 
Artifact.SCOPE_RUNTIME_PLUS_SYSTEM );
-
+        AndArtifactFilter filter = new AndArtifactFilter();
+        filter.add( coreArtifactFilterManager.getCoreArtifactFilter() );
+        filter.add( new ScopeArtifactFilter( 
Artifact.SCOPE_RUNTIME_PLUS_SYSTEM ) );
+        
         Set<Artifact> projectPluginDependencies;
 
         // The case where we have a plugin that can host multiple versions of 
a particular tool. Say the 
@@ -333,7 +363,7 @@
 
         try
         {
-            projectPluginDependencies = repositorySystem.createArtifacts( 
plugin.getDependencies(), null, 
coreArtifactFilterManager.getCoreArtifactFilter(), project );
+            projectPluginDependencies = repositorySystem.createArtifacts( 
plugin.getDependencies(), null, filter, project );
         }
         catch ( VersionNotFoundException e )
         {
@@ -1305,6 +1335,7 @@
                 result.setUnresolvedArtifacts( null );
             }
         }
+        
         resolutionErrorHandler.throwErrors( request, result );
 
         project.setArtifacts( result.getArtifacts() );
@@ -1365,9 +1396,9 @@
         List<ArtifactRepository> remoteArtifactRepositories = 
project.getRemoteArtifactRepositories();
 
         for ( Iterator<Artifact> it = project.getArtifacts().iterator(); 
it.hasNext(); )
-        {
+        {            
             Artifact artifact = (Artifact) it.next();
-
+            
             repositorySystem.resolve( new ArtifactResolutionRequest( artifact, 
localRepository, remoteArtifactRepositories ) );
         }
     }
@@ -1446,27 +1477,27 @@
     public String resolvePluginVersion( String groupId, String artifactId, 
MavenProject project, MavenSession session )
         throws PluginVersionResolutionException, InvalidPluginException, 
PluginVersionNotFoundException
     {
-        return resolvePluginVersion( groupId, artifactId, project, 
session.getLocalRepository(), false );
-    }
-
-    public String resolveReportPluginVersion( String groupId, String 
artifactId, MavenProject project, MavenSession session )
-        throws PluginVersionResolutionException, InvalidPluginException, 
PluginVersionNotFoundException
-    {
-        return resolvePluginVersion( groupId, artifactId, project, 
session.getLocalRepository(), true );
-    }
-
-    private String resolvePluginVersion( String groupId, String artifactId, 
MavenProject project, ArtifactRepository localRepository, boolean 
resolveAsReportPlugin )
-        throws PluginVersionResolutionException, InvalidPluginException, 
PluginVersionNotFoundException
-    {
-        // first pass...if the plugin is specified in the pom, try to retrieve 
the version from there.
-        String version = getVersionFromPluginConfig( groupId, artifactId, 
project, resolveAsReportPlugin );
+        String version = null;
+        
+        if ( project.getBuildPlugins() != null )
+        {
+            for ( Iterator it = project.getBuildPlugins().iterator(); 
it.hasNext() && ( version == null ); )
+            {
+                Plugin plugin = (Plugin) it.next();
 
+                if ( groupId.equals( plugin.getGroupId() ) && 
artifactId.equals( plugin.getArtifactId() ) )
+                {
+                    version = plugin.getVersion();
+                }
+            }
+        }
+        
         // final pass...retrieve the version for RELEASE and also set that 
resolved version as the <useVersion/>
         // in settings.xml.
         if ( StringUtils.isEmpty( version ) || 
Artifact.RELEASE_VERSION.equals( version ) )
         {
             // 1. resolve the version to be used
-            version = resolveMetaVersion( groupId, artifactId, project, 
localRepository, Artifact.RELEASE_VERSION );
+            version = resolveMetaVersion( groupId, artifactId, project, 
session.getLocalRepository(), Artifact.RELEASE_VERSION );
             logger.debug( "Version from RELEASE metadata: " + version );
         }
 
@@ -1476,42 +1507,40 @@
             throw new PluginVersionNotFoundException( groupId, artifactId );
         }
 
-        return version;
+        return version;        
     }
 
-    private String getVersionFromPluginConfig( String groupId, String 
artifactId, MavenProject project, boolean resolveAsReportPlugin )
+    public String resolveReportPluginVersion( String groupId, String 
artifactId, MavenProject project, MavenSession session )
+        throws PluginVersionResolutionException, InvalidPluginException, 
PluginVersionNotFoundException
     {
         String version = null;
-
-        if ( resolveAsReportPlugin )
+        
+        if ( project.getReportPlugins() != null )
         {
-            if ( project.getReportPlugins() != null )
+            for ( Iterator it = project.getReportPlugins().iterator(); 
it.hasNext() && ( version == null ); )
             {
-                for ( Iterator it = project.getReportPlugins().iterator(); 
it.hasNext() && ( version == null ); )
-                {
-                    ReportPlugin plugin = (ReportPlugin) it.next();
+                ReportPlugin plugin = (ReportPlugin) it.next();
 
-                    if ( groupId.equals( plugin.getGroupId() ) && 
artifactId.equals( plugin.getArtifactId() ) )
-                    {
-                        version = plugin.getVersion();
-                    }
+                if ( groupId.equals( plugin.getGroupId() ) && 
artifactId.equals( plugin.getArtifactId() ) )
+                {
+                    version = plugin.getVersion();
                 }
             }
         }
-        else
+        
+        // final pass...retrieve the version for RELEASE and also set that 
resolved version as the <useVersion/>
+        // in settings.xml.
+        if ( StringUtils.isEmpty( version ) || 
Artifact.RELEASE_VERSION.equals( version ) )
         {
-            if ( project.getBuildPlugins() != null )
-            {
-                for ( Iterator it = project.getBuildPlugins().iterator(); 
it.hasNext() && ( version == null ); )
-                {
-                    Plugin plugin = (Plugin) it.next();
+            // 1. resolve the version to be used
+            version = resolveMetaVersion( groupId, artifactId, project, 
session.getLocalRepository(), Artifact.RELEASE_VERSION );
+            logger.debug( "Version from RELEASE metadata: " + version );
+        }
 
-                    if ( groupId.equals( plugin.getGroupId() ) && 
artifactId.equals( plugin.getArtifactId() ) )
-                    {
-                        version = plugin.getVersion();
-                    }
-                }
-            }
+        // if we still haven't found a version, then fail early before we get 
into the update goop.
+        if ( StringUtils.isEmpty( version ) )
+        {
+            throw new PluginVersionNotFoundException( groupId, artifactId );
         }
 
         return version;

Modified: 
maven/components/branches/MNG-2766/maven-embedder/src/test/embedder-test-project/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-embedder/src/test/embedder-test-project/pom.xml?rev=757003&r1=757002&r2=757003&view=diff
==============================================================================
--- 
maven/components/branches/MNG-2766/maven-embedder/src/test/embedder-test-project/pom.xml
 (original)
+++ 
maven/components/branches/MNG-2766/maven-embedder/src/test/embedder-test-project/pom.xml
 Sat Mar 21 20:18:36 2009
@@ -1,21 +1,13 @@
-<!--
-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.
--->
+  <!--
+    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.
+  -->
 
 <project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
@@ -44,4 +36,13 @@
       </properties>
     </profile>
   </profiles>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <version>2.4.3</version>
+      </plugin>
+    </plugins>
+  </build>
 </project>

Modified: 
maven/components/branches/MNG-2766/maven-embedder/src/test/java/org/apache/maven/embedder/MavenEmbedderTest.java
URL: 
http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-embedder/src/test/java/org/apache/maven/embedder/MavenEmbedderTest.java?rev=757003&r1=757002&r2=757003&view=diff
==============================================================================
--- 
maven/components/branches/MNG-2766/maven-embedder/src/test/java/org/apache/maven/embedder/MavenEmbedderTest.java
 (original)
+++ 
maven/components/branches/MNG-2766/maven-embedder/src/test/java/org/apache/maven/embedder/MavenEmbedderTest.java
 Sat Mar 21 20:18:36 2009
@@ -55,7 +55,7 @@
 {
     protected String basedir;
 
-    protected MavenEmbedder maven;
+    protected MavenEmbedder mavenEmbedder;
 
 
     protected void setUp()
@@ -77,13 +77,13 @@
             .setMavenEmbedderLogger( new MavenEmbedderConsoleLogger() );
         configuration.setUserSettingsFile( 
MavenEmbedder.DEFAULT_USER_SETTINGS_FILE );
 
-        maven = new MavenEmbedder( configuration );
+        mavenEmbedder = new MavenEmbedder( configuration );
     }
 
     protected void tearDown()
         throws Exception
     {
-        maven.stop();
+        mavenEmbedder.stop();
     }
 
     protected void assertNoExceptions( MavenExecutionResult result )
@@ -119,10 +119,12 @@
 
         FileUtils.copyDirectoryStructure( testDirectory, targetDirectory );
 
-        MavenExecutionRequest request = new 
DefaultMavenExecutionRequest().setBaseDirectory( targetDirectory )
-            .setShowErrors( true ).setGoals( Arrays.asList( new 
String[]{"package"} ) );
+        MavenExecutionRequest request = new DefaultMavenExecutionRequest()
+            .setBaseDirectory( targetDirectory )
+            .setShowErrors( true )
+            .setGoals( Arrays.asList( new String[]{"package"} ) );
 
-        MavenExecutionResult result = maven.execute( request );
+        MavenExecutionResult result = mavenEmbedder.execute( request );
 
         assertNoExceptions( result );
 
@@ -148,7 +150,7 @@
         MavenExecutionRequest request = new 
DefaultMavenExecutionRequest().setBaseDirectory( targetDirectory )
             .setShowErrors( true ).setGoals( Arrays.asList( new 
String[]{"validate"} ) );
 
-        MavenExecutionResult result = maven.execute( request );
+        MavenExecutionResult result = mavenEmbedder.execute( request );
         List exceptions = result.getExceptions();
         assertEquals("Incorrect number of exceptions", 1, exceptions.size());
 
@@ -172,7 +174,7 @@
             .setPom( new File( targetDirectory, "pom.xml" ) ).setShowErrors( 
true )
             .setGoals( Arrays.asList( new String[] { "package" } ) );
 
-        MavenExecutionResult result = maven.execute( request );
+        MavenExecutionResult result = mavenEmbedder.execute( request );
 
         assertNoExceptions( result );
         
@@ -200,7 +202,7 @@
             .setPom( new File( targetDirectory, "pom.xml" ) ).setShowErrors( 
true )
             .setGoals( Arrays.asList( new String[] { "validate" } ) );
 
-        MavenExecutionResult r0 = maven.execute( requestWithoutProfile );
+        MavenExecutionResult r0 = mavenEmbedder.execute( requestWithoutProfile 
);
 
         assertNoExceptions( r0 );
 
@@ -220,7 +222,7 @@
             .setGoals( Arrays.asList( new String[] { "validate" } ) )
             .addActiveProfile( "embedderProfile" );
 
-        MavenExecutionResult r1 = maven.execute( request );
+        MavenExecutionResult r1 = mavenEmbedder.execute( request );
 
         MavenProject p1 = r1.getProject();
 
@@ -248,7 +250,7 @@
         File pom = new File( targetDirectory, "pom.xml" );
 
         /* Add the surefire plugin 2.2 to the pom */
-        Model model = maven.readModel( pom );
+        Model model = mavenEmbedder.readModel( pom );
 
         Plugin plugin = new Plugin();
         plugin.setArtifactId( "maven-surefire-plugin" );
@@ -257,14 +259,14 @@
         model.getBuild().addPlugin( plugin );
 
         Writer writer = WriterFactory.newXmlWriter( pom );
-        maven.writeModel( writer, model );
+        mavenEmbedder.writeModel( writer, model );
         writer.close();
 
         /* execute maven */
         MavenExecutionRequest request = new 
DefaultMavenExecutionRequest().setPom( pom ).setShowErrors( true )
             .setGoals( Arrays.asList( new String[] { "package" } ) );
 
-        MavenExecutionResult result = maven.execute( request );
+        MavenExecutionResult result = mavenEmbedder.execute( request );
 
         assertNoExceptions( result );
 
@@ -276,13 +278,13 @@
         /* Add the surefire plugin 2.3 to the pom */
         plugin.setVersion( "2.3" );
         writer = WriterFactory.newXmlWriter( pom );
-        maven.writeModel( writer, model );
+        mavenEmbedder.writeModel( writer, model );
         writer.close();
 
         /* execute Maven */
         request = new DefaultMavenExecutionRequest().setPom( pom 
).setShowErrors( true )
             .setGoals( Arrays.asList( new String[] { "package" } ) );
-        result = maven.execute( request );
+        result = mavenEmbedder.execute( request );
 
         assertNoExceptions( result );
 
@@ -299,7 +301,7 @@
     public void testRetrievingLifecyclePhases()
         throws Exception
     {
-        List phases = maven.getLifecyclePhases();
+        List phases = mavenEmbedder.getLifecyclePhases();
                 
         assertEquals( "validate", (String) phases.get( 0 ) );
 
@@ -315,7 +317,7 @@
     public void testLocalRepositoryRetrieval()
         throws Exception
     {
-        assertNotNull( maven.getLocalRepository().getBasedir() );
+        assertNotNull( mavenEmbedder.getLocalRepository().getBasedir() );
     }
 
     // ----------------------------------------------------------------------
@@ -329,7 +331,7 @@
         // Test model reading
         // 
----------------------------------------------------------------------
 
-        Model model = maven.readModel( getPomFile() );
+        Model model = mavenEmbedder.readModel( getPomFile() );
 
         assertEquals( "org.apache.maven", model.getGroupId() );
     }
@@ -339,7 +341,7 @@
     {
         MavenExecutionRequest request = new 
DefaultMavenExecutionRequest().setShowErrors( true ).setPom( getPomFile() );
 
-        MavenExecutionResult result = maven.readProjectWithDependencies( 
request );
+        MavenExecutionResult result = 
mavenEmbedder.readProjectWithDependencies( request );
 
         assertNoExceptions( result );
 
@@ -347,7 +349,7 @@
 
         Set artifacts = result.getProject().getArtifacts();
 
-        assertEquals( 1, artifacts.size() );
+        assertEquals( 2, artifacts.size() );
 
         artifacts.iterator().next();
     }
@@ -357,7 +359,7 @@
     {
         File pomFile = new File( basedir, 
"src/test/projects/readProject-withScmInheritance/modules/child1/pom.xml" );
 
-        MavenProject project = maven.readProject( pomFile );
+        MavenProject project = mavenEmbedder.readProject( pomFile );
 
         assertEquals( "http://host/viewer?path=/trunk/parent/child1";, 
project.getScm().getUrl() );
         assertEquals( "scm:svn:http://host/trunk/parent/child1";, 
project.getScm().getConnection() );
@@ -370,7 +372,7 @@
         File pomFile = new File( basedir,
                                  
"src/test/projects/readProject-missingModuleIgnored/pom.xml" );
 
-        maven.readProject( pomFile );
+        mavenEmbedder.readProject( pomFile );
     }
 
     /*
@@ -402,7 +404,7 @@
     public void testModelWriting()
         throws Exception
     {
-        Model model = maven.readModel( getPomFile() );
+        Model model = mavenEmbedder.readModel( getPomFile() );
 
         model.setGroupId( "org.apache.maven.new" );
 
@@ -410,11 +412,11 @@
 
         Writer writer = WriterFactory.newXmlWriter( file );
 
-        maven.writeModel( writer, model );
+        mavenEmbedder.writeModel( writer, model );
 
         writer.close();
 
-        model = maven.readModel( file );
+        model = mavenEmbedder.readModel( file );
 
         assertEquals( "org.apache.maven.new", model.getGroupId() );
     }


Reply via email to