You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by "Henning P. Schmiedehausen" <hp...@intermeta.de> on 2004/05/09 19:32:02 UTC

[BUG][PATCH] maven-1.0-rc3-dev breaks Torque Plugin

Hi,

due to some change in jelly, maven or somewhere else between the
1.0-rc2 and the current 1.0 HEAD version (which identifies itself as
1.0-rc3-dev), the Torque Plugin, which relies on using the Ant Task
interface no longer works.

The reason for this is in the JellyPropsHandler class which interfaces
the JellyContext onto ant Properties. For this, it calls toString() on
values in the JellyContext. 

Up to some points, expression elements in this context returned its
evaluated value. At some point this seem to have changed and the
elements now return

classname@location[value=myvalue]

so code that uses these elements starts to use really scary stuff. 

I wasn't able to pinpoint the exact location where the problem crept
in, because I simply didn't want to try to understand the "inner
workings" of the maven code. It might have to do with the changes in
the MavenExpressionFactory; it could als simply be because a newer
jelly version is used.

However, I needed this patch to JellyPropsHandler and I'm not sure how
this code could ever work without this patch. With this patch, the
torque plugin works again.

Please apply for rc3.

	Regards
		Henning

--- cut ---
Index: src/java/org/apache/maven/jelly/JellyPropsHandler.java
===================================================================
RCS file: /home/cvspublic/maven/src/java/org/apache/maven/jelly/JellyPropsHandler.java,v
retrieving revision 1.7.4.3
diff -u -r1.7.4.3 JellyPropsHandler.java
--- src/java/org/apache/maven/jelly/JellyPropsHandler.java	28 Mar 2004 21:27:27 -0000	1.7.4.3
+++ src/java/org/apache/maven/jelly/JellyPropsHandler.java	9 May 2004 17:31:03 -0000
@@ -19,6 +19,9 @@
 
 import org.apache.commons.grant.DefaultPropsHandler;
 import org.apache.commons.jelly.JellyContext;
+import org.apache.commons.jelly.expression.Expression;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 import java.util.Hashtable;
 import java.util.Iterator;
@@ -33,6 +36,9 @@
 public class JellyPropsHandler
     extends DefaultPropsHandler
 {
+    /** Logger */
+    private static final Log log = LogFactory.getLog( JellyPropsHandler.class );
+
     /** The JellyContext. */
     private JellyContext context;
 
@@ -65,6 +71,7 @@
      */
     public String getProperty( String name )
     {
+        log.debug("getProperty(" + name + ")");
         if ( name == null )
         {
             return null;
@@ -78,7 +85,18 @@
         }
         else
         {
-            return value.toString();
+            if (log.isDebugEnabled())
+            {
+                log.debug("Queried: " + name + ", returned: " + value + ", a " + value.getClass().getName());
+            }
+            if (value instanceof Expression)
+            {
+                return ((Expression) value).evaluateAsString(context);
+            }
+            else
+            {
+                return value.toString();
+            }
         }
     }
 
@@ -89,12 +107,13 @@
      */
     public Hashtable getProperties()
     {
+        log.debug("getProperties()");
         Hashtable h = new Hashtable();
         for ( Iterator i = this.context.getVariableNames(); i.hasNext();)
         {
             String name = (String) i.next();
-            Object value = this.context.getVariable( name );
-            if ( value != null && value.toString() != null )
+            Object value = getProperty(name);
+            if (value != null)
             {
                 h.put( name, value.toString() );
             }
--- cut ---

-- 
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen          INTERMETA GmbH
hps@intermeta.de        +49 9131 50 654 0   http://www.intermeta.de/

RedHat Certified Engineer -- Jakarta Turbine Development  -- hero for hire
   Linux, Java, perl, Solaris -- Consulting, Training, Development

"Au�erdem k�nnen in Deutschland alle Englisch. [...] so entf�llt die
Notwendigkeit [...] Deutsch zu lernen." 
            -- Johan Micoud auf die Frage warum er kein Deutsch spricht.
                   (http://www.spiegel.de/spiegel/0,1518,273205,00.html)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org