Skip to content

Catalog of Features

Eric Milles edited this page Oct 2, 2024 · 25 revisions

The Groovy Development Tools (GDT) aim to provide many of the same features and conveniences offered by the Java Development Tools (JDT). In most respects, GDT should be seen as an extension of JDT, much like Groovy is an extention of Java.

Java Builder Integration

Project Nature

An existing Java Project can gain Groovy support simply by adding the Groovy Nature. This can be done by right-clicking on the project and selecting Configure > Convert to Groovy Project or by adding the nature using the new Project Natures panel of the project settings view. From this point on, when Java sources are built, the Java Builder will also process Groovy sources it finds in the project's source folders. Groovy and Java sources may be inter-mixed within a source folder or Java package.

Content Types

GDT adds extensions to the Java Source File (*.java) content type. The Groovy Source File (*.groovy) content type is seen as both Groovy and Java (for Java Builder integration) and will open in the Groovy Editor by default. The Gradle Build File (*.gradle) is added as well so Groovy DSL of Gradle scripts can be associated with the Groovy Editor as well. Note: This should not interfere with Buildship (Eclipse Gradle Tooling) functionality.

These and other content types can be viewed and edited at Window > Preferences > General > Content Types > Text.

Classpath Container

A project that has the Groovy Nature also requires a reference to the Groovy Runtime classes. This is necessary to satisfy references to core classes such as groovy.lang.GroovyObject during compilation and execution. The builder/compiler itself will use an internal copy of the Groovy Runtime library.

This requirement can be fulfilled by the Groovy Libraries classpath container. It can be added to a Groovy project by right-clicking on it and selecting Groovy > Add Groovy libraries to classpath or by using the Java Build Path panel of the project settings view. Choose Add Library..., select Groovy Runtime Libraries, click Next, proceed through the prompts and lastly click Apply.

Groovy Libraries container

The Groovy Libraries classpath container provides linked sources/javadoc for the internal libraries and supports the standard JDT container attributes, including Build Access Rules, External Annotations, etc. Alternatively, Groovy Runtime classes can be supplied using Gradle, Maven, Ivy or the JDT Referenced Libraries classpath container (aka via the Java Build Path panel).

Internal/External Libraries and the Minimal attribute

By default, GDT will populate the Groovy Libraries with all jars embedded in the runtime bundle (groovy-all-2.3.11.jar, servlet-api-2.4.jar, ivy-2.4.0.jar and bsf-2.4.0.jar for example), as well as all jars located in the user's .groovy/lib directory. This can be limited to just the Groovy Runtime jar by setting attributes on the classpath container. Right-click on Groovy Libraries and choose Properties to see the following options:

Groovy Libraries properties

Compiler Configuration

Support for per-project compiler config scripts is available. This allows addition of new "default" imports and much more; see http://www.groovy-lang.org/dsls.html#compilation-customizers.

Groovy compiler configuration script

Compiler Errors/Warnings

Due to the tight integration of the GDT and JDT, many of the compiler problems that can be indicated for Java code can be indicated for Groovy code as well. As always, these are configured at Window > Preferences > Java > Compiler > Errors/Warnings or the project-specific Java Compiler > Errors/Warnings page.

Navigator and Package/Project Explorer Integration

Element/Resource Icons

Thanks to the pre-defined Content Types, Groovy resources have their own file icons on the Navigator and Package/Project Explorer views. There is a bug due to the Groovy type being a child of the Java type that causes a few Groovy resources to display with Java iconography in the Project Explorer and some other views, like Synchronize.

Groovy sources support the Java element member nodes as well; enabled/disabled at Window > Preferences > Java > Appearance > Show members in Package Explorer.

Show members in Package Explorer

Label Decorations

Java element type label decorations (A, I, E, @, etc.) in the upper-right corner of the file icon are supported. Traits are given the same decoration as an interface.

Additional Groovy-specific indications are provided for scripts (circle-slash in lower-left corner) and build path issue (red exclamation in lower-left). Other decorations like source control indication are also supported.

These can be enabled/disabled at Window > Preferences > General > Appearance > Label Decorations by setting Java Type Indicator and Groovy Source File.

Conversion Commands

To enable a simple Java <=> Groovy transition, GDT adds interface commands for automatically converting a Java source to/from a Groovy one. Right-click on any Java source and select Groovy > Convert file extension to Groovy (Alt-J, G). To go back to Java, right-click on any Groovy source and select Groovy > Convert file extension to Java (Alt-G, J).

Creation Wizards

GDT provides wizards for quick creation of Groovy projects, classes, traits, interfaces, annotations, DSL descriptors and JUnit tests. They can be accessed from the main menu under File > New menu, the toolbar -- usually the leftmost button -- or the context menu of the Navigator, Package Explorer, Project Explorer and other views.

Groovy Wizards

New Groovy Project

The new project wizard accelerates the creation of a Groovy/Java project. Similar to the New Java Project wizard, you can set the name, directory, working set, Java runtime, etc. All the necessary Eclipse metadata files will be created upon clicking Finish. This includes .classpath, .project and some key prefs files in .settings/.

New Groovy Project wizard

New Groovy Type

The new type wizard accelerates the creation of Groovy types and scripts. Similar to the new Java Class wizard, you can set the source folder, package, enclosing type, name, modifiers, and so on. If package visibility is selected, the groovy.transform.PackageScope transform will be automatically applied to the new type.

New Groovy Type wizard

New Groovy Test

New Groovy Test wizard

New Groovy DSL Descriptor

See DSL Descriptors

New Groovy DSLD wizard

Groovy Editor

Syntax Coloring (aka Semantic Highlighting)

  • comments
  • keywords
  • number literals
  • string literals
  • GString expressions
  • regular expressions
  • keys in map literals
  • annotations
  • annotation attributes
  • fields
  • properties
  • parameters
  • local variables
  • constructors
  • instance methods
  • class/static methods
  • constants (static final)
  • deprecated references
  • category (aka Groovy) methods
  • dynamic/unknown references (underline)

Problem/Task Indicators

Code Folding

The Groovy Editor supports the same structure folding support as the Java Editor (methods, Javadoc comments, etc.) plus the following Groovy-specific additions:

  • multi-line closures
  • static initializers
  • top-level multi-line comments in scripts

Folding of closures and initializers

Folding of script comments and members

Context Menu additions

Find Occurrences

Code Formatter

Code Browsing

Javadoc Hover (F2)

Open Declaration/Implementation (F3 or Ctrl+click)

Content Assist

Favorites

Templates

Quick Fix and Assist

Save Actions

The Groovy Editor supports some of the same on-save actions as the Java Editor, including:

  • Format Source
  • Organize Imports
  • Remove Trailing Whitespaces

In addition, it adds one Groovy-specific on-save action:

Remove Unnecessary Semicolons

Semi-colons that are not required for the correct parsing of a Groovy source can be removed automatically on save.

Debugging

Stack Frame low-lighting

JUnit View monospace font

Searching

Call Hierarchy

Type Hierarchy

Find References

Find Declarations

Refactoring

Type Checking

Type Filters

Outline enhancements

  • Grapes
  • Script members

Outline view of script grapes and members

Run As

Groovy Console

Groovy Script

Groovy Shell

Groovy Shell

AST View

Event Console

DSL support

DSLD Preferences page

Inferencing Suggestions

DSLD Preferences page

Plugin DSLDs

Global DSLDs

Project Preferences

Groovy compiler project preferences

Compiler Version

Compiler Config Script

Script Filters

Workspace Preferences

Root preferences page

Debugger preferences page

Content Assist preferences page Formatter preferences page Groovy Templates preferences page Save Actions preferences page

Ant Integration

Maven Integration

Command-Line Integration

batch compiler

System Properties that control Greclipse

  • eclipse.groovy.debug
  • Non-locking class loader (aka greclipse.nonlocking)
  • greclipse.dsld.disabled
  • greclipse.includeServletInClasspathContainer
  • groovy.antlr4
  • ivy.message.logger.level
Clone this wiki locally