DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
The Latest "Software Integration: The Intersection of APIs, Microservices, and Cloud-Based Systems" Trend Report
Get the report
  1. DZone
  2. Coding
  3. Frameworks
  4. The Best Groovy Modules You Might Not Know About

The Best Groovy Modules You Might Not Know About

Mitch Pronschinske user avatar by
Mitch Pronschinske
·
Jan. 26, 10 · Interview
Like (0)
Save
Tweet
Share
28.55K Views

Join the DZone community and get the full member experience.

Join For Free
It's no secret that Groovy and its many related goodies are quite popular, especially at DZone where the announcement of Groovy 1.7 got 137 up votes, making it the highest rated DZone link ever!  Plenty of people have heard about the Groovy-based frameworks like Griffon and Grails, and the Gradle build system, which uses Groovy build scripts.  If you've looked at the Groovy Modules page lately, you'll see that there are a lot of other Groovy-based modules out there.  Listed below are five Groovy modules that are really great, but they haven't gotten the attention that they deserve.

GroovyWS

There is some killer Groovy support for Web Services in the Groovy WS module.  GroovyWS incorporates Apache CXF to help you quickly consume, publish, and test WS-I compliant web services.  GroovyWS can even use secured web-services.  To invoke a web service using a complex type, simply write the method's signature and its parameters, and GroovyWS will construct the proper SOAP message and invoke the remote web service during runtime.  The complex types are automatically generated from the WSDL, compiled, and made available through your classloader.  The client API provides a method to easily instantiate a complex object from its class name.  GroovyWS makes life easier by logging the names of classes that are generated on the fly.  The client-side of GroovyWS integrates seamlessly with Grails and Griffon applications.

Scriptom

This module combines the "syntactical sugar" of Groovy with the Jacob (Java COM Bridge) library to use ActiveX or COM Windows components from Groovy.  It takes advantage of Groovy's dynamic (late-bound) principles to map COM objects into Groovy objects at runtime, therefore, you don't need to know a lot about COM in order to use Scriptom.  You also don't need to deal with type-libraries and there are no wrappers to maintain.  Just code it and run it.  Scriptom got its name because it is script-like in the sense that it resembles writing code using VBScript (but with the more advanced Groovy language).  Among other things, Scriptom can be used to automate Word or Excel documents, control Internet Explorer, make your PC talk using the Microsoft Speech API, monitor processes with WMI (Windows Management Instrumentation), or browse the Windows Registry using WShell.  Talking to custom VB6 or Microsoft.NET libraries is also much easier with Scriptom.

Groovy Monkey

If you are working on automating tasks in Eclipse or doing plugin development in general, this is the tool for you!  Groovy Monkey is a branch of the Eclipse Monkey software based on the Eclipse Jobs API.  It lets users quickly try parts of the Eclipse API without the overhead of a plugin or a separate runtime instance.  It is a dynamic scripting tool for writing quick and reusable functionality (i.e. task automation) to make life easier with Eclipse.  Groovy Monkey can even be used to translate the quick and dirty work into a plugin.  Because Groovy Monkey is based on the Eclipse API, you can seamlessly monitor the progress in the platform and write scripts that users can cancel midway through.  Groovy Monkey is also based on the Apache Bean Scripting Framework (BSF) and OSGi.  BSF lets you write scripts in several languages (Beanshell, Ruby, Python), not just Groovy! (But why wouldn't you want to write in Groovy? ;-) )  The OSGI framework lets Groovy Monkey add the classloader of any bundle on the workbench to a script's classloader.  It also allows Groovy Monkey to do a white box introspection of running bundles/plugins.

Groosh

Groosh is a Unix-like shell that is written in Groovy and can be used with Grapes.  Grape is the infrastructure that enables the grab() calls in Groovy that leverage Apache Ivy, allowing a repository driven module system for Groovy.  With Grapes (@Grab), Groosh can be a powerful alternative to regular shell scripts.  Here is a simple example of Groosh in action:
//Read a text file and write it to stdout
@Grapes([
@Grab(group='org.codehaus.groovy.modules',module='groosh',version='[0.3.6,)'),
@GrabConfig(systemClassLoader=true)
])

import groosh.Groosh
Groosh.withGroosh(this)

cat('test_scripts/blah.txt') >> stdout

GroovySWT

For GUI building, Groovy has a wrapper for the Eclipse Standard Widget Toolkit (SWT).  GroovySWT let's you easily write Eclipse SWT applications right in Groovy's builder mechanism.  Using Groovy instead of Java for SWT applications can significantly reduce the amount of code needed.  Here is some SWT code using native Groovy:
import org.eclipse.swt.SWT
import org.eclipse.swt.widgets.*
import org.eclipse.swt.layout.RowLayout as Layout

def display = new Display()
def shell = new Shell(display)

shell.layout = new Layout(SWT.VERTICAL)

shell.text = 'Groovy / SWT Test'

def label = new Label(shell, SWT.NONE)
label.text = 'Simple demo of Groovy and SWT'
shell.defaultButton = new Button(shell, SWT.PUSH)
shell.defaultButton.text = ' Push Me '

shell.pack()
shell.open()

while (!shell.disposed) {
if (!shell.display.readAndDispatch()) shell.display.sleep()
}

When you run the script, this is the result:



Griffon will allow the use of GroovySWT in the very near future.
_________

Many thanks to Andres Almiray for helping me with this list.

Have you tried any of these tools yet?  Think there's another Groovy module that's more deserving of attention?  Tell us what you think, Groovy-lover.
Groovy (programming language) Standard Widget Toolkit Web Service Eclipse

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Java Concurrency: LockSupport
  • 10 Things to Know When Using SHACL With GraphDB
  • 4 Best dApp Frameworks for First-Time Ethereum Developers
  • Building a REST API With AWS Gateway and Python

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: