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
<img class="editor-inline-macro" src="/plugins/servlet/confluence/placeholder/macro?definition=e3RvYzptYXhMZXZlbD0yfGluZGVudD0yMHB4fHN0eWxlPWRpc2N9&locale=en_GB&version=2" data-macro-name="toc" data-macro-parameters="indent=20px|maxLevel=2|style=disc"> <h1>Overview</h1> <p>The Groovy-Eclipse team is proud to announce the first milestone release of the Groovy-Eclipse plugin. In this release, we have focused on ensuring that the basic edit-compile-run/test/debug loop works as smoothly as possible. Unlike version 1 of the plugin, this version is based upon a new approach to integrating the groovy compiler into eclipse. We have extended the Eclipse JDT compiler to be pluggable by other compilers for Java-like languages. We have plugged in <code>groovyc</code> so that the JDT can build and manipulate both Java and Groovy files in the same project (for more information, please read our earlier blog post, <a href="http://blog.springsource.com/2009/07/30/a-groovier-eclipse-experience/">A Groovier Eclipse Experience</a>). Importantly, this approach enables incremental compilation to work for a multi-language project. We have also put significant effort into ensuring that Groovy developers can naturally use the same standard Eclipse Java facilities that Java developers have become reliant on. This includes facilities like: JUnit testing, debugging, content assist, early error indication, open-type, and outline views. Full feature details are below.</p> <p>The update site (and all future milestone update sites) is here:</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> http://dist.springsource.org/milestone/GRECLIPSE/e3.5/ </pre></td></tr></table> <h1>Core</h1> <h3>Cross language dependencies</h3> <p>Full support for any kind of dependency between .java and .groovy files is supported.</p> <p><img class="confluence-embedded-image confluence-content-image-border image-center" src="/download/attachments/231080044/MixedHierarchies.gif?version=1&modificationDate=1369273396256" data-image-src="/download/attachments/231080044/MixedHierarchies.gif?version=1&modificationDate=1369273396256" data-linked-resource-id="231375326" data-linked-resource-type="attachment" data-linked-resource-default-alias="MixedHierarchies.gif" data-base-url="http://docs.codehaus.org" data-linked-resource-container-id="231080044" title="null > MixedHierarchies.gif"></p> <h3>Generics Checking</h3> <p>Since JDT can now understand groovy source (to a degree), it applies some generics checking to the groovy code and will report correct warnings that <code>groovyc</code> would not normally show:</p> <p><img class="confluence-embedded-image confluence-content-image-border image-center" src="/download/attachments/231080044/GenericsChecking.gif?version=1&modificationDate=1369273396198" data-image-src="/download/attachments/231080044/GenericsChecking.gif?version=1&modificationDate=1369273396198" data-linked-resource-id="231375324" data-linked-resource-type="attachment" data-linked-resource-default-alias="GenericsChecking.gif" data-base-url="http://docs.codehaus.org" data-linked-resource-container-id="231080044" title="null > GenericsChecking.gif"></p> <h3>Incremental compilation</h3> <p>Changes made to either .java or .groovy files will result in an incremental compilation of the containing project. Even if the dependencies are in a different language, the impact of the change will correctly propagate.</p> <p><img class="confluence-embedded-image confluence-content-image-border image-center" src="/download/attachments/231080044/IncrementalCompilation.gif?version=1&modificationDate=1369273396179" data-image-src="/download/attachments/231080044/IncrementalCompilation.gif?version=1&modificationDate=1369273396179" data-linked-resource-id="231375323" data-linked-resource-type="attachment" data-linked-resource-default-alias="IncrementalCompilation.gif" data-base-url="http://docs.codehaus.org" data-linked-resource-container-id="231080044" title="null > IncrementalCompilation.gif"></p> <h3>AST transforms</h3> <p>Projects may exploit AST transforms that are accessible on the project classpath. Transforms like <code>@Singleton</code> that are defined by groovy are immediately accessible due to the groovy libraries being on every groovy project classpath. To exploit transforms provided by third parties, the jars containing the transform implementation must be added to the project classpath prior to usage. As a temporary feature (still under evaluation) in this version, transforms defined in .java files <strong>may</strong> be exploited in the same project they are defined, although on changing the transform it may be necessary to do a full build of the project to pick up the change.</p> <h3>Compiler level switching</h3> <p>The Groovy-Eclipse plugin M1 ships with both the 1.7-beta2 and 1.6.5 versions of the groovy compiler. Currently, the only way to switch between the two versions is outside of Eclipse. Here is how:</p> <ol> <li>Shut down Eclipse</li> <li>Go to eclipse/configuration/org.eclipse.equinox.simpleconfigurator</li> <li>Make a backup copy of bundles.info</li> <li>Open bundles.info in a text editor</li> <li>Find the line for org.codehaus.groovy_1.7.0 and delete</li> <li>Restart eclipse</li> </ol> <p>To re-enable the 1.7 compiler, simply reinstate the backed up copy of bundles.info.</p> <h3>@Grab annotation</h3> <p>Basic support for Grape and the Grab annotation is included, but the code using the annotation may show a compile error (due to a missing dependency), however it will run as a groovy script:</p> <p><img class="confluence-embedded-image confluence-content-image-border image-center" src="/download/attachments/231080044/GrabAnnotation.gif?version=1&modificationDate=1369273396224" data-image-src="/download/attachments/231080044/GrabAnnotation.gif?version=1&modificationDate=1369273396224" data-linked-resource-id="231375325" data-linked-resource-type="attachment" data-linked-resource-default-alias="GrabAnnotation.gif" data-base-url="http://docs.codehaus.org" data-linked-resource-container-id="231080044" title="null > GrabAnnotation.gif"></p> <h1>User Interface</h1> <h3>Wizards</h3> <p>The wizards available mimic their Java counterparts.</p> <h5>New Groovy Project Wizard</h5> <p>The new Groovy project wizard allows you to create an Eclipse project pre-configured with Groovy support:</p> <p><img class="confluence-embedded-image confluence-content-image-border image-center" src="/download/attachments/231080044/new_project1.gif?version=1&modificationDate=1369273395878" data-image-src="/download/attachments/231080044/new_project1.gif?version=1&modificationDate=1369273395878" data-linked-resource-id="231375309" data-linked-resource-type="attachment" data-linked-resource-default-alias="new_project1.gif" data-base-url="http://docs.codehaus.org" data-linked-resource-container-id="231080044" title="null > new_project1.gif"></p> <p>It supports all of the options available for Java projects:</p> <p><img class="confluence-embedded-image confluence-content-image-border image-center" src="/download/attachments/231080044/new_project2.gif?version=1&modificationDate=1369273395850" data-image-src="/download/attachments/231080044/new_project2.gif?version=1&modificationDate=1369273395850" data-linked-resource-id="231375308" data-linked-resource-type="attachment" data-linked-resource-default-alias="new_project2.gif" data-base-url="http://docs.codehaus.org" data-linked-resource-container-id="231080044" title="null > new_project2.gif"></p> <h5>New Groovy Class Wizard</h5> <p>This wizard creates a new Groovy class, with many of the same options available for the Java Class creation wizard:</p> <p><img class="confluence-embedded-image confluence-content-image-border image-center" src="/download/attachments/231080044/new_class.gif?version=1&modificationDate=1369273396691" data-image-src="/download/attachments/231080044/new_class.gif?version=1&modificationDate=1369273396691" data-linked-resource-id="231375346" data-linked-resource-type="attachment" data-linked-resource-default-alias="new_class.gif" data-base-url="http://docs.codehaus.org" data-linked-resource-container-id="231080044" title="null > new_class.gif"></p> <h5>New Groovy Test Case Wizard</h5> <p>This wizard assists you in creating a new Groovy JUnit 3 or JUnit 4 test case:</p> <p><img class="confluence-embedded-image confluence-content-image-border image-center" src="/download/attachments/231080044/new_test.gif?version=1&modificationDate=1369273396659" data-image-src="/download/attachments/231080044/new_test.gif?version=1&modificationDate=1369273396659" data-linked-resource-id="231375345" data-linked-resource-type="attachment" data-linked-resource-default-alias="new_test.gif" data-base-url="http://docs.codehaus.org" data-linked-resource-container-id="231080044" title="null > new_test.gif"></p> <h3>Convert Legacy projects</h3> <p>On startup, you are reminded to convert any legacy groovy projects in your workspace:</p> <p><img class="confluence-embedded-image confluence-content-image-border image-center" src="/download/attachments/231080044/convert_legacy1.gif?version=1&modificationDate=1369273396640" data-image-src="/download/attachments/231080044/convert_legacy1.gif?version=1&modificationDate=1369273396640" data-linked-resource-id="231375344" data-linked-resource-type="attachment" data-linked-resource-default-alias="convert_legacy1.gif" data-base-url="http://docs.codehaus.org" data-linked-resource-container-id="231080044" title="null > convert_legacy1.gif"></p> <p>If you can decide to permanently dismiss this dialog box, you can still do the conversion from the preference pages:</p> <p><img class="confluence-embedded-image confluence-content-image-border image-center" src="/download/attachments/231080044/convert_legacy2.gif?version=1&modificationDate=1369273395950" data-image-src="/download/attachments/231080044/convert_legacy2.gif?version=1&modificationDate=1369273395950" data-linked-resource-id="231375312" data-linked-resource-type="attachment" data-linked-resource-default-alias="convert_legacy2.gif" data-base-url="http://docs.codehaus.org" data-linked-resource-container-id="231080044" title="null > convert_legacy2.gif"></p> <h3>Groovy Editor</h3> <p>As much as possible, we try to provide the same kind of behavior in the Groovy editor as you would expect in the Java editor. By default, the editor uses a different set of colors from the Java editor in order to emphasize the difference between the two languages. However, if you prefer standard Java syntax coloring, you can select it on the following preference page:</p> <p><img class="confluence-embedded-image confluence-content-image-border image-center" src="/download/attachments/231080044/editor_prefs.gif?version=1&modificationDate=1369273395934" data-image-src="/download/attachments/231080044/editor_prefs.gif?version=1&modificationDate=1369273395934" data-linked-resource-id="231375311" data-linked-resource-type="attachment" data-linked-resource-default-alias="editor_prefs.gif" data-base-url="http://docs.codehaus.org" data-linked-resource-container-id="231080044" title="null > editor_prefs.gif"></p> <p>Additionally, the Groovy editor provides the following capabilities.</p> <h5>Early error indication and reconciling</h5> <p>Errors are highlighted as you type. This functionality is provided by hooking into JDT's reconciling capability:</p> <p><img class="confluence-embedded-image confluence-content-image-border image-center" src="/download/attachments/231080044/reconcile1.gif?version=1&modificationDate=1369273396620" data-image-src="/download/attachments/231080044/reconcile1.gif?version=1&modificationDate=1369273396620" data-linked-resource-id="231375343" data-linked-resource-type="attachment" data-linked-resource-default-alias="reconcile1.gif" data-base-url="http://docs.codehaus.org" data-linked-resource-container-id="231080044" title="null > reconcile1.gif"></p> <p>An additional benefit of reconciling means that content assist proposals that come from files with unsaved changes will appear where expected. In the following example, the <code>Shape</code> class the definition of the <code>numberOfSides</code> property has not been saved to disk yet, but it appears in the content assist proposals list of the <code>ShapesTest</code> class:</p> <p><img class="confluence-embedded-image confluence-content-image-border image-center" src="/download/attachments/231080044/content_assist1.gif?version=1&modificationDate=1369273396592" data-image-src="/download/attachments/231080044/content_assist1.gif?version=1&modificationDate=1369273396592" data-linked-resource-id="231375342" data-linked-resource-type="attachment" data-linked-resource-default-alias="content_assist1.gif" data-base-url="http://docs.codehaus.org" data-linked-resource-container-id="231080044" title="null > content_assist1.gif"></p> <h5>Content assist</h5> <p>Inferencing content assist has been available since earlier versions of the Groovy-Eclipse plugin. We are continuing to improve on this. For M1, we have focused on reliability and availability of content assist. For M2, we will focus on completeness of results. And for the final release, we will work on some performance tuning.</p> <p>In following example, notice that there are two levels of inferencing happening. The editor correctly determines that <code>someObject</code> is an <code>int</code> <code>numberOfSides</code> is an <code>int</code>:</p> <p><img class="confluence-embedded-image confluence-content-image-border image-center" src="/download/attachments/231080044/content_assist2.gif?version=1&modificationDate=1369273396568" data-image-src="/download/attachments/231080044/content_assist2.gif?version=1&modificationDate=1369273396568" data-linked-resource-id="231375341" data-linked-resource-type="attachment" data-linked-resource-default-alias="content_assist2.gif" data-base-url="http://docs.codehaus.org" data-linked-resource-container-id="231080044" title="null > content_assist2.gif"></p> <p>And now, the inferencing engine is able to determine that the type of <code>someObject</code> is now a <code>String</code>:</p> <p><img class="confluence-embedded-image confluence-content-image-border image-center" src="/download/attachments/231080044/content_assist3.gif?version=1&modificationDate=1369273396544" data-image-src="/download/attachments/231080044/content_assist3.gif?version=1&modificationDate=1369273396544" data-linked-resource-id="231375340" data-linked-resource-type="attachment" data-linked-resource-default-alias="content_assist3.gif" data-base-url="http://docs.codehaus.org" data-linked-resource-container-id="231080044" title="null > content_assist3.gif"></p> <h5>Navigation</h5> <p>Typing F3, or CTRL-click (CMD-click on Macs) will navigate to the definition of a reference. Navigation hooks into the same inferencing engine being used for content assist. So, pressing F3 on the following:</p> <p><img class="confluence-embedded-image confluence-content-image-border image-center" src="/download/attachments/231080044/navigation1.gif?version=1&modificationDate=1369273396528" data-image-src="/download/attachments/231080044/navigation1.gif?version=1&modificationDate=1369273396528" data-linked-resource-id="231375339" data-linked-resource-type="attachment" data-linked-resource-default-alias="navigation1.gif" data-base-url="http://docs.codehaus.org" data-linked-resource-container-id="231080044" title="null > navigation1.gif"></p> <p>will open an editor on the declaration:</p> <p><img class="confluence-embedded-image confluence-content-image-border image-center" src="/download/attachments/231080044/navigation2.gif?version=1&modificationDate=1369273396512" data-image-src="/download/attachments/231080044/navigation2.gif?version=1&modificationDate=1369273396512" data-linked-resource-id="231375338" data-linked-resource-type="attachment" data-linked-resource-default-alias="navigation2.gif" data-base-url="http://docs.codehaus.org" data-linked-resource-container-id="231080044" title="null > navigation2.gif"></p> <p>You can also notice reconciling at work here because the <code>Shape.groovy</code> has not yet been saved since the <code>numberOfSides</code> property has been added.</p> <h3>Search</h3> <p>We have introduced some basic search functionality for M1. Currently, search will be able to locate method, field, and type references if they are explicitly typed. Local variable references cannot be found yet. This is a feature that is of primary importance for M2 and will be significantly improved in the coming snapshot builds.</p> <p><img class="confluence-embedded-image confluence-content-image-border image-center" src="/download/attachments/231080044/search1.gif?version=1&modificationDate=1369273396484" data-image-src="/download/attachments/231080044/search1.gif?version=1&modificationDate=1369273396484" data-linked-resource-id="231375337" data-linked-resource-type="attachment" data-linked-resource-default-alias="search1.gif" data-base-url="http://docs.codehaus.org" data-linked-resource-container-id="231080044" title="null > search1.gif"></p> <p>Again, notice the affect of reconciling in that the search results view contains both references to <code>numberOfSides</code> even though the text has not yet been written to disk.</p> <h3>JUnit Monospace font</h3> <p>There is an option in the Groovy Preferences page to show the JUnit results pane in monospace font:</p> <p><img class="confluence-embedded-image confluence-content-image-border image-center" src="/download/attachments/231080044/monospace1.gif?version=1&modificationDate=1369273396461" data-image-src="/download/attachments/231080044/monospace1.gif?version=1&modificationDate=1369273396461" data-linked-resource-id="231375336" data-linked-resource-type="attachment" data-linked-resource-default-alias="monospace1.gif" data-base-url="http://docs.codehaus.org" data-linked-resource-container-id="231080044" title="null > monospace1.gif"></p> <p>This is helpful for viewing the results of Spock tests. With monospace font, the results pane is much easier to read:</p> <p><img class="confluence-embedded-image confluence-content-image-border image-center" src="/download/attachments/231080044/monospace2.gif?version=1&modificationDate=1369273395998" data-image-src="/download/attachments/231080044/monospace2.gif?version=1&modificationDate=1369273395998" data-linked-resource-id="231375314" data-linked-resource-type="attachment" data-linked-resource-default-alias="monospace2.gif" data-base-url="http://docs.codehaus.org" data-linked-resource-container-id="231080044" title="null > monospace2.gif"></p> <p>than it is without:</p> <p><img class="confluence-embedded-image confluence-content-image-border image-center" src="/download/attachments/231080044/monospace3.gif?version=1&modificationDate=1369273396018" data-image-src="/download/attachments/231080044/monospace3.gif?version=1&modificationDate=1369273396018" data-linked-resource-id="231375315" data-linked-resource-type="attachment" data-linked-resource-default-alias="monospace3.gif" data-base-url="http://docs.codehaus.org" data-linked-resource-container-id="231080044" title="null > monospace3.gif"></p> <h1>Run/Debug</h1> <p>There are two facets to M1's debug support: launching and debugging.</p> <h3>Launching</h3> <p>There are three launch options for your Groovy files and projects:</p> <p><img class="confluence-embedded-image confluence-content-image-border image-center" src="/download/attachments/231080044/run_debug1.gif?version=1&modificationDate=1369273396451" data-image-src="/download/attachments/231080044/run_debug1.gif?version=1&modificationDate=1369273396451" data-linked-resource-id="231375335" data-linked-resource-type="attachment" data-linked-resource-default-alias="run_debug1.gif" data-base-url="http://docs.codehaus.org" data-linked-resource-container-id="231080044" title="null > run_debug1.gif"></p> <h5>Groovy Application</h5> <p>This is similar to launching Java applications. A main method of a Groovy or Java class is launched and you are provided with options similar to launching a standard Java application:</p> <p><img class="confluence-embedded-image confluence-content-image-border image-center" src="/download/attachments/231080044/run_debug2.gif?version=1&modificationDate=1369273396418" data-image-src="/download/attachments/231080044/run_debug2.gif?version=1&modificationDate=1369273396418" data-linked-resource-id="231375334" data-linked-resource-type="attachment" data-linked-resource-default-alias="run_debug2.gif" data-base-url="http://docs.codehaus.org" data-linked-resource-container-id="231080044" title="null > run_debug2.gif"></p> <p>Actually, this launch configuration is so similar to the <em>Java Application</em> launch configuration that it may disappear in future versions of the plugin. Every launchable class file generated from a Groovy script is a valid Java program. And so, all Groovy scripts should be launchable as a Java application in Eclipse. This is currently possible, but needs some further testing before we can safely remove the Groovy application launch configuration.</p> <h5>Groovy Script</h5> <p>This launch configuration launches a *.groovy file as a script. It is identical to running the <code>groovy</code> command from the command line. This launch configuration does not require class files to execute. Only *.groovy files are necessary. As an example of this,it is possible to explicitly remove a Groovy file from the build:</p> <p><img class="confluence-embedded-image confluence-content-image-border image-center" src="/download/attachments/231080044/build_path1.gif?version=1&modificationDate=1369273396394" data-image-src="/download/attachments/231080044/build_path1.gif?version=1&modificationDate=1369273396394" data-linked-resource-id="231375333" data-linked-resource-type="attachment" data-linked-resource-default-alias="build_path1.gif" data-base-url="http://docs.codehaus.org" data-linked-resource-container-id="231080044" title="null > build_path1.gif"></p> <p>And from here, it is still possible to execute a groovy script:</p> <p><img class="confluence-embedded-image confluence-content-image-border image-center" src="/download/attachments/231080044/run_debug3.gif?version=1&modificationDate=1369273396368" data-image-src="/download/attachments/231080044/run_debug3.gif?version=1&modificationDate=1369273396368" data-linked-resource-id="231375332" data-linked-resource-type="attachment" data-linked-resource-default-alias="run_debug3.gif" data-base-url="http://docs.codehaus.org" data-linked-resource-container-id="231080044" title="null > run_debug3.gif"></p> <p>This launch configuration allows the use of the <code>@Grab</code> annotation since scripts do not need to be compilable before they are executed as Groovy Scripts.</p> <h5>Groovy Shell</h5> <p>This launch configuration allows you to run a groovy shell in the console view. When run from a particular project, all class files in the classpath of the project are available from the groovy prompt. For example, it is possible to run a Groovy shell and execute code in the following manner:</p> <p><img class="confluence-embedded-image confluence-content-image-border image-center" src="/download/attachments/231080044/run_debug4.gif?version=1&modificationDate=1369273396357" data-image-src="/download/attachments/231080044/run_debug4.gif?version=1&modificationDate=1369273396357" data-linked-resource-id="231375331" data-linked-resource-type="attachment" data-linked-resource-default-alias="run_debug4.gif" data-base-url="http://docs.codehaus.org" data-linked-resource-container-id="231080044" title="null > run_debug4.gif"></p> <p>Note that there is a bug on windows where the <code>groovy></code> prompt appears twice on each line. See <a href="http://jira.codehaus.org/browse/GRECLIPSE-434">GRECLIPSE-434</a>.</p> <h3>Breakpoints and debugging</h3> <p>The Groovy-Eclipse plugin allows you to set breakpoints on any statement in a Groovy file, including inside closures, by clicking in the gutter bar next to the line where you want the breakpoint to occur:</p> <p><img class="confluence-embedded-image confluence-content-image-border image-center" src="/download/attachments/231080044/run_debug6.gif?version=1&modificationDate=1369273396349" data-image-src="/download/attachments/231080044/run_debug6.gif?version=1&modificationDate=1369273396349" data-linked-resource-id="231375330" data-linked-resource-type="attachment" data-linked-resource-default-alias="run_debug6.gif" data-base-url="http://docs.codehaus.org" data-linked-resource-container-id="231080044" title="null > run_debug6.gif"></p> <p>When launched in debug mode as a Groovy Application or Groovy Script, execution will break when a breakpoint is reached:</p> <p><img class="confluence-embedded-image confluence-content-image-border image-center" src="/download/attachments/231080044/run_debug5.gif?version=1&modificationDate=1369273395803" data-image-src="/download/attachments/231080044/run_debug5.gif?version=1&modificationDate=1369273395803" data-linked-resource-id="231375307" data-linked-resource-type="attachment" data-linked-resource-default-alias="run_debug5.gif" data-base-url="http://docs.codehaus.org" data-linked-resource-container-id="231080044" title="null > run_debug5.gif"></p> <p>When there is ambiguity as to where the breakpoint should be placed, the debugger stops at both locations. As in the previous example, the debugger will stop at the definition of the closure <code>c</code> as well as whenever closure <code>c</code> is invoked.</p> <p>Debugging will even work if there is no class file available for the particular script being debugged. However, there is an extra step on how the debugger finds the source code for the script. When the debugger stops inside a script that does not have a corresponding class file, you will see this kind of editor:</p> <p><img class="confluence-embedded-image confluence-content-image-border image-center" src="/download/attachments/231080044/run_debug7.gif?version=1&modificationDate=1369273395912" data-image-src="/download/attachments/231080044/run_debug7.gif?version=1&modificationDate=1369273395912" data-linked-resource-id="231375310" data-linked-resource-type="attachment" data-linked-resource-default-alias="run_debug7.gif" data-base-url="http://docs.codehaus.org" data-linked-resource-container-id="231080044" title="null > run_debug7.gif"></p> <p>Click on the <em>Edit Source Lookup Path...</em> button and you will see the following dialog:</p> <p><img class="confluence-embedded-image confluence-content-image-border image-center" src="/download/attachments/231080044/run_debug8.gif?version=1&modificationDate=1369273396327" data-image-src="/download/attachments/231080044/run_debug8.gif?version=1&modificationDate=1369273396327" data-linked-resource-id="231375329" data-linked-resource-type="attachment" data-linked-resource-default-alias="run_debug8.gif" data-base-url="http://docs.codehaus.org" data-linked-resource-container-id="231080044" title="null > run_debug8.gif"></p> <p>Click on <em>Add...</em> and the following dialog appears:</p> <p><img class="confluence-embedded-image confluence-content-image-border image-center" src="/download/attachments/231080044/run_debug9.gif?version=1&modificationDate=1369273396310" data-image-src="/download/attachments/231080044/run_debug9.gif?version=1&modificationDate=1369273396310" data-linked-resource-id="231375328" data-linked-resource-type="attachment" data-linked-resource-default-alias="run_debug9.gif" data-base-url="http://docs.codehaus.org" data-linked-resource-container-id="231080044" title="null > run_debug9.gif"></p> <p>Choose <em>Workspace Folder</em> and select the source folder that contains your Groovy script. The end result should look something like this:</p> <p><img class="confluence-embedded-image confluence-content-image-border image-center" src="/download/attachments/231080044/run_debug10.gif?version=1&modificationDate=1369273396293" data-image-src="/download/attachments/231080044/run_debug10.gif?version=1&modificationDate=1369273396293" data-linked-resource-id="231375327" data-linked-resource-type="attachment" data-linked-resource-default-alias="run_debug10.gif" data-base-url="http://docs.codehaus.org" data-linked-resource-container-id="231080044" title="null > run_debug10.gif"></p> <p>Now, the debugger knows how to find source code for scripts without class files. Please note that in future versions of Groovy-Eclipse, we will include functionality to perform this source lookup automatically.</p> <h3>Viewing variables</h3> <p>Once a breakpoint is reached, (as in Java code) you can evaluate variables:</p> <p><img class="confluence-embedded-image confluence-content-image-border image-center" src="/download/attachments/231080044/run_debug11.gif?version=1&modificationDate=1369273396152" data-image-src="/download/attachments/231080044/run_debug11.gif?version=1&modificationDate=1369273396152" data-linked-resource-id="231375322" data-linked-resource-type="attachment" data-linked-resource-default-alias="run_debug11.gif" data-base-url="http://docs.codehaus.org" data-linked-resource-container-id="231080044" title="null > run_debug11.gif"></p> <p>This lets you inspect the current state of the program and even look at the Groovy meta-classes and closures accessible in the current scope.</p> <h3>Runtime evaluation of Groovy code</h3> <p>It is also possible to evaluate code snippets from the display view while in a Groovy scope:</p> <p><img class="confluence-embedded-image confluence-content-image-border image-center" src="/download/attachments/231080044/run_debug12.gif?version=1&modificationDate=1369273396122" data-image-src="/download/attachments/231080044/run_debug12.gif?version=1&modificationDate=1369273396122" data-linked-resource-id="231375321" data-linked-resource-type="attachment" data-linked-resource-default-alias="run_debug12.gif" data-base-url="http://docs.codehaus.org" data-linked-resource-container-id="231080044" title="null > run_debug12.gif"></p> <p>Java syntax is required for evaluating code snippets. What this means is that explicit casting of Groovy objects will be necessary for local variables and dynamically typed references.</p> <h3>Conditional breakpoints</h3> <p>The Groovy debugging facility supports conditional breakpoints (Java syntax required). To create a conditional breakpoint, right click on the breakpoint definition and select <em>Breakpoint Properties...</em>:</p> <p><img class="confluence-embedded-image confluence-content-image-border image-center" src="/download/attachments/231080044/run_debug13.gif?version=1&modificationDate=1369273396108" data-image-src="/download/attachments/231080044/run_debug13.gif?version=1&modificationDate=1369273396108" data-linked-resource-id="231375320" data-linked-resource-type="attachment" data-linked-resource-default-alias="run_debug13.gif" data-base-url="http://docs.codehaus.org" data-linked-resource-container-id="231080044" title="null > run_debug13.gif"></p> <p>The breakpoint properties dialog appears. Select <em>Enable Condition</em> and enter the condition to break at (again, only Java syntax is available, so it will be necessary to explicitly cast all variable references):</p> <p><img class="confluence-embedded-image confluence-content-image-border image-center" src="/download/attachments/231080044/conditional_breakpoints.gif?version=1&modificationDate=1369273396086" data-image-src="/download/attachments/231080044/conditional_breakpoints.gif?version=1&modificationDate=1369273396086" data-linked-resource-id="231375319" data-linked-resource-type="attachment" data-linked-resource-default-alias="conditional_breakpoints.gif" data-base-url="http://docs.codehaus.org" data-linked-resource-container-id="231080044" title="null > conditional_breakpoints.gif"></p> <p>And now the debugger will stop at the defined location only when the condition is evaluated to true!</p> <p><img class="confluence-embedded-image confluence-content-image-border image-center" src="/download/attachments/231080044/run_debug14.gif?version=1&modificationDate=1369273396070" data-image-src="/download/attachments/231080044/run_debug14.gif?version=1&modificationDate=1369273396070" data-linked-resource-id="231375318" data-linked-resource-type="attachment" data-linked-resource-default-alias="run_debug14.gif" data-base-url="http://docs.codehaus.org" data-linked-resource-container-id="231080044" title="null > run_debug14.gif"></p> <h1>Refactoring/Formatting</h1> <p>M1 contains several new refactoring and formatting facilities.</p> <h3>Indentation & Formatting</h3> <p>The Groovy editor will automatically indent poorly indented code on a paste. So, this:</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> def this_is(some) { very poorly indented "code" } </pre></td></tr></table> <p>Becomes this:</p> <p><img class="confluence-embedded-image confluence-content-image-border image-center" src="/download/attachments/231080044/indent.gif?version=1&modificationDate=1369273396065" data-image-src="/download/attachments/231080044/indent.gif?version=1&modificationDate=1369273396065" data-linked-resource-id="231375317" data-linked-resource-type="attachment" data-linked-resource-default-alias="indent.gif" data-base-url="http://docs.codehaus.org" data-linked-resource-container-id="231080044" title="null > indent.gif"></p> <h3>Quick suffix switching</h3> <p>It is simple to convert from a <code>.java</code> file to a <code>.groovy</code> file and back using the context menu:</p> <p><img class="confluence-embedded-image confluence-content-image-border image-center" src="/download/attachments/231080044/convert_file.gif?version=1&modificationDate=1369273396041" data-image-src="/download/attachments/231080044/convert_file.gif?version=1&modificationDate=1369273396041" data-linked-resource-id="231375316" data-linked-resource-type="attachment" data-linked-resource-default-alias="convert_file.gif" data-base-url="http://docs.codehaus.org" data-linked-resource-container-id="231080044" title="null > convert_file.gif"></p> <h3>Organize imports</h3> <p>The Groovy editor supports automatic organizing of imports (CTRL-Shift-O or CMD-Shift-O). Or you can set your project to automatically organize on save through the project properties page:</p> <p><img class="confluence-embedded-image confluence-content-image-border image-center" src="/download/attachments/231080044/cleanup1.gif?version=1&modificationDate=1369273395973" data-image-src="/download/attachments/231080044/cleanup1.gif?version=1&modificationDate=1369273395973" data-linked-resource-id="231375313" data-linked-resource-type="attachment" data-linked-resource-default-alias="cleanup1.gif" data-base-url="http://docs.codehaus.org" data-linked-resource-container-id="231080044" title="null > cleanup1.gif"></p> <p>Note that only <em>Remove unused imports</em>, format on save, and indent on save are respected in Groovy editors. All other cleanup options are ignored.</p> <h1>Issues addressed for M1</h1> <p>We have fixed over 130 issues for this milestone release:</p> <img class="editor-inline-macro" src="/plugins/servlet/confluence/placeholder/macro?definition=e2ppcmFpc3N1ZXM6dGl0bGU9SXNzdWVzIGFkZHJlc3NlZCBmb3IgTTF8Y29sdW1ucz10eXBlO2tleTtzdW1tYXJ5fHVybD1odHRwOi8vamlyYS5jb2RlaGF1cy5vcmcvc3IvamlyYS5pc3N1ZXZpZXdzOnNlYXJjaHJlcXVlc3QteG1sLzEzNDc2L1NlYXJjaFJlcXVlc3QtMTM0NzYueG1sP3RlbXBNYXg9MTAwMH0&locale=en_GB&version=2" data-macro-name="jiraissues" data-macro-parameters="columns=type;key;summary|title=Issues addressed for M1|url=http://jira.codehaus.org/sr/jira.issueviews:searchrequest-xml/13476/SearchRequest-13476.xml?tempMax\=1000">
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