maven-m2-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject cvs commit: maven-components/maven-core/src/test/java/org/apache/maven/plugin PluginParameterExpressionEvaluatorTest.java
Date Fri, 15 Apr 2005 05:29:00 GMT
brett       2005/04/14 22:29:00

  Modified:    maven-core/src/main/java/org/apache/maven/plugin
                        DefaultPluginManager.java
                        PluginParameterExpressionEvaluator.java
               maven-core/src/test/java/org/apache/maven/plugin
                        PluginParameterExpressionEvaluatorTest.java
  Log:
  allow the expression evaluator to align strings to a base directory, for the purposes of
the file converter
  
  Revision  Changes    Path
  1.81      +7 -10     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.80
  retrieving revision 1.81
  diff -u -r1.80 -r1.81
  --- DefaultPluginManager.java	15 Apr 2005 04:52:30 -0000	1.80
  +++ DefaultPluginManager.java	15 Apr 2005 05:29:00 -0000	1.81
  @@ -395,7 +395,7 @@
   
               configuration = mergeConfiguration( configuration, mojoDescriptor.getConfiguration()
);
   
  -            PluginParameterExpressionEvaluator expressionEvaluator = new PluginParameterExpressionEvaluator(
session );
  +            ExpressionEvaluator expressionEvaluator = new PluginParameterExpressionEvaluator(
session, pathTranslator );
               try
               {
                   if ( newMojoTechnique )
  @@ -577,6 +577,12 @@
           for ( Iterator i = map.keySet().iterator(); i.hasNext(); )
           {
               String key = (String) i.next();
  +
  +            if ( configuration.getChild( key ) != null )
  +            {
  +                continue;
  +            }
  +
               Object value = map.get( key );
   
               if ( value != null )
  @@ -684,15 +690,6 @@
                   throw new PluginConfigurationException( createPluginParameterRequiredMessage(
goal, parameter ) );
               }
   
  -            String type = parameter.getType();
  -
  -            // 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.15      +14 -2     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.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- PluginParameterExpressionEvaluator.java	15 Apr 2005 04:52:30 -0000	1.14
  +++ PluginParameterExpressionEvaluator.java	15 Apr 2005 05:29:00 -0000	1.15
  @@ -17,11 +17,14 @@
    */
   
   import org.apache.maven.execution.MavenSession;
  +import org.apache.maven.project.path.PathTranslator;
   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;
   
  +import java.io.File;
  +
   /**
    * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
    * @version $Id$
  @@ -30,11 +33,14 @@
   public class PluginParameterExpressionEvaluator
       implements ExpressionEvaluator
   {
  +    private final PathTranslator pathTranslator;
  +
       private final MavenSession context;
   
  -    public PluginParameterExpressionEvaluator( MavenSession context )
  +    public PluginParameterExpressionEvaluator( MavenSession context, PathTranslator pathTranslator
)
       {
           this.context = context;
  +        this.pathTranslator = pathTranslator;
       }
   
       public Object evaluate( String expression )
  @@ -165,5 +171,11 @@
           return value;
       }
   
  +    public File alignToBaseDirectory( File file )
  +    {
  +        File basedir = context.getProject().getFile().getParentFile();
  +        return new File( pathTranslator.alignToBaseDirectory( file.getPath(), basedir )
);
  +    }
  +
   }
   
  
  
  
  1.11      +3 -3      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.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- PluginParameterExpressionEvaluatorTest.java	15 Apr 2005 04:52:30 -0000	1.10
  +++ PluginParameterExpressionEvaluatorTest.java	15 Apr 2005 05:29:00 -0000	1.11
  @@ -62,7 +62,7 @@
                                                    new DefaultEventDispatcher(), new DefaultLog(
container.getLogger() ),
                                                    Collections.EMPTY_LIST );
   
  -        ExpressionEvaluator expressionEvaluator = new PluginParameterExpressionEvaluator(
session );
  +        ExpressionEvaluator expressionEvaluator = new PluginParameterExpressionEvaluator(
session, null );
           Object value = expressionEvaluator.evaluate( "#project.build.directory/classes"
);
   
           String actual = new File( value.toString() ).getCanonicalPath();
  @@ -90,7 +90,7 @@
                                                    new DefaultEventDispatcher(), new DefaultLog(
container.getLogger() ),
                                                    Collections.EMPTY_LIST );
   
  -        ExpressionEvaluator expressionEvaluator = new PluginParameterExpressionEvaluator(
session );
  +        ExpressionEvaluator expressionEvaluator = new PluginParameterExpressionEvaluator(
session, null );
           Object value = expressionEvaluator.evaluate( role );
   
           assertNotNull( value );
  @@ -111,7 +111,7 @@
                                                    new DefaultEventDispatcher(), new DefaultLog(
container.getLogger() ),
                                                    Collections.EMPTY_LIST );
   
  -        ExpressionEvaluator expressionEvaluator = new PluginParameterExpressionEvaluator(
session );
  +        ExpressionEvaluator expressionEvaluator = new PluginParameterExpressionEvaluator(
session, null );
           Object value = expressionEvaluator.evaluate( "#localRepository" );
   
           assertEquals( "local", ( (ArtifactRepository) value ).getId() );
  
  
  

Mime
View raw message