Allow custom Gradle versions to be specified in travis.yml

I use Travis CI to build and deploy my Java applications. I use Gradle as my build tool, and use Java 11. Travis CI has built-in support for Java 11 through specifiying jdk: oraclejdk11, however, the minimum Gradle version required to support JDK 11 is Gradle 5.0. Currently, the preinstalled Gradle version on the Trusty image is 4.0 and the preinstalled version on the Xenial image is 4.10.2. Currently, to use Gradle 5.0 or any custom gradle version, I have to manually install it by adding this to my .travis.yml:

before_install:
  - wget http://services.gradle.org/distributions/gradle-5.3-bin.zip
  - unzip -qq gradle-5.3-bin.zip
  - export GRADLE_HOME=$PWD/gradle-5.3
  - export PATH=$GRADLE_HOME/bin:$PATH
  - gradle -v

It would be great if I could just specify a Gradle version like this:

gradle: 5.3

And Travis would install the correct version of Gradle before beginning the build. This would make using Travis easier for many Java developers.

Imprint