You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Jason Dillon <ja...@planet57.com> on 2007/08/11 00:27:42 UTC

*Completely* unfiltered/evaluated mojo parameter?

Hey, is there anyway to get a specific mojo parameters value passed  
in *completely* unfiltered or evaluated with the default property  
expansion?

I'd like to get the XML contents *exactly* how they are in the  
pom.xml file... so for example in this plugin configuration:

----8<----
<plugin>
     <groupId>org.codehaus.mojo.groovy</groupId>
     <artifactId>groovy-maven-plugin</artifactId>
     <executions>
         <execution>
             <phase>generate-resources</phase>
             <goals>
                 <goal>execute</goal>
             </goals>
             <configuration>
                 <source>
                     println "${basedir}"
                 </source>
             </configuration>
         </execution>
     </executions>
</plugin>
---->8----

I really, really, *really* want to have the "source" parameter  
injected as 'println "${basedir}"' and not have Maven expand $ 
{basedir} at all.

For most params I want Maven to do this, but for this one specific  
param... I really need it to leave it alone.  As right now its  
causing problems for windows users when they reference properties in  
GStrings.

So on windows, evil *ucking platform, Maven passes in something more  
like 'println "c:\cygwin\home\jason\tmp\test-project"', which... um  
isn't going to work, since my use-case here is to pass that parameter  
into a Groovy shell for execution... and Groovy will puke up  
complaining about \c, \h, \j, or \<anything> that isn't a real escape  
sequence... and even if they are all valid, I don't want it to do  
that... don't need tabs or newlines or whatever in there.

I tried creating a custom converted, based on what I saw in the  
antrun plugin:

     https://svn.codehaus.org/mojo/trunk/mojo/groovy/groovy-maven- 
plugin/src/main/java/org/codehaus/mojo/groovy/CodeSourceConverter.java

But it looks like that PlexusConfiguration.getValue() does not return  
the raw xml from the pom, but has already been through some filtering  
muck.

So... is there anyway to get the *exact*... untouched, asis, whatever  
the user put there, contents of a mojo configuration element?

Any ideas or suggestions would be very helpful at this point... I'm  
running out of ideas.

:-(

Thanks,

--jason

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


Re: *Completely* unfiltered/evaluated mojo parameter?

Posted by Kenney Westerhof <ke...@apache.org>.
hi,

All mojo parameters are evaluated, nothing you can do about that.

But as with all 'templating' or evaluation solutions, you can escape characters
with special meanings in mojo parameters. Just replace $ with $$.

So use this, and you'll get 'println "${basedir}"' injected
as a mojo parameter:

                 <source>
                     println "$${basedir}"
                 </source>

-- Kenney

Jason Dillon wrote:
> Hey, is there anyway to get a specific mojo parameters value passed in 
> *completely* unfiltered or evaluated with the default property expansion?
> 
> I'd like to get the XML contents *exactly* how they are in the pom.xml 
> file... so for example in this plugin configuration:
> 
> ----8<----
> <plugin>
>     <groupId>org.codehaus.mojo.groovy</groupId>
>     <artifactId>groovy-maven-plugin</artifactId>
>     <executions>
>         <execution>
>             <phase>generate-resources</phase>
>             <goals>
>                 <goal>execute</goal>
>             </goals>
>             <configuration>
>                 <source>
>                     println "${basedir}"
>                 </source>
>             </configuration>
>         </execution>
>     </executions>
> </plugin>
> ---->8----
> 
> I really, really, *really* want to have the "source" parameter injected 
> as 'println "${basedir}"' and not have Maven expand ${basedir} at all.
> 
> For most params I want Maven to do this, but for this one specific 
> param... I really need it to leave it alone.  As right now its causing 
> problems for windows users when they reference properties in GStrings.
> 
> So on windows, evil *ucking platform, Maven passes in something more 
> like 'println "c:\cygwin\home\jason\tmp\test-project"', which... um 
> isn't going to work, since my use-case here is to pass that parameter 
> into a Groovy shell for execution... and Groovy will puke up complaining 
> about \c, \h, \j, or \<anything> that isn't a real escape sequence... 
> and even if they are all valid, I don't want it to do that... don't need 
> tabs or newlines or whatever in there.
> 
> I tried creating a custom converted, based on what I saw in the antrun 
> plugin:
> 
>     
> https://svn.codehaus.org/mojo/trunk/mojo/groovy/groovy-maven-plugin/src/main/java/org/codehaus/mojo/groovy/CodeSourceConverter.java 
> 
> 
> But it looks like that PlexusConfiguration.getValue() does not return 
> the raw xml from the pom, but has already been through some filtering muck.
> 
> So... is there anyway to get the *exact*... untouched, asis, whatever 
> the user put there, contents of a mojo configuration element?
> 
> Any ideas or suggestions would be very helpful at this point... I'm 
> running out of ideas.
> 
> :-(
> 
> Thanks,
> 
> --jason
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org

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