Building a Groovy project

What This Guide Covers

Language versions and other build-environment specific information are in our reference pages:

The rest of this guide covers configuring Groovy projects on Travis CI. If you’re new to Travis CI please read our Getting Started and build configuration guides first.

Groovy builds are not available on the OS X environment.

Overview

The Travis CI environment contains various versions of OpenJDK, Oracle JDK, Gradle, Maven and Ant, along with reasonable defaults, so quite often you won’t have to configure anything beyond:

language: groovy

Projects Using Gradle

Gradle Dependency Management

If your project has build.gradle file in the repository root, Travis CI runs:

gradle assemble

to install your project’s dependencies.

Gradle Default Test Command

If your project has build.gradle file in the repository root, Travis CI runs:

gradle check

Gradle Caching

A peculiarity of dependency caching in Gradle means that to avoid uploading the cache after every build you need to add the following lines to your .travis.yml:

before_cache:
  - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
cache:
  directories:
    - $HOME/.gradle/caches/
    - $HOME/.gradle/wrapper/

Gradle daemon is disabled by default

As recommended by the Gradle team, the Gradle daemon is disabled by default. If you would like to run gradle with daemon, add --daemon to the invocation.

Projects Using Maven

Maven Dependency Management

If your project has pom.xml file in the repository root and does not have a build.gradle, Travis CI uses Maven 3 to install your project’s dependencies:

mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V

Maven Default Test Command

If your project has pom.xml file in the repository root and does not have a build.gradle, Travis CI uses Maven 3 to run your build script:

mvn test -B

Projects Using Ant

Ant Default Test Command

If Groovy project does not have Gradle or Maven configuration files, Travis CI uses Ant to build your project:

ant test

Ant Dependency Management

Because there is no single standard way of installing project dependencies with Ant you need to specify a custom command using the install: key in your .travis.yml:

language: groovy
install: ant deps

Testing Against Multiple JDKs

To test against multiple JDKs, use the :jdk key in .travis.yml. For example, to test against Oracle JDK 8 and OpenJDK 7:

jdk:
  - oraclejdk8
  - openjdk7

Build Matrix

For Groovy projects, env and jdk can be given as arrays to construct a build matrix.