You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Zemian Deng <ke...@gmail.com> on 2008/03/04 17:07:00 UTC

escaping dollar sign in archetype templates

Hello,
This is for maven-archetype-plugin related.

There is a "Closed-Won't Fix" jira issue that doesn't have clear  
direction on a work around.
http://jira.codehaus.org/browse/ARCHETYPE-39

What's more strange is that the many proposed methods in that jira  
comments only work on certain types of files!

For example if I have a src/main/resources/archetype-resources/ 
pom.xml, I can escape with \${artifactID} just fine, but if I have a  
resource file like
src/main/resources/archetype-resources/src/main/webapp/welcome.jsp,  
the back slash WON'T work here! Velocity indeed escaped the dollar  
sign, but it also left the back slash in place which messed up the jsp  
as result. I have to use the #set($dollar = '$') method with this type  
of files as workaround.

Since it's not going to be fixed, is there way I can globally declare  
#set($dollar = '$'), so I can use in many more jsp without adding it  
on every file?

Thanks,
Zemian Deng.

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


Re: escaping dollar sign in archetype templates

Posted by Zemian Deng <ke...@gmail.com>.
Sure Wendy, it's added under "How To" section now.
-Z

On Wed, Mar 5, 2008 at 9:16 AM, Wendy Smoak <ws...@gmail.com> wrote:

> On Tue, Mar 4, 2008 at 12:01 PM, Zemian Deng <ke...@gmail.com>
> wrote:
> > This is the archetype's template pom.xml, not the owning project
> >  pom.xml, and hence that line will get processed and removed by the
> >  template engine.  I stated in my original email that this is the file
> >  in question: src/main/resources/archetype-resources/pom.xml.
> >
> >  I am not saying this is a good idea. It's just a undocumented
> >  workaround that I discovered. I much prefer the archetype plugin
> >  itself to provide a way to un-escape the dollar sign so it won't get
> >  substituted by engine.  Or simply populate the parameter ${dollar}
> >  instead of making user to set it is a step to improvement.
>
> Thanks, it was the owning project's pom that I was concerned about.
>
> Can you add this to the Assembly Plugin's wiki page?
> http://docs.codehaus.org/display/MAVENUSER/Assembly+Plugin
>
> --
> Wendy
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: escaping dollar sign in archetype templates

Posted by Wendy Smoak <ws...@gmail.com>.
On Tue, Mar 4, 2008 at 12:01 PM, Zemian Deng <ke...@gmail.com> wrote:
> This is the archetype's template pom.xml, not the owning project
>  pom.xml, and hence that line will get processed and removed by the
>  template engine.  I stated in my original email that this is the file
>  in question: src/main/resources/archetype-resources/pom.xml.
>
>  I am not saying this is a good idea. It's just a undocumented
>  workaround that I discovered. I much prefer the archetype plugin
>  itself to provide a way to un-escape the dollar sign so it won't get
>  substituted by engine.  Or simply populate the parameter ${dollar}
>  instead of making user to set it is a step to improvement.

Thanks, it was the owning project's pom that I was concerned about.

Can you add this to the Assembly Plugin's wiki page?
http://docs.codehaus.org/display/MAVENUSER/Assembly+Plugin

-- 
Wendy

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


Re: escaping dollar sign in archetype templates

Posted by Zemian Deng <ke...@gmail.com>.
This is the archetype's template pom.xml, not the owning project  
pom.xml, and hence that line will get processed and removed by the  
template engine. I stated in my original email that this is the file  
in question: src/main/resources/archetype-resources/pom.xml.

I am not saying this is a good idea. It's just a undocumented  
workaround that I discovered. I much prefer the archetype plugin  
itself to provide a way to un-escape the dollar sign so it won't get  
substituted by engine.  Or simply populate the parameter ${dollar}  
instead of making user to set it is a step to improvement.

-Zemian


On Mar 4, 2008, at Tue Mar 4 - 1:15 PM, Wendy Smoak wrote:

> On Tue, Mar 4, 2008 at 10:37 AM, Zemian Deng  
> <ke...@gmail.com> wrote:
>
>> Added this on top of pom.xml
>> #set($dollar = '$')
>
> Doesn't that make it invalid xml?  I'm not sure this is a good idea if
> anything other than Maven needs to consume the files.
>
> Specifically I wonder whether that line ends up in the pom deployed to
> the artifact repository when you release the project.
>
> -- 
> Wendy
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>


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


Re: escaping dollar sign in archetype templates

Posted by Wendy Smoak <ws...@gmail.com>.
On Tue, Mar 4, 2008 at 10:37 AM, Zemian Deng <ke...@gmail.com> wrote:

> Added this on top of pom.xml
>  #set($dollar = '$')

Doesn't that make it invalid xml?  I'm not sure this is a good idea if
anything other than Maven needs to consume the files.

Specifically I wonder whether that line ends up in the pom deployed to
the artifact repository when you release the project.

-- 
Wendy

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


Re: escaping dollar sign in archetype templates

Posted by Zemian Deng <ke...@gmail.com>.
Added this on top of pom.xml
#set($dollar = '$')


On Mar 4, 2008, at Tue Mar 4 - 12:02 PM, Wendy Smoak wrote:

> On Tue, Mar 4, 2008 at 9:17 AM, Zemian Deng <th...@gmail.com>  
> wrote:
>> Never mind, Answered my own question.
>> Setting velocity parameter in pom.xml will be visible as global to  
>> all
>> other resources filter.
>
> What did you need to put in pom.xml for this to work?  Sounds like a
> good FAQ if it's not in there already.
>
> -- 
> Wendy
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>


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


Re: escaping dollar sign in archetype templates

Posted by Wendy Smoak <ws...@gmail.com>.
On Tue, Mar 4, 2008 at 9:17 AM, Zemian Deng <th...@gmail.com> wrote:
> Never mind, Answered my own question.
>  Setting velocity parameter in pom.xml will be visible as global to all
>  other resources filter.

What did you need to put in pom.xml for this to work?  Sounds like a
good FAQ if it's not in there already.

-- 
Wendy

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


Re: escaping dollar sign in archetype templates

Posted by Zemian Deng <th...@gmail.com>.
Never mind, Answered my own question.
Setting velocity parameter in pom.xml will be visible as global to all  
other resources filter.

Zemian Deng

On Mar 4, 2008, at Tue Mar 4 - 11:07 AM, Zemian Deng wrote:

> Hello,
> This is for maven-archetype-plugin related.
>
> There is a "Closed-Won't Fix" jira issue that doesn't have clear  
> direction on a work around.
> http://jira.codehaus.org/browse/ARCHETYPE-39
>
> What's more strange is that the many proposed methods in that jira  
> comments only work on certain types of files!
>
> For example if I have a src/main/resources/archetype-resources/ 
> pom.xml, I can escape with \${artifactID} just fine, but if I have a  
> resource file like
> src/main/resources/archetype-resources/src/main/webapp/welcome.jsp,  
> the back slash WON'T work here! Velocity indeed escaped the dollar  
> sign, but it also left the back slash in place which messed up the  
> jsp as result. I have to use the #set($dollar = '$') method with  
> this type of files as workaround.
>
> Since it's not going to be fixed, is there way I can globally  
> declare #set($dollar = '$'), so I can use in many more jsp without  
> adding it on every file?
>
> Thanks,
> Zemian Deng.


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