Cernunnos Manual


${groovy()}

Description:

Returns the value of the specified Groovy EXPRESSION.

Groovy Logo Among dozens of things we can say about Groovy, it is a dynamic language for the Java platform. This feature -- dynamic -- offers tremendous synergy with Cernunnos because it allows us to evaluate expressions at runtime and then execute them. This feature is especially handy for tasks like <if> and <choose> that rely on conditionals.

The Groovy Language is also concise, modern, and powerful. Its syntax is based on regular Java syntax, so Java developers will experience little difficulty getting up to speed. Since it runs on the JVM, Groovy also integrates with exisiting Java code seamlessly.

Reagents:

Name XPath Description Reagent Type Expected Type Required
CACHE @cache A shared Map to cache items in. The default is the value of the 'Attributes.CACHE' request attribute. PHRASE java.util.Map No
CACHE_MODEL @cache-model Specify either NONE, ONE, or ALL. PHRASE java.lang.String No
EXPRESSION descendant-or-self::text() Script expression to evaluate. PHRASE java.lang.String Yes

Examples:

Tests to see if the first argument on the command line contains the colon (':') character; if so, the argument is sepparated into tokens and a new directory is created using each token:

 
       
        <with-attribute key="Attributes.STRING" value="${$1}"> 
          <if test="${groovy(Attributes.STRING.contains(':'))}"> 
            <token-iterator regex=":"> 
              <mkdirs path="${Attributes.STRING}"/> 
            </token-iterator> 
          </if> 
        </with-attribute> 
       
    

Removes the files 'abc.txt' and 'xyz.txt' from the CVS module checked out at '/usr/local/person':

 
       
        <with-attribute key="myFiles" value="${groovy(['abc.txt', 'xyz.txt'])}"> 
          <cvs-client cvsroot=":pserver:user@host:/usr/local/cvsroot" encoded-password="change^me"> 
            <cvs-remove files="${myFiles}" local-path="/usr/local/person"/> 
          </cvs-client> 
        </with-attribute>