Author: brett
Date: Mon Jun  6 18:13:52 2005
New Revision: 188647

URL: http://svn.apache.org/viewcvs?rev=188647&view=rev
Log:
PR: MNG-423
move default value into configuration, rather than relying on Java. More 
convenient for other languages, and allows us to validate/document it. Cleaned 
up the plugin manager handling. More should be pushed into plexus proper.

Modified:
    
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
    
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java
    
maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/Parameter.java
    
maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptorBuilder.java
    
maven/components/trunk/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java
    
maven/components/trunk/maven-plugin-tools/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoDescriptorExtractor.java
    
maven/components/trunk/maven-site/src/site/xdoc/developers/mojo-api-specification.xml

Modified: 
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
URL: 
http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java?rev=188647&r1=188646&r2=188647&view=diff
==============================================================================
--- 
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
 (original)
+++ 
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
 Mon Jun  6 18:13:52 2005
@@ -61,7 +61,6 @@
 import org.codehaus.plexus.util.StringUtils;
 import org.codehaus.plexus.util.xml.Xpp3Dom;
 
-import java.io.File;
 import java.lang.reflect.Field;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -115,13 +114,6 @@
         {
             PluginDescriptor pluginDescriptor = (PluginDescriptor) 
componentSetDescriptor;
 
-            if ( pluginDescriptor.getVersion() == null )
-            {
-                // TODO: temporary - until we're done testing that version is 
always written
-                throw new NullPointerException( "Version was null - check your 
plugin '" + pluginDescriptor.getId() +
-                                                "' was built with Maven 2.0 
Alpha 2" );
-            }
-
 //            String key = pluginDescriptor.getId();
             // TODO: see comment in getPluginDescriptor
             String key = pluginDescriptor.getGroupId() + ":" + 
pluginDescriptor.getArtifactId();
@@ -184,7 +176,7 @@
     public PluginDescriptor verifyPlugin( String groupId, String artifactId, 
String version, MavenSession session )
         throws ArtifactResolutionException, PluginManagerException
     {
-        
+
         String pluginKey = groupId + ":" + artifactId;
         
         // TODO: this should be possibly outside
@@ -239,7 +231,8 @@
         {
             try
             {
-                Artifact pluginArtifact = artifactFactory.createArtifact( 
groupId, artifactId, version, Artifact.SCOPE_RUNTIME,
+                Artifact pluginArtifact = artifactFactory.createArtifact( 
groupId, artifactId, version,
+                                                                          
Artifact.SCOPE_RUNTIME,
                                                                           
MojoDescriptor.MAVEN_PLUGIN, null );
 
                 addPlugin( pluginKey, pluginArtifact, session );
@@ -286,20 +279,21 @@
 
             MavenMetadataSource metadataSource = new MavenMetadataSource( 
artifactResolver, mavenProjectBuilder );
 
-            ArtifactResolutionResult result = 
artifactResolver.resolveTransitively( Collections.singleton( pluginArtifact ), 
session.getRemoteRepositories(), session.getLocalRepository(), metadataSource, 
artifactFilter );
-            
+            ArtifactResolutionResult result = 
artifactResolver.resolveTransitively(
+                Collections.singleton( pluginArtifact ), 
session.getRemoteRepositories(), session.getLocalRepository(),
+                metadataSource, artifactFilter );
+
             Map resolved = result.getArtifacts();
-            
+
             List files = new ArrayList();
-            
+
             for ( Iterator it = resolved.values().iterator(); it.hasNext(); )
             {
                 Artifact artifact = (Artifact) it.next();
-                File artifactFile = artifact.getFile();
-                
+
                 files.add( artifact.getFile() );
             }
-            
+
             container.createChildContainer( pluginKey, files, 
Collections.EMPTY_MAP, Collections.singletonList( this ) );
         }
         finally
@@ -335,7 +329,7 @@
         throws ArtifactResolutionException, PluginManagerException, 
MojoExecutionException
     {
         PlexusContainer pluginContainer = null;
-        
+
         if ( mojoDescriptor.isDependencyResolutionRequired() != null )
         {
 
@@ -375,20 +369,19 @@
         try
         {
             String pluginKey = 
mojoDescriptor.getPluginDescriptor().getPluginLookupKey();
-            
+
             pluginContainer = container.getChildContainer( pluginKey );
-            
-            if( pluginContainer == null )
+
+            if ( pluginContainer == null )
             {
                 throw new PluginConfigurationException( "Cannot find 
PlexusContainer for plugin: " + pluginKey );
             }
-            
+
             plugin = (Mojo) pluginContainer.lookup( Mojo.ROLE, 
mojoDescriptor.getRoleHint() );
             plugin.setLog( mojoLogger );
 
             String goalId = mojoDescriptor.getGoal();
 
-            // TODO: can probable refactor these a little when only the new 
plugin technique is in place
             PluginDescriptor pluginDescriptor = 
mojoDescriptor.getPluginDescriptor();
             Xpp3Dom dom = session.getProject().getGoalConfiguration( 
pluginDescriptor.getGroupId(),
                                                                      
pluginDescriptor.getArtifactId(), goalId );
@@ -401,34 +394,24 @@
             else
             {
                 pomConfiguration = new XmlPlexusConfiguration( dom );
-
-                // Validate against non-editable (@readonly) parameters, to 
make sure users aren't trying to 
-                // override in the POM.
-                // TODO: currently breaks it0014, as an expression is in 
pomConfiguration
-//                validatePomConfiguration( mojoDescriptor, pomConfiguration );
             }
 
-            ExpressionEvaluator expressionEvaluator = new 
PluginParameterExpressionEvaluator( session, pathTranslator,
-                                                                               
               getLogger() );
+            // Validate against non-editable (@readonly) parameters, to make 
sure users aren't trying to
+            // override in the POM.
+            validatePomConfiguration( mojoDescriptor, pomConfiguration );
 
             PlexusConfiguration mergedConfiguration = mergeConfiguration( 
pomConfiguration,
                                                                           
mojoDescriptor.getMojoConfiguration() );
 
-            // TODO: Go back to this when we get the container ready to 
configure mojos...
+            // TODO: plexus
 //            PlexusConfiguration mergedConfiguration = mergeConfiguration( 
pomConfiguration,
 //                                                                          
mojoDescriptor.getConfiguration() );
 
-            try
-            {
-                getPluginConfigurationFromExpressions( plugin, mojoDescriptor, 
mergedConfiguration,
-                                                       pluginContainer, 
expressionEvaluator );
+            ExpressionEvaluator expressionEvaluator = new 
PluginParameterExpressionEvaluator( session, pathTranslator,
+                                                                               
               getLogger() );
+            checkRequiredParameters( mojoDescriptor, mergedConfiguration, 
expressionEvaluator, plugin );
 
-                populatePluginFields( plugin, mojoDescriptor, 
mergedConfiguration, pluginContainer, expressionEvaluator );
-            }
-            catch ( ExpressionEvaluationException e )
-            {
-                throw new MojoExecutionException( "Unable to configure 
plugin", e );
-            }
+            populatePluginFields( plugin, mojoDescriptor, mergedConfiguration, 
pluginContainer, expressionEvaluator );
 
             // !! This is ripe for refactoring to an aspect.
             // Event monitoring.
@@ -467,7 +450,7 @@
             }
             catch ( ComponentLifecycleException e )
             {
-                if( getLogger().isErrorEnabled() )
+                if ( getLogger().isErrorEnabled() )
                 {
                     getLogger().error( "Error releasing plugin - ignoring.", e 
);
                 }
@@ -475,40 +458,127 @@
         }
     }
 
-    private void validatePomConfiguration( MojoDescriptor goal, 
PlexusConfiguration pomConfiguration )
+    private void checkRequiredParameters( MojoDescriptor goal, 
PlexusConfiguration configuration,
+                                          ExpressionEvaluator 
expressionEvaluator, Mojo plugin )
         throws PluginConfigurationException
     {
+        // TODO: this should be built in to the configurator, as we presently 
double process the expressions
+
         List parameters = goal.getParameters();
 
+        List invalidParameters = new ArrayList();
+
         for ( int i = 0; i < parameters.size(); i++ )
         {
             Parameter parameter = (Parameter) parameters.get( i );
 
-            boolean editable = parameter.isEditable();
-
             // the key for the configuration map we're building.
             String key = parameter.getName();
 
-            // the key used to lookup the parameter in the config from the 
POM, etc.
-            String lookupKey = parameter.getAlias();
+            Object fieldValue = null;
+            String expression = null;
+            PlexusConfiguration value = configuration.getChild( key, false );
+            try
+            {
+                if ( value != null )
+                {
+                    expression = value.getValue( null );
+                    fieldValue = expressionEvaluator.evaluate( expression );
+                    if ( fieldValue == null )
+                    {
+                        fieldValue = value.getAttribute( "default-value", null 
);
+                    }
+                }
 
-            if ( StringUtils.isEmpty( lookupKey ) )
+                if ( fieldValue == null && StringUtils.isNotEmpty( 
parameter.getAlias() ) )
+                {
+                    value = configuration.getChild( parameter.getAlias(), 
false );
+                    if ( value != null )
+                    {
+                        expression = value.getValue( null );
+                        fieldValue = expressionEvaluator.evaluate( expression 
);
+                        if ( fieldValue == null )
+                        {
+                            fieldValue = value.getAttribute( "default-value", 
null );
+                        }
+                    }
+                }
+            }
+            catch ( ExpressionEvaluationException e )
             {
-                lookupKey = key;
+                throw new PluginConfigurationException( "Bad expression", e );
             }
 
-            // Make sure the parameter is either editable/configurable, or 
else is NOT specified in the POM 
-            if ( !editable && ( pomConfiguration.getChild( lookupKey, false ) 
!= null ||
-                pomConfiguration.getChild( key, false ) != null ) )
+            if ( fieldValue == null && goal.getComponentConfigurator() == null 
)
             {
-                StringBuffer errorMessage = new StringBuffer().append( "ERROR: 
Cannot override read-only parameter: " ).append(
-                    key );
-
-                if ( !lookupKey.equals( key ) )
+                try
                 {
-                    errorMessage.append( " (with alias: " ).append( lookupKey 
).append( ")" );
+                    // TODO: remove in beta-1
+                    Field field = findPluginField( plugin.getClass(), 
parameter.getName() );
+                    boolean accessible = field.isAccessible();
+                    if ( !accessible )
+                    {
+                        field.setAccessible( true );
+                    }
+                    fieldValue = field.get( plugin );
+                    if ( !accessible )
+                    {
+                        field.setAccessible( false );
+                    }
+                    if ( fieldValue != null )
+                    {
+                        getLogger().warn( "DEPRECATED: using default-value to 
set the default value of field '" +
+                                          parameter.getName() + "'" );
+                    }
                 }
+                catch ( NoSuchFieldException e )
+                {
+                    throw new PluginConfigurationException( "Unable to find 
field to check default value", e );
+                }
+                catch ( IllegalAccessException e )
+                {
+                    throw new PluginConfigurationException( "Unable to read 
field to check default value", e );
+                }
+            }
+
+            if ( parameter.isRequired() && fieldValue == null )
+            {
+                parameter.setExpression( expression );
+                invalidParameters.add( parameter );
+            }
+        }
+
+        if ( !invalidParameters.isEmpty() )
+        {
+            throw new PluginParameterException( goal, invalidParameters );
+        }
+    }
+
+    private void validatePomConfiguration( MojoDescriptor goal, 
PlexusConfiguration pomConfiguration )
+        throws PluginConfigurationException
+    {
+        List parameters = goal.getParameters();
+
+        for ( int i = 0; i < parameters.size(); i++ )
+        {
+            Parameter parameter = (Parameter) parameters.get( i );
+
+            // the key for the configuration map we're building.
+            String key = parameter.getName();
 
+            PlexusConfiguration value = pomConfiguration.getChild( key, false 
);
+
+            if ( value == null && StringUtils.isNotEmpty( parameter.getAlias() 
) )
+            {
+                key = parameter.getAlias();
+                value = pomConfiguration.getChild( key, false );
+            }
+
+            // Make sure the parameter is either editable/configurable, or 
else is NOT specified in the POM
+            if ( !parameter.isEditable() && value != null )
+            {
+                StringBuffer errorMessage = new StringBuffer().append( "ERROR: 
Cannot override read-only parameter: " );
+                errorMessage.append( key );
                 errorMessage.append( " in goal: " ).append( 
goal.getFullGoalName() );
 
                 throw new PluginConfigurationException( 
errorMessage.toString() );
@@ -575,15 +645,16 @@
             // TODO: should this be known to the component factory instead? 
And if so, should configuration be part of lookup?
             if ( StringUtils.isNotEmpty( configuratorId ) )
             {
-                configurator = (ComponentConfigurator) pluginContainer.lookup( 
ComponentConfigurator.ROLE, configuratorId );
+                configurator =
+                    (ComponentConfigurator) pluginContainer.lookup( 
ComponentConfigurator.ROLE, configuratorId );
             }
             else
             {
                 configurator = (ComponentConfigurator) pluginContainer.lookup( 
ComponentConfigurator.ROLE );
             }
 
-            configurator.configureComponent( plugin, configuration, 
expressionEvaluator, pluginContainer.getContainerRealm() );
-
+            configurator.configureComponent( plugin, configuration, 
expressionEvaluator,
+                                             
pluginContainer.getContainerRealm() );
         }
         catch ( ComponentConfigurationException e )
         {
@@ -630,144 +701,6 @@
         }
     }
 
-    /**
-     * @deprecated [JC] in favor of what?
-     */
-    private void getPluginConfigurationFromExpressions( Mojo plugin, 
MojoDescriptor goal,
-                                                        PlexusConfiguration 
mergedConfiguration,
-                                                        PlexusContainer 
pluginContainer, ExpressionEvaluator expressionEvaluator )
-        throws ExpressionEvaluationException, PluginConfigurationException
-    {
-        List parameters = goal.getParameters();
-
-        List invalidParameters = new ArrayList();
-
-        if ( parameters == null || parameters.isEmpty() )
-        {
-            return;
-        }
-
-        for ( int i = 0; i < parameters.size(); i++ )
-        {
-            Parameter parameter = (Parameter) parameters.get( i );
-
-            boolean editable = parameter.isEditable();
-
-            // the key for the configuration map we're building.
-            String key = parameter.getName();
-
-            // the key used to lookup the parameter in the config from the 
POM, etc.
-            String lookupKey = parameter.getAlias();
-
-            if ( StringUtils.isEmpty( lookupKey ) )
-            {
-                lookupKey = key;
-            }
-
-            String expression;
-
-            boolean foundInConfiguration = false;
-
-            if ( mergedConfiguration.getChild( lookupKey, false ) != null )
-            {
-                expression = mergedConfiguration.getChild( lookupKey, false 
).getValue( null );
-                foundInConfiguration = true;
-            }
-            else if ( mergedConfiguration.getChild( key, false ) != null )
-            {
-                expression = mergedConfiguration.getChild( key, false 
).getValue( null );
-                foundInConfiguration = true;
-            }
-            else
-            {
-                expression = parameter.getExpression();
-            }
-
-            if ( foundInConfiguration && expression != null && 
parameter.getDeprecated() != null )
-            {
-                PlexusConfiguration goalConfiguration = 
goal.getMojoConfiguration();
-                
-                // TODO: Go back to this when we get the container ready to 
configure mojos...
-//                PlexusConfiguration goalConfiguration = 
goal.getConfiguration();
-
-                if ( !expression.equals( goalConfiguration.getChild( 
lookupKey, false ).getValue( null ) ) &&
-                    !expression.equals( goalConfiguration.getChild( key, false 
).getValue( null ) ) )
-                {
-                    StringBuffer message = new StringBuffer().append( 
"DEPRECATED: " ).append( key );
-
-                    if ( !lookupKey.equals( key ) )
-                    {
-                        message.append( " (aliased to " ).append( lookupKey 
).append( ")" );
-                    }
-
-                    message.append( " is deprecated.\n\t" ).append( 
parameter.getDeprecated() );
-
-                    getLogger().warn( message.toString() );
-                }
-            }
-
-            Object value = expressionEvaluator.evaluate( expression );
-
-            getLogger().debug( "Evaluated mojo parameter expression: \'" + 
expression + "\' to: " + value +
-                               " for parameter: \'" + key + "\'" );
-
-            // TODO: remove. If there is a default value, required should have 
been removed by the descriptor generator
-            if ( value == null && goal.getComponentConfigurator() == null )
-            {
-                Object defaultValue;
-                try
-                {
-                    Field pluginField = findPluginField( plugin.getClass(), 
parameter.getName() );
-                    boolean accessible = pluginField.isAccessible();
-                    if ( !accessible )
-                    {
-                        pluginField.setAccessible( true );
-                    }
-                    defaultValue = pluginField.get( plugin );
-                    if ( !accessible )
-                    {
-                        pluginField.setAccessible( false );
-                    }
-                }
-                catch ( IllegalAccessException e )
-                {
-                    String message = "Error finding field for parameter '" + 
parameter.getName() + "'";
-                    throw new PluginConfigurationException( message, e );
-                }
-                catch ( NoSuchFieldException e )
-                {
-                    String message = "Error finding field for parameter '" + 
parameter.getName() + "'";
-                    throw new PluginConfigurationException( message, e );
-                }
-                if ( defaultValue != null )
-                {
-                    // TODO: allow expressions?
-                    value = defaultValue;
-                }
-            }
-
-            // 
----------------------------------------------------------------------
-            // We will perform a basic check here for parameters values that 
are
-            // required. Required parameters can't be null so we throw an
-            // Exception in the case where they are. We probably want some
-            // pluggable
-            // mechanism here but this will catch the most obvious of
-            // misconfigurations.
-            // 
----------------------------------------------------------------------
-
-            if ( value == null && parameter.isRequired() )
-            {
-                invalidParameters.add( parameter );
-            }
-
-        }
-
-        if ( !invalidParameters.isEmpty() )
-        {
-            throw new PluginParameterException( goal, invalidParameters );
-        }
-    }
-
     public static String createPluginParameterRequiredMessage( MojoDescriptor 
mojo, Parameter parameter,
                                                                String 
expression )
     {
@@ -825,28 +758,13 @@
     public void initialize()
     {
         // TODO: configure this from bootstrap or scan lib
-        // TODO: Note: maven-plugin just re-added until all plugins are 
switched over...
-        artifactFilter = new ExclusionSetFilter( new String[]
-        {
-            "bsh",
-            "classworlds",
-            "doxia-core",
-            "maven-artifact",
-            "maven-core",
-            "maven-model",
-            "maven-monitor",
-            "maven-plugin",
-            "maven-plugin-api",
-            "maven-plugin-descriptor",
-            "maven-project",
-            "maven-reporting-api",
-            "maven-script-beanshell",
-            "maven-settings",
-            "plexus-bsh-factory",
-            "plexus-container-default",
-            "plexus-utils",
-            "wagon-provider-api"
-        } );
+        artifactFilter = new ExclusionSetFilter( new String[]{"bsh", 
"classworlds", "doxia-core", "maven-artifact",
+                                                              "maven-core", 
"maven-model", "maven-monitor",
+                                                              
"maven-plugin-api", "maven-plugin-descriptor",
+                                                              "maven-project", 
"maven-reporting-api",
+                                                              
"maven-script-beanshell", "maven-settings",
+                                                              
"plexus-bsh-factory", "plexus-container-default",
+                                                              "plexus-utils", 
"wagon-provider-api"} );
     }
 
     // ----------------------------------------------------------------------
@@ -899,7 +817,8 @@
         }
         context.getProject().setPluginArtifacts( pluginArtifacts );
 
-        artifactResolver.resolve( context.getProject().getParentArtifact(), 
context.getRemoteRepositories(), context.getLocalRepository() );
+        artifactResolver.resolve( context.getProject().getParentArtifact(), 
context.getRemoteRepositories(),
+                                  context.getLocalRepository() );
     }
 
 }

Modified: 
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java
URL: 
http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java?rev=188647&r1=188646&r2=188647&view=diff
==============================================================================
--- 
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java
 (original)
+++ 
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java
 Mon Jun  6 18:13:52 2005
@@ -59,7 +59,6 @@
 
         if ( expr == null )
         {
-            // TODO: this should not have happened - previously there was a 
note about a fix to plexus Trygve was going to make - investigate
             return null;
         }
 

Modified: 
maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/Parameter.java
URL: 
http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/Parameter.java?rev=188647&r1=188646&r2=188647&view=diff
==============================================================================
--- 
maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/Parameter.java
 (original)
+++ 
maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/Parameter.java
 Mon Jun  6 18:13:52 2005
@@ -38,6 +38,8 @@
 
     private String deprecated;
 
+    private String defaultValue;
+
     // ----------------------------------------------------------------------
     //
     // ----------------------------------------------------------------------
@@ -132,8 +134,19 @@
         this.editable = editable;
     }
 
+    public void setDefaultValue( String defaultValue )
+    {
+        this.defaultValue = defaultValue;
+    }
+
+    public String getDefaultValue()
+    {
+        return defaultValue;
+    }
+
     public String toString()
     {
         return "Mojo parameter [name: \'" + getName() + "\'; alias: \'" + 
getAlias() + "\']";
     }
+
 }

Modified: 
maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptorBuilder.java
URL: 
http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptorBuilder.java?rev=188647&r1=188646&r2=188647&view=diff
==============================================================================
--- 
maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptorBuilder.java
 (original)
+++ 
maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptorBuilder.java
 Mon Jun  6 18:13:52 2005
@@ -210,8 +210,6 @@
 
             parameter.setDescription( d.getChild( "description" ).getValue() );
 
-            parameter.setExpression( d.getChild( "expression" ).getValue() );
-
             parameter.setDeprecated( d.getChild( "deprecated" ).getValue() );
 
             parameters.add( parameter );

Modified: 
maven/components/trunk/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java
URL: 
http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java?rev=188647&r1=188646&r2=188647&view=diff
==============================================================================
--- 
maven/components/trunk/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java
 (original)
+++ 
maven/components/trunk/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java
 Mon Jun  6 18:13:52 2005
@@ -30,10 +30,10 @@
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Map;
+import java.util.Set;
 
 /**
  * @todo add example usage tag that can be shown in the doco
@@ -69,11 +69,11 @@
             element( w, "version", pluginDescriptor.getVersion() );
 
             element( w, "goalPrefix", pluginDescriptor.getGoalPrefix() );
-            
+
             element( w, "isolatedRealm", "" + 
pluginDescriptor.isIsolatedRealm() );
 
             element( w, "inheritedByDefault", "" + 
pluginDescriptor.isInheritedByDefault() );
-            
+
             w.startElement( "mojos" );
 
             if ( pluginDescriptor.getMojos() != null )
@@ -233,10 +233,10 @@
         w.startElement( "parameters" );
 
         Collection requirements = new ArrayList();
-        
-        Map configuration = new HashMap();
-        
-        if( parameters != null )
+
+        Set configuration = new HashSet();
+
+        if ( parameters != null )
         {
             for ( int j = 0; j < parameters.size(); j++ )
             {
@@ -276,9 +276,10 @@
 
                     element( w, "description", parameter.getDescription() );
 
-                    if ( expression != null && expression.length() > 0 )
+                    if ( StringUtils.isNotEmpty( parameter.getDefaultValue() ) 
||
+                        StringUtils.isNotEmpty( parameter.getExpression() ) )
                     {
-                        configuration.put( parameter, expression );
+                        configuration.add( parameter );
                     }
 
                     w.endElement();
@@ -297,7 +298,7 @@
         {
             w.startElement( "configuration" );
 
-            for ( Iterator i = configuration.keySet().iterator(); i.hasNext(); 
)
+            for ( Iterator i = configuration.iterator(); i.hasNext(); )
             {
                 Parameter parameter = (Parameter) i.next();
 
@@ -309,7 +310,15 @@
                     w.addAttribute( "implementation", type );
                 }
 
-                w.writeText( (String) configuration.get( parameter ) );
+                if ( parameter.getDefaultValue() != null )
+                {
+                    w.addAttribute( "default-value", 
parameter.getDefaultValue() );
+                }
+
+                if ( parameter.getExpression() != null )
+                {
+                    w.writeText( parameter.getExpression() );
+                }
 
                 w.endElement();
             }

Modified: 
maven/components/trunk/maven-plugin-tools/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoDescriptorExtractor.java
URL: 
http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugin-tools/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoDescriptorExtractor.java?rev=188647&r1=188646&r2=188647&view=diff
==============================================================================
--- 
maven/components/trunk/maven-plugin-tools/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoDescriptorExtractor.java
 (original)
+++ 
maven/components/trunk/maven-plugin-tools/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoDescriptorExtractor.java
 Mon Jun  6 18:13:52 2005
@@ -56,6 +56,8 @@
 
     public static final String PARAMETER_EXPRESSION = "expression";
 
+    public static final String PARAMETER_DEFAULT_VALUE = "default-value";
+
     public static final String REQUIRED = "required";
 
     public static final String DEPRECATED = "deprecated";
@@ -292,6 +294,8 @@
             }
 
             pd.setExpression( parameter.getNamedParameter( 
PARAMETER_EXPRESSION ) );
+
+            pd.setDefaultValue( parameter.getNamedParameter( 
PARAMETER_DEFAULT_VALUE ) );
 
             mojoDescriptor.addParameter( pd );
         }

Modified: 
maven/components/trunk/maven-site/src/site/xdoc/developers/mojo-api-specification.xml
URL: 
http://svn.apache.org/viewcvs/maven/components/trunk/maven-site/src/site/xdoc/developers/mojo-api-specification.xml?rev=188647&r1=188646&r2=188647&view=diff
==============================================================================
--- 
maven/components/trunk/maven-site/src/site/xdoc/developers/mojo-api-specification.xml
 (original)
+++ 
maven/components/trunk/maven-site/src/site/xdoc/developers/mojo-api-specification.xml
 Mon Jun  6 18:13:52 2005
@@ -477,14 +477,15 @@
               tool support for browsing, etc. and for clarity.</i></td>
           </tr>
           <tr>
-            <td>expression</td>
-            <td>@parameter expression="${someExpression}"</td>
+            <td>configuration</td>
+            <td>@parameter expression="${someExpression}" 
default-value="value"</td>
             <td>No</td>
             <td>Specifies the expression used to calculate the value to be 
               injected into this parameter of the Mojo at buildtime. This is 
               commonly used to refer to specific elements in the POM, such as 
               ${project.build.resources}, which refers to the List of 
resources 
               meant to accompany the classes in the resulting jar file. 
+              The default value is used when the expression evaluates to 
<code>null</code>.
               <i>NOTE: If not specified, an expression of ${&lt;name&gt;} is 
               assumed, which can only be satisfied from POM configuration or 
               System properties. The use of '${' and '}' is required to 
delimit 
@@ -578,4 +579,4 @@
       </p>
     </section>
   </body>
-</document>
\ No newline at end of file
+</document>



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to