Hi Andy :-)

You need to use normal Mojo semantics to get a hold of Maven properties. There is no magical GString configuration to pre-load the execution binding with Maven bits. Also, there isn't really a need to use ant.echo() to print stuff out... so I'd recommending using something like this instead for your simple example:

<snip>
/**
 * Compiles Java Classes
 *
 * @goal compile
 * @phase compile
 */
class JavaCompileMojo
    extends GroovyMojoSupport
{
    /**
     * @parameter expression="${project.basedir}"
     */
    File basedir

    void execute() {
        println('Hello Andy')
        ant.echoproperties()
        println("Basedir: $basedir")
    }
}
</snip>

Cheers,

--jason


On Aug 15, 2007, at 8:54 AM, Andreas Schaefer wrote:

Hi Geeks

I just started to look into Maven 2 Groovy Plugin and I am already stomped. It seems that I cannot retrieve Maven properties. I am working on a Mac OS X 10.4.10 (Intel), Java 1.6.0-dp and using Maven2 2.0.7.

I have this little groovy plugin:

package com.madplanet.m2

import org.codehaus.mojo.groovy.GroovyMojoSupport

/**
 * Compiles Java Classes
 *
 * @goal compile
 * @phase compile
 */
class JavaCompileMojo
    extends GroovyMojoSupport
{
    void execute() {
        ant.echo( "Hello Andy" )
        ant.echoproperties()
        ant.echo( "Basedir: ${basedir}" )
    }
}

and get this error:

[INFO] ---------------------------------------------------------------------- --
[ERROR] FATAL ERROR
[INFO] ---------------------------------------------------------------------- -- [INFO] No such property: basedir for class: com.madplanet.m2.JavaCompileMojo [INFO] ---------------------------------------------------------------------- --
[INFO] Trace
groovy.lang.MissingPropertyException: No such property: basedir for class: com.madplanet.m2.JavaCompileMojo at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java: 942) at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java: 2183)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:589)
at org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke (ReflectionMetaMethod.java:52) at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke (MetaClassHelper.java:714) at groovy.lang.MetaClassImpl.invokeMethod (MetaClassImpl.java:583) at groovy.lang.MetaClassImpl.invokeMethod (MetaClassImpl.java:476) at org.codehaus.groovy.runtime.Invoker.invokePojoMethod (Invoker.java:104) at org.codehaus.groovy.runtime.Invoker.invokeMethod (Invoker.java:77) at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod (InvokerHelper.java:85) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN (ScriptBytecodeAdapter.java:158) at org.codehaus.mojo.groovy.GroovyMojoSupport.getProperty (GroovyMojoSupport.groovy) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.getGroovyObjectPrope rty(ScriptBytecodeAdapter.java:527) at com.madplanet.m2.JavaCompileMojo.execute (JavaCompileMojo.groovy:17)


Any ideas what I am doing wrong? I assume it is plain stupid but I can't see it.

Thanks - Andy


---------------------------------------------------------------------
To unsubscribe from this list please visit:

   http://xircles.codehaus.org/manage_email



---------------------------------------------------------------------
To unsubscribe from this list please visit:

   http://xircles.codehaus.org/manage_email

Reply via email to