brett 2005/04/14 21:52:31
Modified: maven-plugins/maven-war-plugin/src/main/java/org/apache/maven/plugin/war WarMojo.java maven-core/src/main/java/org/apache/maven/plugin DefaultPluginManager.java PluginParameterExpressionEvaluator.java maven-core/src/main/resources/META-INF/plexus components.xml maven-core/src/test/java/org/apache/maven/plugin PluginParameterExpressionEvaluatorTest.java maven-core pom.xml maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator PluginDescriptorGenerator.java maven-plugin-tools/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/generator PluginDescriptorGeneratorTest.java maven-plugins/maven-ejb-plugin/src/main/java/org/apache/maven/plugin/ejb EjbMojo.java maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor MojoDescriptor.java PluginDescriptorBuilder.java maven-plugins/maven-surefire-plugin/src/main/java/org/apache/maven/test SurefirePlugin.java Log: utilise the container for populating all mojo configuration, including expressions Revision Changes Path 1.14 +6 -17 maven-components/maven-plugins/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/WarMojo.java Index: WarMojo.java =================================================================== RCS file: /home/cvs/maven-components/maven-plugins/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/WarMojo.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- WarMojo.java 30 Mar 2005 08:22:24 -0000 1.13 +++ WarMojo.java 15 Apr 2005 04:52:30 -0000 1.14 @@ -54,21 +54,20 @@ * type="String" * required="true" * validator="" - * expression="#maven.war.src" - * default="#basedir/src/main/webapp" + * expression="#basedir/src/main/webapp" * description="" * @parameter name="warSourceIncludes" * type="String" * required="false" * validator="" - * expression="#maven.war.src.includes" + * expression="" * default="**" * description="" * @parameter name="warSourceExcludes" * type="String" * required="false" * validator="" - * expression="#maven.war.src.excludes" + * expression="" * description="" * @parameter name="webXml" * type="String" @@ -80,14 +79,13 @@ * type="String" * required="true" * validator="" - * expression="#maven.war.webapp.dir" - * default="#project.build.directory/#project.build.finalName" + * expression="#project.build.directory/#project.build.finalName" * description="" * @parameter name="mode" * type="String" * required="true" * validator="" - * expression="#maven.war.mode" + * expression="" * default="war" * description="" * @parameter name="classesDirectory" @@ -100,13 +98,6 @@ * type="String" * required="true" * validator="" - * expression="#maven.war.build.dir" - * default="#project.build.directory" - * description="" - * @parameter name="basedir" - * type="String" - * required="true" - * validator="" * expression="#project.build.directory" * description="" * @parameter name="project" @@ -129,8 +120,6 @@ private MavenProject project; - private String basedir; - /** * @todo File */ 1.80 +122 -87 maven-components/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java Index: DefaultPluginManager.java =================================================================== RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java,v retrieving revision 1.79 retrieving revision 1.80 diff -u -r1.79 -r1.80 --- DefaultPluginManager.java 14 Apr 2005 03:27:35 -0000 1.79 +++ DefaultPluginManager.java 15 Apr 2005 04:52:30 -0000 1.80 @@ -42,12 +42,13 @@ import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.configurator.ComponentConfigurationException; import org.codehaus.plexus.component.configurator.ComponentConfigurator; +import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; +import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; import org.codehaus.plexus.component.discovery.ComponentDiscoveryEvent; import org.codehaus.plexus.component.discovery.ComponentDiscoveryListener; import org.codehaus.plexus.component.repository.ComponentSetDescriptor; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.configuration.PlexusConfiguration; -import org.codehaus.plexus.configuration.PlexusConfigurationException; import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration; import org.codehaus.plexus.context.Context; import org.codehaus.plexus.context.ContextException; @@ -392,19 +393,31 @@ configuration = new XmlPlexusConfiguration( dom ); } - if ( newMojoTechnique ) - { - Map map = getPluginConfigurationFromExpressions( mojoDescriptor, configuration, session ); + configuration = mergeConfiguration( configuration, mojoDescriptor.getConfiguration() ); - populatePluginFields( plugin, configuration, map ); - } - else + PluginParameterExpressionEvaluator expressionEvaluator = new PluginParameterExpressionEvaluator( session ); + try { - getLogger().warn( "WARNING: The mojo " + mojoDescriptor.getId() + " is using the OLD API" ); + if ( newMojoTechnique ) + { + Map map = getPluginConfigurationFromExpressions( mojoDescriptor, configuration, session, + expressionEvaluator ); + + populatePluginFields( plugin, configuration, map, expressionEvaluator ); + } + else + { + getLogger().warn( "WARNING: The mojo " + mojoDescriptor.getId() + " is using the OLD API" ); - Map map = getPluginConfigurationFromExpressions( mojoDescriptor, configuration, session ); + Map map = getPluginConfigurationFromExpressions( mojoDescriptor, configuration, session, + expressionEvaluator ); - request = createPluginRequest( configuration, map ); + request = createPluginRequest( configuration, map ); + } + } + catch ( ExpressionEvaluationException e ) + { + throw new PluginExecutionException( "Unable to configure plugin", e ); } // !! This is ripe for refactoring to an aspect. @@ -436,7 +449,8 @@ } catch ( PluginConfigurationException e ) { - throw new PluginExecutionException( "Error configuring plugin for execution.", e ); + String msg = "Error configuring plugin for execution of ."; + throw new PluginExecutionException( msg, e ); } catch ( ComponentLookupException e ) { @@ -446,8 +460,6 @@ { try { - releaseComponents( mojoDescriptor, request ); - container.release( plugin ); } catch ( Exception e ) @@ -458,6 +470,48 @@ } } + private PlexusConfiguration mergeConfiguration( PlexusConfiguration dominant, PlexusConfiguration configuration ) + { + // TODO: share with mergeXpp3Dom + PlexusConfiguration[] children = configuration.getChildren(); + for ( int i = 0; i < children.length; i++ ) + { + PlexusConfiguration child = children[i]; + PlexusConfiguration childDom = (XmlPlexusConfiguration) dominant.getChild( child.getName(), false ); + if ( childDom != null ) + { + mergeConfiguration( childDom, child ); + } + else + { + dominant.addChild( copyConfiguration( child ) ); + } + } + return dominant; + } + + public static PlexusConfiguration copyConfiguration( PlexusConfiguration src ) + { + // TODO: shouldn't be necessary + XmlPlexusConfiguration dom = new XmlPlexusConfiguration( src.getName() ); + dom.setValue( src.getValue( null ) ); + + String[] attributeNames = src.getAttributeNames(); + for ( int i = 0; i < attributeNames.length; i++ ) + { + String attributeName = attributeNames[i]; + dom.setAttribute( attributeName, src.getAttribute( attributeName, null ) ); + } + + PlexusConfiguration[] children = src.getChildren(); + for ( int i = 0; i < children.length; i++ ) + { + dom.addChild( copyConfiguration( children[i] ) ); + } + + return dom; + } + /** * @deprecated */ @@ -482,61 +536,36 @@ return newMojoTechnique; } - // TODO: don't throw Exception - private void releaseComponents( MojoDescriptor goal, PluginExecutionRequest request ) - throws Exception - { - if ( request != null && request.getParameters() != null ) - { - for ( Iterator iterator = goal.getParameters().iterator(); iterator.hasNext(); ) - { - Parameter parameter = (Parameter) iterator.next(); - - String key = parameter.getName(); - - String expression = parameter.getExpression(); - - if ( expression != null && expression.startsWith( "#component" ) ) - { - Object component = request.getParameter( key ); - - container.release( component ); - } - } - } - } - // ---------------------------------------------------------------------- // Mojo Parameter Handling // ---------------------------------------------------------------------- + /** + * @param configuration + * @param map + * @return + * @deprecated + */ private static PluginExecutionRequest createPluginRequest( PlexusConfiguration configuration, Map map ) - throws PluginConfigurationException { - try + Map parameters = new HashMap(); + PlexusConfiguration[] children = configuration.getChildren(); + for ( int i = 0; i < children.length; i++ ) { - Map parameters = new HashMap(); - PlexusConfiguration[] children = configuration.getChildren(); - for ( int i = 0; i < children.length; i++ ) - { - PlexusConfiguration child = children[i]; - parameters.put( child.getName(), child.getValue() ); - } - map = CollectionUtils.mergeMaps( map, parameters ); - } - catch ( PlexusConfigurationException e ) - { - throw new PluginConfigurationException( "Unable to construct map from plugin configuration", e ); + PlexusConfiguration child = children[i]; + parameters.put( child.getName(), child.getValue( null ) ); } + map = CollectionUtils.mergeMaps( map, parameters ); return new PluginExecutionRequest( map ); } - private void populatePluginFields( Plugin plugin, PlexusConfiguration configuration, Map map ) + private void populatePluginFields( Plugin plugin, PlexusConfiguration configuration, Map map, + ExpressionEvaluator expressionEvaluator ) throws PluginConfigurationException { try { - configurator.configureComponent( plugin, configuration ); + configurator.configureComponent( plugin, configuration, expressionEvaluator ); } catch ( ComponentConfigurationException e ) { @@ -544,7 +573,7 @@ } // Configuration does not store objects, so the non-String fields are configured here - // TODO: we don't have converters, so "primitives" that -are- strings are not configured properly (eg String -> File from an expression) + // TODO: remove - this is for plugins built with alpha-1 for ( Iterator i = map.keySet().iterator(); i.hasNext(); ) { String key = (String) i.next(); @@ -602,9 +631,12 @@ } } + /** + * @deprecated + */ private Map getPluginConfigurationFromExpressions( MojoDescriptor goal, PlexusConfiguration configuration, - MavenSession session ) - throws PluginConfigurationException + MavenSession session, ExpressionEvaluator expressionEvaluator ) + throws ExpressionEvaluationException, PluginConfigurationException { List parameters = goal.getParameters(); @@ -616,49 +648,52 @@ String key = parameter.getName(); + String expression; if ( configuration.getChild( key, false ) == null ) { - String expression = parameter.getExpression(); + expression = parameter.getExpression(); + } + else + { + expression = configuration.getChild( key, false ).getValue( null ); + } - Object value = PluginParameterExpressionEvaluator.evaluate( expression, session ); + Object value = expressionEvaluator.evaluate( expression ); - getLogger().debug( "Evaluated mojo parameter expression: \'" + expression + "\' to: " + value ); + getLogger().debug( "Evaluated mojo parameter expression: \'" + expression + "\' to: " + value ); - if ( value == null ) + if ( value == null ) + { + if ( parameter.getDefaultValue() != null ) { - if ( parameter.getDefaultValue() != null ) - { - value = PluginParameterExpressionEvaluator.evaluate( parameter.getDefaultValue(), session ); - } + value = expressionEvaluator.evaluate( parameter.getDefaultValue() ); } + } - // ---------------------------------------------------------------------- - // 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. - // ---------------------------------------------------------------------- + // ---------------------------------------------------------------------- + // 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() ) - { - throw new PluginConfigurationException( createPluginParameterRequiredMessage( goal, parameter ) ); - } - - String type = parameter.getType(); + if ( value == null && parameter.isRequired() ) + { + throw new PluginConfigurationException( createPluginParameterRequiredMessage( goal, parameter ) ); + } - // TODO: Not sure how we might find files that are nested in other objects... perhaps - // we add a "needs translation" to the mojo so such types can be translated (implementing some interface) and - // address their own file objects - if ( type != null && ( type.equals( "File" ) || type.equals( "java.io.File" ) ) ) - { - value = pathTranslator.alignToBaseDirectory( (String) value, - session.getProject().getFile().getParentFile() ); - } + String type = parameter.getType(); - map.put( key, value ); + // TODO: remove - done via plexus configuration, but need to inject the base directory into it + if ( type != null && ( type.equals( "File" ) || type.equals( "java.io.File" ) ) ) + { + value = pathTranslator.alignToBaseDirectory( (String) value, + session.getProject().getFile().getParentFile() ); } + + map.put( key, value ); } return map; } 1.14 +36 -30 maven-components/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java Index: PluginParameterExpressionEvaluator.java =================================================================== RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- PluginParameterExpressionEvaluator.java 14 Apr 2005 03:27:35 -0000 1.13 +++ PluginParameterExpressionEvaluator.java 15 Apr 2005 04:52:30 -0000 1.14 @@ -1,35 +1,44 @@ package org.apache.maven.plugin; -/* ==================================================================== - * Copyright 2001-2004 The Apache Software Foundation. +/* + * Copyright 2001-2005 The Apache Software Foundation. * - * Licensed 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 + * Licensed 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 + * 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. - * ==================================================================== + * 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.execution.MavenSession; -import org.apache.maven.project.MavenProject; import org.apache.maven.util.introspection.ReflectionValueExtractor; +import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; +import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; /** * @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a> * @version $Id$ + * @todo belong in MavenSession, so it only gets created once? */ public class PluginParameterExpressionEvaluator + implements ExpressionEvaluator { - public static Object evaluate( String expression, MavenSession context ) - throws PluginConfigurationException + private final MavenSession context; + + public PluginParameterExpressionEvaluator( MavenSession context ) + { + this.context = context; + } + + public Object evaluate( String expression ) + throws ExpressionEvaluationException { Object value = null; @@ -51,7 +60,7 @@ } catch ( ComponentLookupException e ) { - throw new PluginConfigurationException( "Cannot lookup component: " + role + ".", e ); + throw new ExpressionEvaluationException( "Cannot lookup component: " + role + ".", e ); } } else if ( expression.equals( "#localRepository" ) ) @@ -61,7 +70,7 @@ else if ( expression.equals( "#maven.final.name" ) ) { // TODO: remove this alias - value = context.getProject().getModel().getBuild().getFinalName(); + value = context.getProject().getBuild().getFinalName(); } else if ( expression.equals( "#project" ) ) { @@ -75,18 +84,20 @@ if ( pathSeparator > 0 ) { - value = getValue( expression.substring( 1, pathSeparator ), context.getProject() ) + - expression.substring( pathSeparator ); + String pathExpression = expression.substring( 1, pathSeparator ); + value = ReflectionValueExtractor.evaluate( pathExpression, context.getProject() ); + value = value + expression.substring( pathSeparator ); } else { - value = getValue( expression.substring( 1 ), context.getProject() ); + value = ReflectionValueExtractor.evaluate( expression.substring( 1 ), context.getProject() ); } } catch ( Exception e ) { - throw new PluginConfigurationException( "Error evaluating plugin parameter expression: " + expression, - e ); + // TODO: don't catch exception + throw new ExpressionEvaluationException( "Error evaluating plugin parameter expression: " + expression, + e ); } } else if ( "#settings".equals( expression ) ) @@ -128,12 +139,12 @@ if ( sharpSeparator > 0 ) { - val = val.substring( 0, sharpSeparator ) + evaluate( val.substring( sharpSeparator ), context ); + val = val.substring( 0, sharpSeparator ) + evaluate( val.substring( sharpSeparator ) ); value = val; } else if ( sharpSeparator > 0 ) { - value = evaluate( val.substring( sharpSeparator ), context ); + value = evaluate( val.substring( sharpSeparator ) ); } } @@ -154,10 +165,5 @@ return value; } - private static Object getValue( String expression, MavenProject project ) - throws Exception - { - return ReflectionValueExtractor.evaluate( expression, project ); - } } 1.27 +6 -0 maven-components/maven-core/src/main/resources/META-INF/plexus/components.xml Index: components.xml =================================================================== RCS file: /home/cvs/maven-components/maven-core/src/main/resources/META-INF/plexus/components.xml,v retrieving revision 1.26 retrieving revision 1.27 diff -u -r1.26 -r1.27 --- components.xml 29 Mar 2005 17:06:30 -0000 1.26 +++ components.xml 15 Apr 2005 04:52:30 -0000 1.27 @@ -232,6 +232,12 @@ <!-- END SNIPPET: lifecycle --> </configuration> </component> + + <component> + <role>org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator</role> + <implementation>org.apache.maven.</implementation> + </component> + <!-- ********************* FIXME ******************************************* | I realize this is duplicated but allows the project builder to work by itself --> 1.10 +15 -7 maven-components/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorTest.java Index: PluginParameterExpressionEvaluatorTest.java =================================================================== RCS file: /home/cvs/maven-components/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorTest.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- PluginParameterExpressionEvaluatorTest.java 21 Mar 2005 08:18:33 -0000 1.9 +++ PluginParameterExpressionEvaluatorTest.java 15 Apr 2005 04:52:30 -0000 1.10 @@ -11,6 +11,7 @@ import org.apache.maven.project.MavenProject; import org.apache.maven.settings.MavenSettings; import org.codehaus.plexus.PlexusContainer; +import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; import java.io.File; import java.util.Collections; @@ -25,7 +26,8 @@ { private MavenProject project; - protected void setUp() throws Exception + protected void setUp() + throws Exception { super.setUp(); @@ -34,7 +36,8 @@ project = getProject( f ); } - public void testValueExtractionWithAPomValueContainingAPath() throws Exception + public void testValueExtractionWithAPomValueContainingAPath() + throws Exception { String expected = getTestFile( "target/test-classes/target/classes" ).getCanonicalPath(); @@ -59,7 +62,8 @@ new DefaultEventDispatcher(), new DefaultLog( container.getLogger() ), Collections.EMPTY_LIST ); - Object value = PluginParameterExpressionEvaluator.evaluate( "#project.build.directory/classes", session ); + ExpressionEvaluator expressionEvaluator = new PluginParameterExpressionEvaluator( session ); + Object value = expressionEvaluator.evaluate( "#project.build.directory/classes" ); String actual = new File( value.toString() ).getCanonicalPath(); @@ -69,7 +73,8 @@ assertEquals( expected, actual ); } - public void testParameterThatIsAComponent() throws Exception + public void testParameterThatIsAComponent() + throws Exception { String role = "#component.org.apache.maven.project.MavenProjectBuilder"; @@ -85,12 +90,14 @@ new DefaultEventDispatcher(), new DefaultLog( container.getLogger() ), Collections.EMPTY_LIST ); - Object value = PluginParameterExpressionEvaluator.evaluate( role, session ); + ExpressionEvaluator expressionEvaluator = new PluginParameterExpressionEvaluator( session ); + Object value = expressionEvaluator.evaluate( role ); assertNotNull( value ); } - public void testLocalRepositoryExtraction() throws Exception + public void testLocalRepositoryExtraction() + throws Exception { ArtifactRepositoryLayout repoLayout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "legacy" ); @@ -104,7 +111,8 @@ new DefaultEventDispatcher(), new DefaultLog( container.getLogger() ), Collections.EMPTY_LIST ); - Object value = PluginParameterExpressionEvaluator.evaluate( "#localRepository", session ); + ExpressionEvaluator expressionEvaluator = new PluginParameterExpressionEvaluator( session ); + Object value = expressionEvaluator.evaluate( "#localRepository" ); assertEquals( "local", ( (ArtifactRepository) value ).getId() ); } 1.34 +1 -1 maven-components/maven-core/pom.xml Index: pom.xml =================================================================== RCS file: /home/cvs/maven-components/maven-core/pom.xml,v retrieving revision 1.33 retrieving revision 1.34 diff -u -r1.33 -r1.34 --- pom.xml 13 Apr 2005 05:11:48 -0000 1.33 +++ pom.xml 15 Apr 2005 04:52:30 -0000 1.34 @@ -62,7 +62,7 @@ <dependency> <groupId>plexus</groupId> <artifactId>plexus-container-default</artifactId> - <version>1.0-alpha-2</version> + <version>1.0-alpha-3-SNAPSHOT</version> </dependency> <dependency> <groupId>org.apache.maven.wagon</groupId> 1.9 +71 -2 maven-components/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java Index: PluginDescriptorGenerator.java =================================================================== RCS file: /home/cvs/maven-components/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- PluginDescriptorGenerator.java 14 Apr 2005 03:27:35 -0000 1.8 +++ PluginDescriptorGenerator.java 15 Apr 2005 04:52:30 -0000 1.9 @@ -27,8 +27,10 @@ import java.io.FileWriter; import java.util.ArrayList; import java.util.Collection; +import java.util.HashMap; import java.util.Iterator; import java.util.List; +import java.util.Map; import java.util.Set; /** @@ -162,6 +164,7 @@ w.startElement( "parameters" ); Collection requirements = new ArrayList(); + Map configuration = new HashMap( parameters.size() ); for ( int j = 0; j < parameters.size(); j++ ) { Parameter parameter = (Parameter) parameters.get( j ); @@ -174,6 +177,7 @@ element( w, "validator", parameter.getValidator() ); + String value = null; if ( parameter.getExpression().startsWith( "#component" ) ) { requirements.add( parameter ); @@ -182,12 +186,20 @@ { element( w, "required", Boolean.toString( parameter.isRequired() ) ); - element( w, "expression", parameter.getExpression() ); + value = parameter.getExpression(); } element( w, "description", parameter.getDescription() ); - element( w, "default", parameter.getDefaultValue() ); + if ( value == null || value.length() == 0 ) + { + value = parameter.getDefaultValue(); + } + + if ( value != null && value.length() > 0 ) + { + configuration.put( parameter, value ); + } w.endElement(); } @@ -195,6 +207,34 @@ w.endElement(); // ---------------------------------------------------------------------- + // Coinfiguration + // ---------------------------------------------------------------------- + + if ( !configuration.isEmpty() ) + { + w.startElement( "configuration" ); + + for ( Iterator i = configuration.keySet().iterator(); i.hasNext(); ) + { + Parameter parameter = (Parameter) i.next(); + + w.startElement( parameter.getName() ); + + String type = convertType( parameter.getType() ); + if ( type != null ) + { + w.addAttribute( "implementation", type ); + } + + w.writeText( (String) configuration.get( parameter ) ); + + w.endElement(); + } + + w.endElement(); + } + + // ---------------------------------------------------------------------- // Requirements // ---------------------------------------------------------------------- @@ -225,6 +265,35 @@ w.endElement(); } + /** + * @param type + * @return + * @deprecated - should force proper class specification + */ + private static String convertType( String type ) + { + if ( "String".equals( type ) ) + { + return "java.lang.String"; + } + else if ( "File".equals( type ) ) + { + return "java.io.File"; + } + else if ( "List".equals( type ) ) + { + return "java.util.List"; + } + else if ( "".equals( type ) ) + { + return null; + } + else + { + return type; + } + } + public void element( XMLWriter w, String name, String value ) { w.startElement( name ); 1.4 +0 -2 maven-components/maven-plugin-tools/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGeneratorTest.java Index: PluginDescriptorGeneratorTest.java =================================================================== RCS file: /home/cvs/maven-components/maven-plugin-tools/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGeneratorTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- PluginDescriptorGeneratorTest.java 5 Apr 2005 08:17:28 -0000 1.3 +++ PluginDescriptorGeneratorTest.java 15 Apr 2005 04:52:30 -0000 1.4 @@ -106,8 +106,6 @@ private void checkParameter( Parameter parameter ) { - assertEquals( "value", parameter.getDefaultValue() ); - assertEquals( "#project.build.directory", parameter.getExpression() ); assertEquals( "dir", parameter.getName() ); assertEquals( "String", parameter.getType() ); assertTrue( parameter.isRequired() ); 1.6 +2 -2 maven-components/maven-plugins/maven-ejb-plugin/src/main/java/org/apache/maven/plugin/ejb/EjbMojo.java Index: EjbMojo.java =================================================================== RCS file: /home/cvs/maven-components/maven-plugins/maven-ejb-plugin/src/main/java/org/apache/maven/plugin/ejb/EjbMojo.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- EjbMojo.java 30 Mar 2005 08:14:52 -0000 1.5 +++ EjbMojo.java 15 Apr 2005 04:52:30 -0000 1.6 @@ -46,7 +46,7 @@ * type="String" * required="false" * validator="" - * expression="#maven.ejb.generateclient" + * expression="" * default="false" * description="" * @parameter name="outputDirectory" 1.3 +13 -0 maven-components/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/MojoDescriptor.java Index: MojoDescriptor.java =================================================================== RCS file: /home/cvs/maven-components/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/MojoDescriptor.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- MojoDescriptor.java 14 Apr 2005 03:27:35 -0000 1.2 +++ MojoDescriptor.java 15 Apr 2005 04:52:31 -0000 1.3 @@ -17,6 +17,7 @@ */ import org.codehaus.plexus.component.repository.ComponentRequirement; +import org.codehaus.plexus.configuration.PlexusConfiguration; import java.util.ArrayList; import java.util.HashMap; @@ -68,6 +69,8 @@ private String language = DEFAULT_LANGUAGE; + private PlexusConfiguration configuration; + // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- @@ -230,4 +233,14 @@ { getRequirements().add( cr ); } + + public void setConfiguration( PlexusConfiguration configuration ) + { + this.configuration = configuration; + } + + public PlexusConfiguration getConfiguration() + { + return configuration; + } } 1.4 +9 -1 maven-components/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptorBuilder.java Index: PluginDescriptorBuilder.java =================================================================== RCS file: /home/cvs/maven-components/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptorBuilder.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- PluginDescriptorBuilder.java 14 Apr 2005 03:27:35 -0000 1.3 +++ PluginDescriptorBuilder.java 15 Apr 2005 04:52:31 -0000 1.4 @@ -147,8 +147,10 @@ parameter.setDescription( d.getChild( "description" ).getValue() ); + // TODO: remove parameter.setExpression( d.getChild( "expression" ).getValue() ); + // TODO: remove parameter.setDefaultValue( d.getChild( "default" ).getValue() ); parameters.add( parameter ); @@ -159,6 +161,12 @@ // TODO: this should not need to be handed off... // ---------------------------------------------------------------------- + // Configuration + // ---------------------------------------------------------------------- + + mojo.setConfiguration( c.getChild( "configuration" ) ); + + // ---------------------------------------------------------------------- // Requirements // ---------------------------------------------------------------------- 1.23 +10 -5 maven-components/maven-plugins/maven-surefire-plugin/src/main/java/org/apache/maven/test/SurefirePlugin.java Index: SurefirePlugin.java =================================================================== RCS file: /home/cvs/maven-components/maven-plugins/maven-surefire-plugin/src/main/java/org/apache/maven/test/SurefirePlugin.java,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- SurefirePlugin.java 4 Apr 2005 03:48:01 -0000 1.22 +++ SurefirePlugin.java 15 Apr 2005 04:52:31 -0000 1.23 @@ -53,19 +53,19 @@ * expression="#project.build.testOutputDirectory" * description="" * @parameter name="includes" - * type="String" + * type="java.util.List" * required="false" * validator="" * description="" * expression="" * @parameter name="excludes" - * type="String" + * type="java.util.List" * required="false" * validator="" * description="" * expression="" * @parameter name="classpathElements" - * type="String[]" + * type="java.util.List" * required="true" * validator="" * expression="#project.testClasspathElements" @@ -82,7 +82,12 @@ * validator="" * expression="#test" * description="Specify this parameter if you want to use the test regex notation to select tests to run." - * @parameter name="localRepository" type="ArtifactRepository" required="true" validator="" expression="#localRepository" description="" + * @parameter name="localRepository" + * type="org.apache.maven.artifact.repository.ArtifactRepository" + * required="true" + * validator="" + * expression="#localRepository" + * description="" * @todo make version of junit and surefire configurable * @todo make report to be produced configurable */