Author: jvanzyl
Date: Sun May  3 18:08:54 2009
New Revision: 771096

URL: http://svn.apache.org/viewvc?rev=771096&view=rev
Log:
o debugging configuration merging

Modified:
    
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/project/DefaultMavenProjectBuilder.java

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=771096&r1=771095&r2=771096&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
 Sun May  3 18:08:54 2009
@@ -15,6 +15,7 @@
  * the License.
  */
 
+import java.io.File;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
@@ -38,11 +39,14 @@
 import org.apache.maven.plugin.PluginExecutionException;
 import org.apache.maven.plugin.PluginLoaderException;
 import org.apache.maven.plugin.PluginManager;
+import org.apache.maven.plugin.PluginParameterExpressionEvaluator;
 import org.apache.maven.plugin.descriptor.MojoDescriptor;
 import org.apache.maven.plugin.descriptor.Parameter;
 import org.apache.maven.plugin.descriptor.PluginDescriptor;
 import org.apache.maven.project.MavenProject;
 import org.codehaus.plexus.component.annotations.Requirement;
+import 
org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
+import 
org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator;
 import org.codehaus.plexus.configuration.PlexusConfiguration;
 import org.codehaus.plexus.logging.Logger;
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
@@ -177,8 +181,9 @@
         for ( MojoExecution mojoExecution : lifecyclePlan )
         {            
             try
-            {
+            {                
                 logger.info( executionDescription( mojoExecution ) );
+                System.out.println( "!!!");
                 System.out.println( mojoExecution.getConfiguration() );
                 pluginManager.executeMojo( session, mojoExecution );
             }
@@ -194,7 +199,7 @@
             }
         }         
     }
-
+    
     private String executionDescription( MojoExecution me )
     {
         PluginDescriptor pd = me.getMojoDescriptor().getPluginDescriptor();
@@ -330,10 +335,10 @@
                 //
                 // 
org.apache.maven.plugins:maven-remote-resources-plugin:1.0:process
                 //
-                MojoDescriptor mojoDescriptor = getMojoDescriptor( mojo, 
project, session.getLocalRepository() ); 
+                MojoDescriptor mojoDescriptor = getMojoDescriptor( mojo, 
project, session.getLocalRepository() );                                
                 
                 MojoExecution mojoExecution = new MojoExecution( 
mojoDescriptor );
-                
+                                
                 String g = 
mojoExecution.getMojoDescriptor().getPluginDescriptor().getGroupId();
                 
                 String a = 
mojoExecution.getMojoDescriptor().getPluginDescriptor().getArtifactId();
@@ -569,6 +574,7 @@
     public Xpp3Dom getDefaultPluginConfiguration( String groupId, String 
artifactId, String version, String goal, MavenProject project, 
ArtifactRepository localRepository ) 
         throws LifecycleExecutionException
     {
+        //return new Xpp3Dom( "configuration" );
         return convert( getMojoDescriptor( 
groupId+":"+artifactId+":"+version+":"+goal, project, localRepository ) );
     }
     
@@ -577,10 +583,9 @@
         return convert( mojoDescriptor );
     }
     
+    
     public Xpp3Dom convert( MojoDescriptor mojoDescriptor  )
-    {
-        Map<String,Parameter> parameters = mojoDescriptor.getParameterMap();
-        
+    {        
         Xpp3Dom dom = new Xpp3Dom( "configuration" );
 
         PlexusConfiguration c = mojoDescriptor.getMojoConfiguration();
@@ -588,15 +593,71 @@
         PlexusConfiguration[] ces = c.getChildren();
         
         for( PlexusConfiguration ce : ces )
-        {
-            Xpp3Dom e = new Xpp3Dom( ce.getName() );
-            e.setValue( ce.getValue( ce.getAttribute( "default-value", null ) 
) );
-            dom.addChild( e );
+        {            
+            if ( ce.getValue( null ) != null )
+            {
+                Xpp3Dom e = new Xpp3Dom( ce.getName() );
+                e.setValue( ce.getValue( null ) );
+                dom.addChild( e );                
+            }
         }
 
         return dom;
     }
     
+    // assign all values
+    // validate everything is fine
+    private Xpp3Dom processConfiguration( MavenSession session, MojoExecution 
mojoExecution )
+    {
+        ExpressionEvaluator expressionEvaluator = new 
PluginParameterExpressionEvaluator( session, mojoExecution );
+
+        MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
+        
+        Map<String,Parameter> parameters = mojoDescriptor.getParameterMap();
+
+        Xpp3Dom configuration = mojoExecution.getConfiguration();
+        
+        for( Xpp3Dom c : configuration.getChildren() )
+        {
+            String configurationName = c.getName();
+            
+            Parameter parameter = parameters.get( configurationName );
+            
+            // Read-only
+            
+            if ( !parameter.isEditable() )
+            {
+                
+            }
+            
+            
+            
+            try
+            {
+                Object value = expressionEvaluator.evaluate( c.getValue() );
+                if ( value == null )
+                {
+                    String e = c.getAttribute( "default-value" );
+                    if ( e != null )
+                    {
+                        System.out.println( ">> " + e );
+                        value = expressionEvaluator.evaluate( e );
+                    }                    
+                }
+                
+                if ( value instanceof String || value instanceof File )
+                c.setValue( value.toString() );
+            }
+            catch ( ExpressionEvaluationException e )
+            {
+                // do nothing
+            }
+        }
+        
+        return mojoExecution.getConfiguration();
+    }
+    
+    
     // These are checks that should be available in real time to IDEs
 
     /*

Modified: 
maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
URL: 
http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java?rev=771096&r1=771095&r2=771096&view=diff
==============================================================================
--- 
maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
 (original)
+++ 
maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
 Sun May  3 18:08:54 2009
@@ -193,9 +193,6 @@
                
                        Set<Plugin> pl = 
lifecycle.populateDefaultConfigurationForPlugins(new HashSet<Plugin>(pln), 
                                project, configuration.getLocalRepository());
-                       /*
-               
-                       */
                                
                        for (Plugin buildPlugin : pl) {
                                Xpp3Dom dom = (Xpp3Dom) 
buildPlugin.getConfiguration();
@@ -219,15 +216,9 @@
                                        }
                                }
 
-                       }               
+                       }
+                       
                        project.getModel().getBuild().setPlugins(new 
ArrayList<Plugin>(pl));
-                       /*
-                       if(model.getArtifactId() != null &&
-                               model.getArtifactId().equals("maven-model"))
-                       {
-                       System.out.println(new 
DomainModel(project.getModel()).asString());
-                       } 
-                       */
                } 
                catch (IOException e) 
                {


Reply via email to