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.
Location of the Groovy (and possibly Java) source files.
Location to store the class files.
The classpath to use.
The classpath to use given as a path references.
The sourcepath to use.
The sourcepath to use given as a path reference.
Encoding of source files.
Asks the compiler for verbose output; defaults to no.
Whether to include the Ant run-time libraries in the classpath; defaults to yes.
Whether to include the default run-time libraries from the executing VM in the classpath; defaults to no.
Whether to execute groovyc using a spawned instance of the JVM; defaults to no.
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)
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)
Indicates whether compilation errors will fail the build; defaults to true.
Indicates whether the source files to be compiled will be listed; defaults to no.
if true each compile error message will contain a stacktrace
Enable joint compilation, specifying the command line options. (Using a nested javac task is preferred.)
|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
<groovyc> Nested Elements
a path structure
Yes (unless srcdir is used)
a path structure
- 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
- The nested javac task behaves more or less as documented for the top-level javac task. srcdir, destdir, classpath, encoding for the nested javac task are taken from the enclosing groovyc task. If these attributes are specified then they are added, they do not replace. In fact, you should not attempt to overwrite the destination. Other attributes and nested elements are unaffected, for example fork, memoryMaximumSize, etc. may be used freely.
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.