You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Guillaume Laforge <gl...@gmail.com> on 2005/05/01 22:44:51 UTC

Re: tag and Groovy

Hello Sean,

I'm back with some good news for you.

On 25/04/05, M. Sean Gilligan <se...@msgilligan.com> wrote:
> [...]
> Using ant 1.6.1, I can use the ant <script> tag to run short scripts in JavaScript, Groovy, Jython, and Beanshell.  (as long as the right jars are in my ant/lib directory...)
> 
> I'd like to be able to do this in a maven.xml file under Maven 1.0.2.  Is this possible?
> [...]
>    <jython:script>
> print "This is a jython script"
> print "My Maven POM's name is", pom.getName()
> print "If the POM has a name, then the context passing is working"
>     </jython:script>
> 
> After putting xmlns:jython="jelly:jython" in the root <project> tag and the (correct?) jar files in Maven's path.
> [...]

In the upcoming Groovy (jsr-02) release (in a month or so), Jeremy
Rayner created a groovy Ant task, and I've patched it to be
Maven-friendly. So you should be able to do what you want with Maven +
Groovy.

You'll be able to use Groovy in your maven.xml like so:

<?xml version="1.0" encoding="UTF-8"?>
<project default="groovy" xmlns:ant="jelly:ant"> 
  <goal name="groovy">
    <ant:taskdef name="groovy"
classname="org.codehaus.groovy.ant.Groovy"
classpathref="maven.dependency.classpath"/>
    <ant:groovy>
    	println pom.eachPropertyName{ println it }
    	println pom.build.souceDirectory
    </ant:groovy>
  </goal>
</project>

You'll have to add Groovy in your dependencies:

    <dependency>
      <groupId>groovy</groupId>
      <artifactId>groovy-all</artifactId>
      <version>1.0-jsr-02-SNAPSHOT</version>
      <properties>
        <classloader>root</classloader>
      </properties>
    </dependency>

If you build Groovy from sources and install that artifact in your
local repo, you'll be able to use that Ant task.

I've just added the pom in the context, tell me if there are other
properties I'd need to bind in the context. Thanks in advance for
that.

-- 
Guillaume Laforge
Groovy Project Manager
http://glaforge.free.fr/weblog/?catid=2

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