Building a Groovy project

What This Guide Covers #

For Language versions and other build-environment specific information visit 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 Tutorial and build configuration guides first.

Groovy builds are not available on the macOS 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/

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

Using Java 10 and Up #

For testing with OpenJDK and OracleJDK 10 and up, see Java documentation.

Build Config Reference #

You can find more information on the build config format for Groovy in our Travis CI Build Config Reference.