<groovyc>Compiles Groovy source files and, if the joint compilation option is used, Java source files.
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 the groovyc task being invoked.
Attribute | Description | Required |
|---|---|---|
srcdir | Location of the Groovy (and possibly Java) source files. | Yes |
destdir | Location to store the class files. | Yes |
classpath | The classpath to use. | No |
classpathref | The classpath to use given as a path references. | No |
sourcepath | The sourcepath to use. | No |
sourcepathref | The sourcepath to use given as a path reference. | No |
encoding | Encoding of source files. | No |
verbose | Asks the compiler for verbose output; defaults to no. | No |
includeAntRuntime | Whether to include the Ant run-time libraries in the classpath; defaults to yes. | No |
includeJavaRuntime | Whether to include the default run-time libraries from the executing VM in the classpath; defaults to no. | No |
fork | Whether to execute groovyc using a spawned instance of the JVM; defaults to no. | No |
memoryInitialSize | The initial size of the memory for the underlying VM, if using fork mode; ignored otherwise. Defaults to the standard VM memory setting. (Examples: 83886080, 81920k, or 80m) | No |
memoryMaximumSize | The maximum size of the memory for the underlying VM, if using fork mode; ignored otherwise. Defaults to the standard VM memory setting. (Examples: 83886080, 81920k, or 80m) | No |
failonerror | Indicates whether compilation errors will fail the build; defaults to true. | No |
listfiles | Indicates whether the source files to be compiled will be listed; defaults to no. | No |
stacktrace | if true each compile error message will contain a stacktrace | No |
jointCompilationOptions* | Enable joint compilation, specifying the command line options. (Using a nested javac task is preferred.) | No |
| indy | Enable compilation with the "invoke dynamic" support when using Groovy 2.0 and beyond and running on JDK 7 | No |
Notes: Joint compilation is only available since 1.1-beta-2, jointCompilationOptions is no longer supported, use the nested javac instead
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 | jointCompilationOptions |
Notes:
Joint compilation means that the Groovy compilation will parse the Groovy source files, create stubs for all of them, invoke the Java compiler to compile the stubs along with Java sources, and then continue compilation in the normal Groovy compiler way. This allows mixing of Java and Groovy files without constraint.
To invoke joint compilation with the jointCompilationOptions attribute, you have to simulate the command line with compiler switches. -j enables the joint compilation mode of working. Flags to the Java compiler are presented to the Groovy compiler with the -F option. So, for example, flags like nowarn are specified with -Fnowarn. Options to the Java compiler that take values are presented to the Groovy compiler using -J options. For example -Jtarget=1.4 -Jsource=1.4 is used to specify the target level and source level. So a complete joinCompilationOptions value may look like: "-j -Fnowarn -Jtarget=1.4 -J-source=1.4". Clearly, using this way of specifying things is a real nuisance and not very Ant-like. In fact there are thoughts to deprecate this way of working and remove it as soon as is practical.
The right way of working is, of course, to use a nested tag and all the attributes and further nested tags as required. It is rare to specify srcdir and destdir, the nested javac task is provided with the srcdir and destdir values from the enclosing groovyc task, and it is invariable the right thing to do just to leave this as is. Here is an example:
To restate: the javac task gets the srcdir, destdir and classpath from the enclosing groovyc task.