dion        2002/06/13 21:59:33

  Modified:    src/java/org/apache/maven/jelly JellyAntProject.java
  Log:
  Fixed ability to use an expression for the property name without the ${},
  e.g. maven.currentVersion
  
  Revision  Changes    Path
  1.6       +17 -4     
jakarta-turbine-maven/src/java/org/apache/maven/jelly/JellyAntProject.java
  
  Index: JellyAntProject.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/jelly/JellyAntProject.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- JellyAntProject.java      12 Jun 2002 16:38:56 -0000      1.5
  +++ JellyAntProject.java      14 Jun 2002 04:59:33 -0000      1.6
  @@ -118,25 +118,38 @@
           String propertyValue = null;
           try
           {
  -            // FIXME: Add caching of expressions here
  +            // get the variable
               Object value = getContext().getVariable(name);
  +            log.debug("Context (" + name + "="+ value + ")");
               if (value instanceof String)
               {
  +                // a string could be an expression
                   log.debug(" jelly variable " + name + "=" + value);
                   String valueString = (String) value;
                   if (valueString.indexOf("${") != -1)
                   {
                       value = evaluateExpression(valueString);
  +                    log.debug(" evaluating expression gives: " + value);
                   }
               }
  -            log.debug(" evaluating expression gives: " + value);
  +            
               if ( value != null )
               {
                   propertyValue = value.toString();
               }
               else
               {
  -                propertyValue = evaluateExpression(name).toString();
  +                // try to evaluate name as an expression
  +                Object propertyObject = evaluateExpression("${" + name + "}");
  +                if (propertyObject == null)
  +                {
  +                    propertyValue = name;
  +                } 
  +                else
  +                {
  +                    propertyValue = propertyObject.toString();
  +                }
  +                log.debug(" evaluating name gives: " + propertyValue);
               }
              
           }
  
  
  

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

Reply via email to