Skip to content
Skip to breadcrumbs
Skip to header menu
Skip to action menu
Skip to quick search
Quick Search
Browse
Pages
Blog
Labels
Attachments
Mail
Advanced
What’s New
Space Directory
Feed Builder
Keyboard Shortcuts
Confluence Gadgets
Log In
Sign Up
Dashboard
Groovy
Copy Page
You are not logged in. Any changes you make will be marked as
anonymous
. You may want to
Log In
if you already have an account. You can also
Sign Up
for a new account.
This page is being edited by
.
Paragraph
Paragraph
Heading 1
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6
Preformatted
Quote
Bold
Italic
Underline
More colours
Strikethrough
Subscript
Superscript
Monospace
Clear Formatting
Bullet list
Numbered list
Outdent
Indent
Align left
Align center
Align right
Link
Table
Insert
Insert Content
Image
Link
Attachment
Symbol
Emoticon
Wiki Markup
Horizontal rule
tinymce.confluence.insert_menu.macro_desc
Info
JIRA Issue
Status
Gallery
Tasklist
Table of Contents
Other Macros
Page Layout
No Layout
Two column (simple)
Two column (simple, left sidebar)
Two column (simple, right sidebar)
Three column (simple)
Two column
Two column (left sidebar)
Two column (right sidebar)
Three column
Three column (left and right sidebars)
Undo
Redo
Find/Replace
Keyboard Shortcuts Help
<h2><code><groovyc></code></h2><h3>Description</h3><p>Compiles Groovy source files and, if the joint compilation option is used, Java source files.</p><h3>Required taskdef</h3><p>Assuming groovy-all-VERSION.jar is in <em>my.classpath</em> you will need to declare this task at some point in the build.xml prior to the groovyc task being invoked.</p><table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre><taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc" classpathref="my.classpath"/> </pre></td></tr></table><h3><groovyc> Attributes</h3><table class="confluenceTable"><tbody><tr><th class="confluenceTh"><p>Attribute</p></th><th class="confluenceTh"><p>Description</p></th><th class="confluenceTh"><p>Required</p></th></tr><tr><td class="confluenceTd"><p>srcdir</p></td><td class="confluenceTd"><p>Location of the Groovy (and possibly Java) source files.</p></td><td class="confluenceTd"><p>Yes</p></td></tr><tr><td class="confluenceTd"><p>destdir</p></td><td class="confluenceTd"><p>Location to store the class files.</p></td><td class="confluenceTd"><p>Yes</p></td></tr><tr><td class="confluenceTd"><p>classpath</p></td><td class="confluenceTd"><p>The classpath to use.</p></td><td class="confluenceTd"><p>No</p></td></tr><tr><td class="confluenceTd"><p>classpathref</p></td><td class="confluenceTd"><p>The classpath to use given as a path references.</p></td><td class="confluenceTd"><p>No</p></td></tr><tr><td class="confluenceTd"><p>sourcepath</p></td><td class="confluenceTd"><p>The sourcepath to use.</p></td><td class="confluenceTd"><p>No</p></td></tr><tr><td class="confluenceTd"><p>sourcepathref</p></td><td class="confluenceTd"><p>The sourcepath to use given as a path reference.</p></td><td class="confluenceTd"><p>No</p></td></tr><tr><td class="confluenceTd"><p>encoding</p></td><td class="confluenceTd"><p>Encoding of source files.</p></td><td class="confluenceTd"><p>No</p></td></tr><tr><td class="confluenceTd"><p>verbose</p></td><td class="confluenceTd"><p>Asks the compiler for verbose output; defaults to no.</p></td><td class="confluenceTd"><p>No</p></td></tr><tr><td class="confluenceTd"><p>includeAntRuntime</p></td><td class="confluenceTd"><p>Whether to include the Ant run-time libraries in the classpath; defaults to yes.</p></td><td class="confluenceTd"><p>No</p></td></tr><tr><td class="confluenceTd"><p>includeJavaRuntime</p></td><td class="confluenceTd"><p>Whether to include the default run-time libraries from the executing VM in the classpath; defaults to no.</p></td><td class="confluenceTd"><p>No</p></td></tr><tr><td class="confluenceTd"><p>fork</p></td><td class="confluenceTd"><p>Whether to execute groovyc using a spawned instance of the JVM; defaults to no.</p></td><td class="confluenceTd"><p>No</p></td></tr><tr><td class="confluenceTd"><p>memoryInitialSize</p></td><td class="confluenceTd"><p>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)</p></td><td class="confluenceTd"><p>No</p></td></tr><tr><td class="confluenceTd"><p>memoryMaximumSize</p></td><td class="confluenceTd"><p>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)</p></td><td class="confluenceTd"><p>No</p></td></tr><tr><td class="confluenceTd"><p>failonerror</p></td><td class="confluenceTd"><p>Indicates whether compilation errors will fail the build; defaults to true.</p></td><td class="confluenceTd"><p>No</p></td></tr><tr><td class="confluenceTd"><p>listfiles</p></td><td class="confluenceTd"><p>Indicates whether the source files to be compiled will be listed; defaults to no.</p></td><td class="confluenceTd"><p>No</p></td></tr><tr><td class="confluenceTd"><p>stacktrace</p></td><td class="confluenceTd"><p>if true each compile error message will contain a stacktrace</p></td><td class="confluenceTd"><p>No</p></td></tr><tr><td class="confluenceTd"><p>jointCompilationOptions*</p></td><td class="confluenceTd"><p>Enable joint compilation, specifying the command line options. (Using a nested javac task is preferred.)</p></td><td class="confluenceTd"><p>No</p></td></tr><tr><td colspan="1" class="confluenceTd">indy</td><td colspan="1" class="confluenceTd">Enable compilation with the "invoke dynamic" support when using Groovy 2.0 and beyond and running on JDK 7</td><td colspan="1" class="confluenceTd">No</td></tr></tbody></table><p><strong>Notes:</strong> Joint compilation is only available since 1.1-beta-2, jointCompilationOptions is no longer supported, use the nested javac instead</p><h3><groovyc> Nested Elements</h3><table class="confluenceTable"><tbody><tr><th class="confluenceTh"><p>element</p></th><th class="confluenceTh"><p>kind</p></th><th class="confluenceTh"><p>Required</p></th><th class="confluenceTh"><p>Replaces Attribute</p></th></tr><tr><td class="confluenceTd"><p>src</p></td><td class="confluenceTd"><p>a path structure</p></td><td class="confluenceTd"><p>Yes (unless srcdir is used)</p></td><td class="confluenceTd"><p>srcdir</p></td></tr><tr><td class="confluenceTd"><p>classpath</p></td><td class="confluenceTd"><p>a path structure</p></td><td class="confluenceTd"><p>No</p></td><td class="confluenceTd"><p>classpath</p></td></tr><tr><td class="confluenceTd"><p>javac</p></td><td class="confluenceTd"><p>javac task</p></td><td class="confluenceTd"><p>No</p></td><td class="confluenceTd"><p>jointCompilationOptions</p></td></tr></tbody></table><p><strong>Notes:</strong></p><ul><li>For path structures see for example <a href="http://ant.apache.org/manual/using.html#path">http://ant.apache.org/manual/using.html#path</a></li><li>For usages of the javac task see <a href="http://ant.apache.org/manual/CoreTasks/javac.html">http://ant.apache.org/manual/CoreTasks/javac.html</a></li><li>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.</li></ul><h3>Joint Compilation</h3><p>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.</p><p>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.</p><p>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:</p><table class="wysiwyg-macro" data-macro-name="code" data-macro-default-parameter="xml" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGU6eG1sfQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre><groovyc srcdir="${testSourceDirectory}" destdir="${testClassesDirectory}"> <classpath> <pathelement path="${mainClassesDirectory}"/> <pathelement path="${testClassesDirectory}"/> <path refid="testPath"/> </classpath> <javac source="1.4" target="1.4" debug="on" /> </groovyc> </pre></td></tr></table><p>To restate: the javac task gets the srcdir, destdir and classpath from the enclosing groovyc task.</p>
Please type the word appearing in the picture.
Attachments
Labels
Location
Watch this page
< Edit
Preview >
Loading…
Save
Cancel
Next hint
search
attachments
weblink
advanced