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 16 Next »

<groovyc>

Description

Compiles groovy source files

Required taskdef

Assuming groovy-all-VERSION.jar is in my.classpath you will need to declare this task at some point in the build.xml prior to using this task.

<groovyc> Attributes

Attribute

Description

Required

srcdir

directories containing Groovy source files

Yes

destdir

directory used to store the compiled groovy files

Yes

classpath

classpath used for compilation

No

stacktrace

if true each compile error message will contain a stacktrace

No

encoding

encoding of source files

No

jointCompilation

enables joint compilation

No

Notes: joint Compilation is available since 1.1 beta 2

<groovyc> Nested Elements

element

kind

Required

Replaces Attribute

src

a path structure

Yes (unless srcdir is used)

srcdir

classpath

a path structure

No

classpath

javac

javac task

No

jointCompilation

Notes:

  • For path structures see for example http://ant.apache.org/manual/using.html#path
  • For usages of the javac task see http://ant.apache.org/manual/CoreTasks/javac.html
  • unlike the ant documentation implies the javac task nested in groovyc means that sources, classpaths, destination and the encoding will be taken from the groovyc element. If you still specify sources or classpaths then they will be additional. >ou should not overwrite the destination, but you are free to choose a different encoding. Other attributes and nested elements are unaffected, for example fork and maxmem may be used freely.

Joint Compilation

Joint Compilation means that the groovy compilation will parse the groovy source files, create a stub of these, will use a java compilier to compile the stubs along with java sources and then continue compilation in the normal groovy compiler. This allows to mix java and groovy files freely in most cases.
To use joint compilation with the jointCompilation Attribute, you have to simulate the command line with compiler switches. -j will enable the joint compilation, every option with -F can be used for flags like nowarn (example -Fnowarn), options with values can be used with -J and an = like for example -Jtarget=1.4 -Jsource=1.4. Using the attribute means to use the javac compiler provided by sun. A complete value may look for example like this: "-j -Fnowarn -Jtarget=1.4 -J-source=1.4"
The other way is to use the javac nested element. You can there use any attribute or nested element javac allows as. The compiler used here will be the one ant selects. If you told ant to use for example jikes as java compiler, then this javac will use jikes too. If you use the nested javac element, you don't need to use the attribute. If you still use the attribute, its value will be ignored.

Example form build.xml in 1.1 beta-3:

  • No labels