These days, I use gradle as build system in all of my projects. More precisely, I use the gradle wrapper, as it makes installation even more easy. You don’t even have to have gradle installed, Java is enough. The wrapper is a shell or bash script, depending on the OS, and downloads gradle along with all dependencies on execution. This makes the gradle wrapper very convenient for developing command-line tools, which is what most of my projects are at the moment.
I also like to integrate my projects with Travis CI, a free continuous integration environment for open source projects. Travis CI is quite powerful, but I also found it to be quite hard to get working properly, due to non-intuitive error messages I got for my builds. Nevertheless, it helps you to get rid of any environment-specific configuration and thus makes sure that somebody who checks out your project can get it running very easily. Essentially, you add a file named
.travis.yml to your project in which you describe your build and then link your project with Travis CI.
So far, Travis CI worked easily with the gradle wrapper. Today, however, I upgraded gradle to 1.8 for several projects and mysteriously builds started to fail. Even older builds, that were fine with Travis CI at the time suddenly produced errors on repetition. I haven’t looked deeper at what changed on Travis’ side, but it seems that they did work on the gradle wrapper integration a few days ago and that supposedly broke my builds. The builds suddenly produced this error:
/home/travis/build.sh: line 41: ./gradlew: Permission denied The command "./gradlew assemble" failed. Retrying, 2 of 3.
Huh, what happen to the execution permissions of the gradle wrapper? The only source that I could find that reported a similar problem was this blog post. The solution there was to explicitly set the execution permissions for the wrapper before the execution of the tests. This didn’t work for me, as my build failed even before, when trying to get the dependencies, aka the
assemble step. So, I had to set the permissions before this step, and the build worked again. Setting permissions works with the well-known
chmod executed with a specific hook, named
before_install. As a summary, here is a working
.travis.yml file for one of my projects:
language: java jdk: - oraclejdk7 - openjdk7 before_install: - chmod +x gradlew
And my builds are nice and green again.