I've been trying to get groovy working for anything except manual scripting for s few days with not much luck. The installation and usage documentation is almost nonexistent. I'm worried that I may have something set up wrong, because I can't even get groovy to run its own test suite. In particular, has anyone got the ant "groovyc" task working? I keep getting cryptic classloader errors from ant. I really like the idea, though, and I'm itching to use it!
Originally posted by Frank Carver: I've been trying to get groovy working for anything except manual scripting for s few days with not much luck. The installation and usage documentation is almost nonexistent. I'm worried that I may have something set up wrong, because I can't even get groovy to run its own test suite. In particular, has anyone got the ant "groovyc" task working? I keep getting cryptic classloader errors from ant. I really like the idea, though, and I'm itching to use it!
I'm with you. I haven't been able to even get an echo ANT task to work without getting some strange exception. But Groovy looks exciting and promising. I am running the groovysh console and I type in the following commands:
And the output I get is:
And I am not sure if that is normal behavior or not. But it really needs some better documentation. As usual though, an Open Source project with crap documentation doesn't surprise me.
Joined: Jan 07, 1999
OK. More evaluation tidbits I thought I'd ahare. The major issue I had with ant was in getting the add-in ant task "groovyc" to work without "class not found" errors. There is an elliptical mention on the groovy site:
However, there are a few issues with this. One problem is that the "groovyc" task requires "asm.jar" and "asm-util.jar" (from objectweb.org), but it doesn't say that anywhere in the documentation. Another problem is that the supplied groovyc task doesn't work with the latest versions of these jars. And so on. Eventually, though, I got this process working and generating class files. Unfortunately, I am a little disappointed. Despite the claims on the groovy website, the generated classes are not independently usable. To run a class file generated by groovy, you need to have the groovy jar in the classpath. That's kind of acceptable - I can see the advantage of providing run-time suport for groovy features. Worse, though, is the requirement to have the asm jar file in the classpath! Surely, asm is only needed when compiling, not when runnig a class. That's like having to deliver Sun's "tools.jar" with every 1k "hello world" class file. Looking at the groovy source code, the main problem seems to be that the small and innocuous "GroovyObject" interface includes a reference to the huge, tangled, and concrete "MetaClass" class. For lightweight deployment this should definately be at most an interface, and ideally not mentioned at all. I'm probably going to take this up with the groovy developers. I have this feeling that they have forgotten that they always have asm in their development classpaths, and have not noticed the crazy run-time dependency. [ December 17, 2003: Message edited by: Frank Carver ]
Hi, all: My original thought on reading the post was that you were talking about a compilation problem in Groovy itself, in which case you could resolve it using Maven instead of Ant to perform the build of Groovy. In re-reading the post, though, am I to understand that the Asm dependency is a runtime dependency? It seems you could get around the dependency the same way the Groovy developers did: convert your build process to use Maven projects. Definitely overkill for anything less than a full production system, though. Certainly makes prototyping a pain... [ February 05, 2004: Message edited by: Roby Gamboa ]
Joined: Jan 07, 1999
Yes, it's a runtime dependency. Asm is required to run (ie compile and execute) Groovy scripts, and is an essential component of being able to directly run groovy script (source) files. I can live with that. However, I want to use the supplied "groovyc" task to pre-compile Groovy source code into regular Java classes, so I can use them with my existing Java code. Unfortunately, even these precompiled classes have a load-time dependency on asm. It may be a crazy wish, but I want to be able to compile Groovy code to regular Java classes, with no hidden dependencies. If I don't use something in my code, I don't want the generated classes to need it.