somedude (1) [Avatar] Offline
#1
Hi there,

I am aware that this is not an eclipse forum, but I imagine quite a few people make their first groovy steps with eclipse, so here we go:

I ran into a little problem when trying to use the following ant task from page 463 of gina:

<groovy>
class RulePrinter extends Task {
def size = 40
def symbol = '*'
public void execute() { println symbol * size }
}
project.addTaskDefinition('ruler', RulePrinter)
</groovy>
<ruler size="10"/>

I get the error: ruler doesn't support the "size" attribute

The problem can be fixed by replacing "def size = 40" with "int size = 40"
As I had similar problems before when using examples from the web, I would like to understand why.
I assume the author has an environment where original script works. I would like to know how I can set up my environment to have the original running as well.

My Setup:
I am using Eclipse 3.4.1 to run the ant xml file.
I had to add the groovy-all-1.5.7.jar to my Eclipse Ant-Runtime to be able to run it at all, while normal groovy scripts work without that addition. Although this enables me to run the script, eclipse still warns about
"taskdef class org.codehaus.groovy.ant.Groovy cannot be found"
I am using the Groovy feature 1.5.7.20081120_2330



Thanks a lot
Björn
Mittie (397) [Avatar] Offline
#2
Re: ant task problem inside eclipse
Hi,

yes, a better place to ask would either be the groovy mailinglist or even better the groovy-eclipse mailing list.
See also http://xircles.codehaus.org/lists/eclipse-plugin-dev@groovy.codehaus.org

<speculation>
It may well be that the eclipse plugin is simply erroneous in this point.
</speculation>

keep groovin
Dierk