Skip to end of metadata
Go to start of metadata

Downloading, Installing and Running

In this section we look at how to get up and running with Groovy.

Download

In this download area, you will be able to download the distribution (binary and source), the Windows installer (for some of the versions) and the documentation for Groovy.

For a quick and effortless start on Mac OSX, Linux or Cygwin, you can use GVM (the Groovy enVironment Manager) to download and configure any Groovy version of your choice. Basic instructions can be found below.

Groovy 2.4

Groovy 2.4 is currently in beta testing. If you want a stable version, please choose Groovy 2.3 which is our latest official version of Groovy.

Groovy 2.4.0-beta-4

Download zipBinary Release | Source Release
Download documentation: JavaDoc and zipped online documentation
Combined binary / source / documentation bundle: Distribution bundle
 

You can have a look at the JIRA release notes.

If you plan on using invokedynamic support, read those notes.

Groovy 2.3

Groovy 2.3 is our latest official version of Groovy.

Groovy 2.3.8

Download zipBinary Release | Source Release
Download Windows-Installer: Binary Release (Module Versions)
Download documentation: JavaDoc and zipped online documentation
Combined binary / source / documentation bundle: Distribution bundle
 

You can have a look at the JIRA release notes.

If you plan on using invokedynamic support, read those notes.

Groovy 2.3.7

Download zipBinary Release | Source Release
Download Windows-Installer: Binary Release (Module Versions)
Download documentation: JavaDoc and zipped online documentation
Combined binary / source / documentation bundle: Distribution bundle
 

You can have a look at the JIRA release notes.

If you plan on using invokedynamic support, read those notes.

Groovy 2.3.6

Download zipBinary Release | Source Release
Download Windows-Installer: Binary Release (Module Versions)
Download documentation: JavaDoc and zipped online documentation
Combined binary / source / documentation bundle: Distribution bundle
 

You can have a look at the JIRA release notes.

If you plan on using invokedynamic support, read those notes.

Groovy 2.3.4

Download zipBinary Release | Source Release
Download Windows-Installer: Binary Release (Module Versions)
Download documentation: JavaDoc and zipped online documentation
Combined binary / source / documentation bundle: Distribution bundle
 

You can have a look at the JIRA release notes.

If you plan on using invokedynamic support, read those notes.

Groovy 2.2

Groovy 2.2 is our previous official version of Groovy.

Learn more about Groovy 2.2 in the release notes.

Groovy 2.2.2

Download zipBinary Release | Source Release
Download Windows-Installer: Binary Release (Module Versions)
Download documentation: JavaDoc and zipped online documentation
Combined binary / source / documentation bundle: Distribution bundle
 

You can have a look at the JIRA release notes.

If you plan on using invokedynamic support, read those notes.

Groovy 2.1

Learn more about Groovy 2.1 in the release notes.

Groovy 2.1.9

Download zipBinary Release | Source Release
Download Windows-Installer: Binary Release (Module Versions)
Download documentation: JavaDoc and zipped online documentation
Combined binary / source / documentation bundle: Distribution bundle

You can have a look at the JIRA release notes.

If you plan on using invokedynamic support, read those notes.

Groovy 2.0

Groovy 2.0 is the minor version before Groovy 2.1.

Learn more about Groovy 2.0 in the release notes.

Groovy 2.0.8

Download zipBinary Release | Source Release
Download documentation: JavaDoc and zipped online documentation
Combined binary / source / documentation bundle: Distribution bundle

You can have a look at the JIRA release notes.

If you plan on using invokedynamic support, read those notes.

Groovy 1.8 (Maintenance Release)

Groovy 1.8 is the latest maintenance release branch of the Groovy 1 major version.

Learn more about the Groovy 1.8 in the release notes.

Groovy 1.8.9

Download zipBinary Release | Source Release
Download documentation
JavaDoc and zipped online documentation

You can have a look at the JIRA release notes.

Snapshots

For those who want to test the very latest versions of Groovy and live on the bleeding edge, you can use our snapshot builds. As soon as a build succeeds on our continuous integration server a snapshot is deployed to Artifactory's OSS snapshot repository.

Older Releases

All maintenance of the Groovy 1.5.X, 1.6.X and 1.7.X series has now stopped. These are the last released versions.

Groovy 1.7.11

Download zipBinary Release | Source Release
Download documentationJavaDoc and zipped online documentation

You can have a look at the JIRA release notes.

Groovy 1.6.9

Download zip: Binary Release (JDK 1.4 version) | Source Release
Download documentation: JavaDoc and zipped online documentation

You can have a look at the JIRA release notes.

Groovy 1.5.8

Download zip: Binary Release | Source Release
Download Windows-Installer: Binary Release
Download unofficial Fedora/RHEL/CentOS package: Binary Release | Source Release
Download documentation: JavaDoc and zipped online documentation

The release notes are Release Notes.

Legacy Groovy 1.0

If you still need to use the old Groovy 1.0, here are the links you may be interested in:

Download zip: Binary Release | Source Release
Download unofficial Ubuntu/Debian package: Binary Release
Download Windows-Installer: Binary Release
Download tar/gz: Binary Release | Source Release
Download Javadoc: Javadoc zip

Once you've downloaded the distribution, please read the installation instructions.

Other versions can be found in the distributions archive.

Maven Repositories

If you wish to embed Groovy in your application, you may just prefer to point to your favourite maven repositories or the codehaus maven repository. You should consult the individual pom files for the exact details but here is a summary of the main supported artifactIds and groupIds:

Groovy 2.X.Y  and newer

GradleMavenExplanation

'org.codehaus.groovy:groovy:x.y.z'

<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy</artifactId>
<version>x.y.z</version>

Just the core of groovy without the modules (see below). Treats Antlr, ASM, etc. as standard dependencies. Only useful if you happen to also use the same versions of these jars yourself as it will save you having two copies of these jars.
'org.codehaus.groovy:groovy-$module:x.y.z' 

<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-$module</artifactId>
<version>x.y.z</version>

"$module" stands for the different optional groovy modules "ant", "bsf", "console", "docgenerator", "groovydoc", "groovysh", "jmx", "json", "jsr223", "servlet", "sql", "swing", "test", "testng" and "xml". Example: <artifactId>groovy-sql</artifactId>

'org.codehaus.groovy:groovy-all:x.y.z'

<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>x.y.z</version>

The core plus all the modules. Also includes jarjar versions of Antlr, ASM, Commons-CLI and Retrotranslator runtime. Allows you or your other dependencies (e.g. Hibernate) to use other versions of these jars. Optional dependencies are marked as optional. You may need to include some of the optional dependencies to use some features of Groovy, e.g. AntBuilder, GroovyMBeans, etc.

To use the InvokeDynamic version of the jars just append ':indy' for Gradle or <classifier>indy</classifier> for Maven.

Groovy 1.6.X - 1.8.X

GradleMavenExplanation

'org.codehaus.groovy:groovy:x.y.z'

<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy</artifactId>
<version>x.y.z</version>

Treats Antlr, ASM, etc. as standard dependencies. Only useful if you happen to also use the same versions of these jars yourself as it will save you having two copies of these jars. Optional dependencies are marked as optional. You may need to include some of the optional dependencies to use some features of Groovy, e.g. AntBuilder, GroovyMBeans, etc.
'org.codehaus.groovy:groovy-all:x.y.z'

<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>x.y.z</version>

Includes jarjar versions of Antlr, ASM, Commons-CLI and Retrotranslator runtime. Allows you or your other dependencies (e.g. hibernate) to use other versions of these jars. Optional dependencies are marked as optional. You may need to include some of the optional dependencies to use some features of Groovy, e.g. AntBuilder, GroovyMBeans, etc.

Groovy 1.1.X - 1.5.X

GradleMavenExplanation
'org.codehaus.groovy:groovy:x.y.z'

<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy</artifactId>
<version>x.y.z</version>

Treats Antlr and ASM as standard dependencies. Only useful if you happen to also use the same versions of these jars yourself as it will save you having two copies of these jars. Optional dependencies are marked as optional. You may need to include some of the optional dependencies to use some features of Groovy, e.g. AntBuilder, GroovyMBeans, etc.
'org.codehaus.groovy:groovy-all:x.y.z'

<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>x.y.z</version>

Includes jarjar versions of Antlr, ASM and Commons-CLI. Allows you or your other dependencies (e.g. hibernate) to use other versions of these jars. Optional dependencies are marked as optional. You may need to include some of the optional dependencies to use some features of Groovy, e.g. AntBuilder, GroovyMBeans, etc.
'org.codehaus.groovy:groovy-all-minimal:x.y.z'

<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all-minimal</artifactId>
<version>x.y.z</version>

Includes jarjar versions of Antlr and ASM. Does not include Commons-CLI or any optional dependencies. Not suitable by itself if you want to use any tools which do command-line processing, e.g. groovyc, GroovyShell, ...

Groovy 1.0

Available in the Maven 1 and Maven 2 repositories.

GradleMavenExplanation
'groovy:groovy:x.y.z'

<groupId>groovy</groupId>
<artifactId>groovy</artifactId>
<version>1.0</version>

Treats Antlr and ASM as standard dependencies. Only useful if you happen to also use the same versions of these jars yourself as it will save you having two copies of these jars. Dependencies mandated for all optional parts of Groovy, e.g. AntBuilder, GroovyMBeans, etc.
'groovy:groovy-all:x.y.z'

<groupId>groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>1.0</version>

Includes jarjar versions of Antlr and ASM. Allows you or your other dependencies (e.g. hibernate) to use other versions of these jars. Dependencies mandated for all optional parts of Groovy, e.g. AntBuilder, GroovyMBeans, etc.
'groovy:groovy-all-minimal:x.y.z'

<groupId>groovy</groupId>
<artifactId>groovy-all-minimal</artifactId>
<version>1.0</version>

Includes jarjar versions of Antlr and ASM. Does not include any optional dependencies.

For historical purposes, the releases candidates for 1.0 are also available by using the appropriate version instead of 1.0 in the above version tag.

Snapshot Releases

In addition to the stable and milestone releases you can find intermediate SNAPSHOT releases at the codehaus snapshot maven repository.

GVM (the Groovy enVironment Manager)

This tool makes installing Groovy on any Bash platform (Mac OSX, Linux, Cygwin, Solaris or FreeBSD) very easy.

Simply open a new terminal and enter:

$ curl -s get.gvmtool.net | bash

Follow the instructions on-screen to complete installation.

Open a new terminal or type the command:

$ source "$HOME/.gvm/bin/gvm-init.sh"

Then install the latest stable Groovy:

$ gvm install groovy

After installation is complete and you've made it your default version, test it with:

$ groovy -version

That's all there is to it!

Other ways to get Groovy

If you're on MacOS and have Homebrew installed, you can run "brew install groovy" to install Groovy.

If you're on MacOS and have MacPorts installed, you can run "sudo port install groovy" to install the latest Groovy release.

If you're on Windows, you can also use the NSIS Windows installer.

You may download other distributions of Groovy from this site.

If you prefer to live on the bleeding edge, you can also grab the source code from SVN.

If you are an IDE user, you can just grab the latest IDE plugin and follow the plugin installation instructions.

System Requirements

Groovy BranchJVM Required (non-indy)JVM Required (indy) *
1.0 - 1.51.4N/A
1.6 - 1.81.5N/A
2.0 - 2.21.51.7
2.3 - current1.61.7

* If you plan on using invokedynamic support, read those notes.

 

Installing

These instructions describe how to install a binary distribution of Groovy.
  • first, Download a binary distribution of Groovy and unpack it into some file on your local file system
  • set your GROOVY_HOME environment variable to the directory you unpacked the distribution
  • add GROOVY_HOME/bin to your PATH environment variable
  • set your JAVA_HOME environment variable to point to your JDK. On OS X this is /Library/Java/Home, on other unixes its often /usr/java etc. If you've already installed tools like Ant or Maven you've probably already done this step.

You should now have Groovy installed properly. You can test this by typing the following in a command shell:

Which should create an interactive groovy shell where you can type Groovy statements. Or to run the Swing interactive console type:

To run a specific Groovy script type:

Alternative Installation on Mac OSX, Linux or Cygwin

For a quick and effortless start on Mac OSX, Linux or Cygwin, you can use GVM (the Groovy enVironment Manager) to download and configure any Groovy version of your choice. Basic instructions can be found here.

 

Running

Groovy scripts are a number of statements and class declarations in a text file. Groovy scripts can be used similarly to other scripting languages. There are various ways of running Groovy scripts

Using the interactive console

Groovy has a Swing interactive console that allows you to type in commands and execute them rather like using an SQL query tool. History is available and such like so you can move forwards and backwards through commands etc.

If you install a binary distribution of Groovy then you can run the Groovy Swing console by typing this on the command line.

For a command line interactive shell type

To see how to add things to the classpath see below.

Running Groovy scripts from your IDE

There is a helper class called GroovyShell which has a main(String[]) method for running any Groovy script. You can run any groovy script as follows

You can then run the above Groovy main() in your IDE to run or debug any Groovy script.

Running Groovy scripts from the command line

There are shell scripts called 'groovy' or 'groovy.bat' depending on your platform which is part of the Groovy runtime.
Once the runtime is installed you can just run groovy like any other script...

If you are using Groovy built from CVS Head (after Beta-5, see below if you want to upgrade), apart from Groovy scripts, you may also now run different kind of classes from the command-line.

  • Classes with a main method of course,
  • Classes extending GroovyTestCase are run with JUnit's test runner,
  • Classes implementing the Runnable interface are instanciated either with a constructor with String[] as argument, or with a no-args constructor, then their run() method is called.

To work from the latest and greatest Groovy see Building Groovy from Source. Once built you'll then have a full binary distribution made for you in groovy/target/install. You can then add groovy/target/install/bin to your path and you can then run groovy scripts easily from the command line.

To see how to add things to the classpath see below.

Creating Unix scripts with Groovy

You can write unix scripts with Groovy and execute them directly on the command line as if they were normal unix shell scripts. Providing you have installed the Groovy binary distribution (see above) and 'groovy' is on your PATH then the following should work.

The following is a sample script, which you should copy and save as helloWorld.groovy.

Then to run the script from the command line, just make sure the script is executable then you can call it.

Note that you will not be able to provided any arguments to groovy when running with the shebang(#!) on Linux because the arguments are treated as part of the name of the command to run. Mac OS X will interpret additional arguments correctly.

Adding things to the classpath

When running command line scripts or interactive shells you might want to add things to your classpath such as JDBC drivers or JMS implementations etc. To do this, you have a few choices:

  • Add things to your CLASSPATH environment variable
  • Pass -classpath (or -cp) into the command you used to create the shell or run the script
  • It's also possible to create a ~/.groovy/lib directory and add whatever jars you need in there.
  • If the jars you need are in a Maven or Ivy repository, you can "grab" them with Grape.

Increasing Groovy's JVM Heap Size

To increase the amount of memory allocated to your groovy scripts, set your JAVA_OPTS environment variable. JAVA_OPTS="-Xmx..."

Avoiding PermGen out of memory

Groovy creates classes dynamically, but the default Java VM does not GC the PermGen. If you are using Java 6 or later, add -XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC. UseConcMarkSweepGC is needed to enable CMSClassUnloadingEnabled.


Groovy and the Cloud

Groovy can run anywhere the JVM runs - including many cloud platforms, likewise, continuous integration is just as easy. You can kick the tyres at CloudBees for hosting your groovy app, this quick start will get you going (with the correct settings and permgen):

This will setup a CI job (running tests and build, in Jenkins) and deploy the "pet store" app that uses the grails "pet store" demo app (you can use it for free). Prefer to set it up yourself, read here for details.



  • No labels