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
<p>There are various options for compiling Groovy code and then either running it or using the Java objects it creates in Java code.</p> <h2>Compling Groovy code to bytecode using a script</h2> <p>There is an Ant task called <strong>groovyc</strong> which works pretty similarly to the <strong>javac</strong> 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.<br /> Indeed the generated Java class is indistinguishable from a normal Java class, other than it implements the<br /> <a href="http://groovy.codehaus.org/api/groovy/lang/GroovyObject.html"><strong>GroovyObject</strong></a> interface.</p> <h2>Compiling Groovy code to bytecode using Ant and Maven</h2> <p>The <a class="confluence-link" href="/display/GROOVY/The+groovyc+Ant+Task" data-linked-resource-id="32704" data-linked-resource-type="page" data-linked-resource-default-alias="The groovyc Ant Task" data-base-url="http://docs.codehaus.org">groovyc</a> Ant task is implemented by the <a href="http://groovy.codehaus.org/gapi/org/codehaus/groovy/ant/Groovyc.html">Groovyc</a> class. You can see an example of this in action inside Groovy's maven.xml file (just search for 'groovyc')</p> <p>There is also an excellent <a href="http://www-128.ibm.com/developerworks/java/library/j-pg11094/">article on DeveloperWorks</a><br /> which will show you how to compile Groovy code from within Maven, similarly to what is done with Ant.</p> <p>You can also use the Ant task <a class="confluence-link" href="/display/GROOVY/Compiling+With+Maven2" data-linked-resource-id="51235" data-linked-resource-type="page" data-linked-resource-default-alias="Compiling With Maven2" data-base-url="http://docs.codehaus.org">from within Maven2</a>, or the <a href="http://mojo.codehaus.org/groovy/">groovy-maven-plugin </a></p> <h2>Dynamically using Groovy inside Java applications</h2> <p>If you don't want to explicitly compile groovy code to bytecode you can just <a class="confluence-link" href="/display/GROOVY/Embedding+Groovy" data-linked-resource-id="2752" data-linked-resource-type="page" data-linked-resource-default-alias="Embedding Groovy" data-base-url="http://docs.codehaus.org">embed groovy</a> directly into your Java application.</p> <h2>Runtime dependencies</h2> <p>As well as Java 1.4, or above, and the Groovy jar we also depend at runtime on the ASM library (asm and asm-tree mainly), as well as Antlr. You can also use the groovy-all-xxx.jar from your GROOVY_HOME/embeddable directory, which embeds ASM and Antlr in its own namespace, to avoid Jar version hell.</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