A gradlew script gradlew not required to create a Gradle project in Travis CI.
Probably the best alternative is to use the pre-installed Gradle to install the Gradle wrapper. Here's what a simple build.gradle looks like:
apply plugin: 'java' check.doFirst { println "Running gradle v${project.gradle.gradleVersion}" } task wrapper(type: Wrapper) { gradleVersion = '3.4.1' }
If you use this build file with the standard Travis handle, this will not work. It will just use gradle to start your build. However, if you added a shell task to the handle:
language: java jdk: - oraclejdk8 before_install: gradle wrapper
First, Travis runs the shell task, and then correctly detects that gradlew present, and use it to start the build.
However, this approach has a flaw that could disrupt your build. If you use some functions in Gradle that were implemented after the preinstalled version of Gradle, the gradle wrapper step will fail. An example of such a function is the S3 maven repository, which was introduced in version 2.4. I suppose.
To prevent this, you can transfer the shell task to a separate assembly file, say wrapper.gradle :
task wrapper(type: Wrapper) { gradleVersion = '3.4.1' }
And change the .travis.yml file to:
language: java jdk: - oraclejdk8 before_install: gradle -b wrapper.gradle wrapper
That should do it. This installation uses the pre-installed Gradle to install the shell without changing the main assembly script.
You can see the build example here and this is the entire GitHub repository .
Note. There is another way. You can use the before_install step to install the required version of Gradle from a download distribution, or possibly using the Debian package system. However, this requires sudo privileges. Such virtual machines take a lot of time (about 30 seconds?).
Another thing, I mentioned this in a comment on another answer, if you pass a gradlew script, you also need banners and shell properties. An ATM is a binary file, and its inclusion in version control is sometimes seen as contradictory. Therefore, if you use the solution described above, you can also omit gradle folder.