Skip to content

Instantly share code, notes, and snippets.

@JMBattista
Last active April 24, 2018 17:31
Show Gist options
  • Save JMBattista/f1ade1921d678695d300 to your computer and use it in GitHub Desktop.
Save JMBattista/f1ade1921d678695d300 to your computer and use it in GitHub Desktop.
Upgrade Gradle Codeship
#!/bin/bash
# Allows using different Gradle versions with http://codeship.io
#
# As @altfatterz points out below this isn't necessary if you choose to check in your .gradle and gradlew.bat/gradlew.sh files.
# I prefer not to check-in the generated files so I set this up.
#
# We update the path here instead of via the environment variables because you cannot control the order
# that environment variables are set in the Environment tab, and this results in the path NOT having the version number
# see test_commands for info on how to run gradle without settings the path here if you want to avoid it.
#
# Codeship defaults to jdk7, so you may also want to run the following command to switch to jdk8
# jdk_switcher use oraclejdk8
PATH=$GRADLE_HOME/bin:$PATH
wget -N $GRADLE_URL
mkdir -p ~/gradle
unzip $GRADLE.zip -d ~
#!/bin/bash
# If you don't want to update the path as part of the setup commands you can instead call gralde using:
# $GRADLE_HOME/bin/gradle check --info
# I prefer to update the path and simplify the
gradle check --info
# We set the GRADLE_VERSION as its own environment variable here as it gets referenced in two places.
# This allows us to easily upgrade our gradle version. (Tested going from 2.1 to 3.1)
GRADLE_VERSION=3.1
GRADLE_HOME=/home/rof/gradle-$GRADLE_VERSION
GRADLE=gradle-$GRADLE_VERSION-bin
GRADLE_URL=https://services.gradle.org/distributions/$GRADLE.zip
@RyanMarcus
Copy link

Still working as of December 10th, 2014 -- thanks!

@altfatterz
Copy link

With the new dependency cache
http://blog.codeship.com/dependency-cache-sphinx-codeship/
the zip will be downloaded each time.
Why not use the gradle wrapper approach? Although with this is as well, the ~/.gradle is not kept

@kubukoz
Copy link

kubukoz commented Sep 4, 2015

For future users: remember that Codeship uses Java 7 by default.
use
jdk_switcher use oraclejdk8
to change it to Java 8.

@leosilvadev
Copy link

Great! It really helped me here, thanks!

@geld0r
Copy link

geld0r commented Sep 25, 2016

Still works for Gradle 3.1 (if version is adjusted in command). Thanks!

@geld0r
Copy link

geld0r commented Jun 15, 2017

Still works for Gradle 4.0.
Add --console=plain to your gradle command to generate console output that is readable as this was changed in gradle 4.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment