You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Matthew McGowan <md...@techie.com> on 2003/01/31 16:24:27 UTC
[patch] MavenJellyContext
Here's a patch to fix a problem where JellyContexts rather than MavenJellyContexts are created.
MavenJellyContext doesn't override createChildContext to instantiate the correct context type, which causes a ClassCastException in BaseTagSupport when new child contexts are created by jelly and then used by maven.
I've included a touchstone test included in the patch. The complete fix also requires a patch to jelly (submitted to the commons-dev list), as not all child contexts were created via the createChildContext factory mathod. I've included the jelly patch here for convenience.
Cheers,
mat.
--
__________________________________________________________
Sign-up for your own FREE Personalized E-mail at Mail.com
http://www.mail.com/?sr=signup
Re: [patch] MavenJellyContext
Posted by Colin Sampaleanu <co...@exis.com>.
Yes! I this is causing a ClassCastException when trying to do some maven
related stuff in a custom tag.
Note that your message doesn't appear to have any attachments, as far as
I can tell (I am using Mozilla mail).
Matthew McGowan wrote:
>Here's a patch to fix a problem where JellyContexts rather than MavenJellyContexts are created.
>
>MavenJellyContext doesn't override createChildContext to instantiate the correct context type, which causes a ClassCastException in BaseTagSupport when new child contexts are created by jelly and then used by maven.
>
>I've included a touchstone test included in the patch. The complete fix also requires a patch to jelly (submitted to the commons-dev list), as not all child contexts were created via the createChildContext factory mathod. I've included the jelly patch here for convenience.
>
>Cheers,
>mat.
>
>
Re: [patch] MavenJellyContext
Posted by Jason van Zyl <ja...@zenplex.com>.
On Fri, 2003-01-31 at 10:24, Matthew McGowan wrote:
> Here's a patch to fix a problem where JellyContexts rather than MavenJellyContexts are created.
>
> MavenJellyContext doesn't override createChildContext to instantiate the correct context type, which causes a ClassCastException in BaseTagSupport when new child contexts are created by jelly and then used by maven.
>
> I've included a touchstone test included in the patch. The complete fix also requires a patch to jelly (submitted to the commons-dev list), as not all child contexts were created via the createChildContext factory mathod. I've included the jelly patch here for convenience.
Cool, now I just need the patch :-)
> Cheers,
> mat.
--
jvz.
Jason van Zyl
jason@zenplex.com
http://tambora.zenplex.org
In short, man creates for himself a new religion of a rational
and technical order to justify his work and to be justified in it.
-- Jacques Ellul, The Technological Society
Re: [patch] MavenJellyContext
Posted by Colin Sampaleanu <co...@exis.com>.
Just so you know in the future, it's probably a better idea anyways to
submit patches through Jira.
http://jira.werken.com/secure/BrowseProject.jspa?id=10030
That way they don't get lost when there is a lot of mailing list
activity going on. I haven't seen anybody commit your patch, so I
actualy created a Jira entry for it, although I goofed up the subject line:
http://jira.werken.com/secure/ViewIssue.jspa?key=MAVEN-245
Matthew McGowan wrote:
>Appologies for this third repost. I've no idea why the attachments
>aren't getting through. I've included the diffs inline below, as well as
>attached in a zip.
>
>Thanks for your patience!
>mat.
>
>
>Index: JellyContext.java
>===================================================================
>RCS file:
>/home/cvspublic/jakarta-commons-sandbox/jelly/src/java/org/apache/common
>s/jelly/JellyContext.java,v
>retrieving revision 1.40
>diff -u -r1.40 JellyContext.java
>--- JellyContext.java 24 Jan 2003 05:54:37 -0000 1.40
>+++ JellyContext.java 31 Jan 2003 15:29:17 -0000
>@@ -603,7 +603,9 @@
> throw new JellyException(e.toString());
> }
>
>- JellyContext newJellyContext = new JellyContext(this,
>newJellyContextURL);
>+ JellyContext newJellyContext = newJellyContext();
>+ newJellyContext.setRootURL( newJellyContextURL );
>+ newJellyContext.setCurrentURL( newJellyContextURL );
> newJellyContext.setExport( export );
> newJellyContext.setInherit( inherit );
>
>Index: maven.xml
>===================================================================
>RCS file:
>/home/cvspublic/jakarta-turbine-maven/src/test/touchstone-build/maven.xm
>l,v
>retrieving revision 1.23
>diff -u -r1.23 maven.xml
>--- maven.xml 29 Jan 2003 18:35:15 -0000 1.23
>+++ maven.xml 31 Jan 2003 14:21:31 -0000
>@@ -5,6 +5,7 @@
> xmlns:i="jelly:interaction"
> xmlns:maven="jelly:maven"
> xmlns:test="jelly:junit"
>+ xmlns:define="jelly:define"
> xmlns:sea="sea"
> xmlns:deploy="deploy">
>
>@@ -132,6 +133,14 @@
> </fail>
> </j:if>
>
>+ <attainGoal name="test-mavenjellyscope"/>
>+ <j:if
>test="${context.findVariable('test-mavenjellyscope')!='success'}">
>+ <fail>
>+ Problem with scope factory method - $${test-mavenjellyscope}
>should have been set to 'success'
>+ but was set to '${test-mavenjellyscope}'.
>+ </fail>
>+ </j:if>
>+
> <!--
> |
> | Inter-plugin preGoal tests.
>@@ -286,6 +295,25 @@
> </echo>
> </goal>
>
>+ <goal xmlns:testmavenjellyscope="test-mavenjellyscope"
>+ name="test-mavenjellyscope" description="throws a ClassCastException
>when
>+ loading the jelly script from a nested maven session.">
>+ <!-- the purpose of this defined tag is to get jelly to create a
>new scope from the one it has.
>+ If the factory methods aren't defined, then the scope is
>not the correct type, and
>+ BaseTagSupport.getMavenContext throws a
>ClassCastException.
>+ -->
>+ <define:taglib uri="test-mavenjellyscope">
>+ <define:tag name="runmaven">
>+ <maven:maven descriptor="${basedir}/project.xml"
>goals="test-mavenjellyscope-helper" />
>+ </define:tag>
>+ </define:taglib>
>+ <testmavenjellyscope:runmaven/>
>+ </goal>
>+
>+ <goal name="test-mavenjellyscope-helper">
>+ <j:set var="test-mavenjellyscope" scope="parent"
>value="success"/>
>+ </goal>
>+
> <!--
> | This preGoal test does NOT work at the moment. This is just a
> | reminder for me to get it working.
>
>Index: MavenJellyContext.java
>===================================================================
>RCS file:
>/home/cvspublic/jakarta-turbine-maven/src/java/org/apache/maven/jelly/Ma
>venJellyContext.java,v
>retrieving revision 1.27
>diff -u -r1.27 MavenJellyContext.java
>--- MavenJellyContext.java 24 Jan 2003 03:50:37 -0000 1.27
>+++ MavenJellyContext.java 31 Jan 2003 14:25:42 -0000
>@@ -124,6 +124,11 @@
> initializeContext();
> }
>
>+ protected JellyContext createChildContext()
>+ {
>+ return new MavenJellyContext(this);
>+ }
>+
> //
>----------------------------------------------------------------------
> // I N S T A N C E M E T H O D S
> //
>----------------------------------------------------------------------
>
>
>
>>-----Opprinnelig melding-----
>>Fra: Matthew McGowan [mailto:mdm@techie.com]
>>Sendt: 31 January 2003 16:24
>>Til: turbine-maven-dev@jakarta.apache.org
>>Emne: [patch] MavenJellyContext
>>
>>
>>Here's a patch to fix a problem where JellyContexts rather
>>than MavenJellyContexts are created.
>>
>>MavenJellyContext doesn't override createChildContext to
>>instantiate the correct context type, which causes a
>>ClassCastException in BaseTagSupport when new child contexts
>>are created by jelly and then used by maven.
>>
>>I've included a touchstone test included in the patch. The
>>complete fix also requires a patch to jelly (submitted to the
>>commons-dev list), as not all child contexts were created via
>>the createChildContext factory mathod. I've included the
>>jelly patch here for convenience.
>>
>>Cheers,
>>mat.
>>
>>
RE: [patch] MavenJellyContext
Posted by Matthew McGowan <ma...@revival.force9.co.uk>.
Appologies for this third repost. I've no idea why the attachments
aren't getting through. I've included the diffs inline below, as well as
attached in a zip.
Thanks for your patience!
mat.
Index: JellyContext.java
===================================================================
RCS file:
/home/cvspublic/jakarta-commons-sandbox/jelly/src/java/org/apache/common
s/jelly/JellyContext.java,v
retrieving revision 1.40
diff -u -r1.40 JellyContext.java
--- JellyContext.java 24 Jan 2003 05:54:37 -0000 1.40
+++ JellyContext.java 31 Jan 2003 15:29:17 -0000
@@ -603,7 +603,9 @@
throw new JellyException(e.toString());
}
- JellyContext newJellyContext = new JellyContext(this,
newJellyContextURL);
+ JellyContext newJellyContext = newJellyContext();
+ newJellyContext.setRootURL( newJellyContextURL );
+ newJellyContext.setCurrentURL( newJellyContextURL );
newJellyContext.setExport( export );
newJellyContext.setInherit( inherit );
Index: maven.xml
===================================================================
RCS file:
/home/cvspublic/jakarta-turbine-maven/src/test/touchstone-build/maven.xm
l,v
retrieving revision 1.23
diff -u -r1.23 maven.xml
--- maven.xml 29 Jan 2003 18:35:15 -0000 1.23
+++ maven.xml 31 Jan 2003 14:21:31 -0000
@@ -5,6 +5,7 @@
xmlns:i="jelly:interaction"
xmlns:maven="jelly:maven"
xmlns:test="jelly:junit"
+ xmlns:define="jelly:define"
xmlns:sea="sea"
xmlns:deploy="deploy">
@@ -132,6 +133,14 @@
</fail>
</j:if>
+ <attainGoal name="test-mavenjellyscope"/>
+ <j:if
test="${context.findVariable('test-mavenjellyscope')!='success'}">
+ <fail>
+ Problem with scope factory method - $${test-mavenjellyscope}
should have been set to 'success'
+ but was set to '${test-mavenjellyscope}'.
+ </fail>
+ </j:if>
+
<!--
|
| Inter-plugin preGoal tests.
@@ -286,6 +295,25 @@
</echo>
</goal>
+ <goal xmlns:testmavenjellyscope="test-mavenjellyscope"
+ name="test-mavenjellyscope" description="throws a ClassCastException
when
+ loading the jelly script from a nested maven session.">
+ <!-- the purpose of this defined tag is to get jelly to create a
new scope from the one it has.
+ If the factory methods aren't defined, then the scope is
not the correct type, and
+ BaseTagSupport.getMavenContext throws a
ClassCastException.
+ -->
+ <define:taglib uri="test-mavenjellyscope">
+ <define:tag name="runmaven">
+ <maven:maven descriptor="${basedir}/project.xml"
goals="test-mavenjellyscope-helper" />
+ </define:tag>
+ </define:taglib>
+ <testmavenjellyscope:runmaven/>
+ </goal>
+
+ <goal name="test-mavenjellyscope-helper">
+ <j:set var="test-mavenjellyscope" scope="parent"
value="success"/>
+ </goal>
+
<!--
| This preGoal test does NOT work at the moment. This is just a
| reminder for me to get it working.
Index: MavenJellyContext.java
===================================================================
RCS file:
/home/cvspublic/jakarta-turbine-maven/src/java/org/apache/maven/jelly/Ma
venJellyContext.java,v
retrieving revision 1.27
diff -u -r1.27 MavenJellyContext.java
--- MavenJellyContext.java 24 Jan 2003 03:50:37 -0000 1.27
+++ MavenJellyContext.java 31 Jan 2003 14:25:42 -0000
@@ -124,6 +124,11 @@
initializeContext();
}
+ protected JellyContext createChildContext()
+ {
+ return new MavenJellyContext(this);
+ }
+
//
----------------------------------------------------------------------
// I N S T A N C E M E T H O D S
//
----------------------------------------------------------------------
> -----Opprinnelig melding-----
> Fra: Matthew McGowan [mailto:mdm@techie.com]
> Sendt: 31 January 2003 16:24
> Til: turbine-maven-dev@jakarta.apache.org
> Emne: [patch] MavenJellyContext
>
>
> Here's a patch to fix a problem where JellyContexts rather
> than MavenJellyContexts are created.
>
> MavenJellyContext doesn't override createChildContext to
> instantiate the correct context type, which causes a
> ClassCastException in BaseTagSupport when new child contexts
> are created by jelly and then used by maven.
>
> I've included a touchstone test included in the patch. The
> complete fix also requires a patch to jelly (submitted to the
> commons-dev list), as not all child contexts were created via
> the createChildContext factory mathod. I've included the
> jelly patch here for convenience.
>
> Cheers,
> mat.
>
>
> --