-
Notifications
You must be signed in to change notification settings - Fork 193
Catalog of Features
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.
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.
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.
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.
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).
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:
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.
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.
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.
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.
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).
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.
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/
.
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.
See DSL Descriptors
- 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)
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
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:
Semi-colons that are not required for the correct parsing of a Groovy source can be removed automatically on save.
- Grapes
- Script members
eclipse.groovy.debug
- Non-locking class loader (aka
greclipse.nonlocking
) greclipse.dsld.disabled
greclipse.includeServletInClasspathContainer
groovy.antlr4
ivy.message.logger.level