Hi Jason
Thanks for that fast reply. Maybe I am using Maven1 too much to see
why this has to be this way but I have to say that this something I
don't like with the Mojos. Compared to Jelly plugins that is quite
complicated and looks way too much like Ant.
On the other hand maybe the project website: http://mojo.codehaus.org/
groovy/guide-groovy-plugin-development.html which shows in the
section for "Copying files" this:
def dir = "${project.build.directory}/backup"
ant.mkdir(dir: dir)
ant.copy(todir: dir) {
fileset(dir: "${project.build.outputDirectoy}") {
include(name: '**/*')
}
}
which will not work either, does it?
Thanks - Andy
On Aug 15, 2007, at 2:24 PM, Jason Dillon wrote:
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.getGroovyObjectProp
erty(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