Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

There are various options for compiling Groovy code and then either running it or using the Java objects it creates in Java code.

Compling Groovy code to bytecode using a script

There is an Ant task called _groovyc_ which works pretty similarly to the _javac_ Ant task which takes a bunch of groovy source files and compiles them into Java bytecode. Each groovy class then just becomes a normal Java class you can use inside your Java code if you wish.
Indeed the generated Java class is indistinguishable from a normal Java class, other than it implements the

Error rendering macro 'link' : Link needs a name and a URL as arguments.
interface.

Compiling Groovy code to bytecode using Ant

The groovyc Ant task is implemented by the

Error rendering macro 'link' : Link needs a name and a URL as arguments.
class.
You can see an example of this in action inside Groovy's maven.xml file (just search for 'groovyc')

Dynamically using Groovy inside Java applications

If you don't want to explicitly compile groovy code to bytecode you can just

Error rendering macro 'link' : Link needs a name and a URL as arguments.
directly into your Java application.

Runtime dependencies

As well as Java 1.4 and the Groovy jar we also depend at runtime on the ASM library (asm and asm-tree), as well as Antlr.

  • No labels