Upgrade to a new version of gradle

cbeams edited this page Jan 24, 2011 · 3 revisions

These instructions are in two sections: first, how to update the version of Gradle globally within the shared gradle sources. Second, how to update individual projects to depend on that new buildSrc version, and thus use the new version of gradle.

The Gradle wrapper configuration is stored within the buildSrc directory at buildSrc/wrapper.gradle. This means that changes to the version of Gradle to use for the wrapper have a global effect -- all projects using the shared buildSrc directory will upgrade their Gradle version automatically whenever they update to the latest revision of the shared buildSrc directory. This is generally considered a good thing, given that Gradle remains faithful to backward-compatibility.

Steps for upgrading the shared Gradle version

Note that these steps could be done against a dedicated clone of the spring-build-gradle project, but I prefer to do it within the context of a project that includes spring-build-gradle as a buildSrc directory. This makes it easier to verify the changes, but it does require a couple extra steps in order to be able to push the changes back.

Note that you'll need to have commit rights to the spring-build-gradle project. If you don't already, ask an admin.

We'll use spring-integration as an example project that uses the shared sources.

  1. git clone git@git.springsource.org:spring-integration/spring-integration.git
  2. cd spring-integration
  3. ./gradlew --version to verify the current version in use. Let's say it's 0.9 GA, and we want to upgrade to 0.9.1 GA.
  4. cd buildSrc
  5. git co master
  6. git pull to make sure you have the very latest changes locally
  7. vi wrapper.gradle and change gradleVersion from 0.9 to 0.9.1
  8. cd .. && ./gradlew wrapper
  9. ./gradlew --version to verify the change. The new Gradle version (0.9.1) should download.
  10. cd buildSrc
  11. git ci -am'Upgrade to Gradle 0.9.1 GA'
  12. we want to push this change remote now, but first you'll need to make sure you have a pushUrl specified in your git config. vi .git/config and make the "origin" section look like the following:
[remote "origin"]
    fetch = +refs/heads/*:refs/remotes/origin/*
    url = git://github.com/SpringSource/spring-build-gradle.git
    pushUrl = git@github.com:SpringSource/spring-build-gradle.git
  1. git push

The version of Gradle has now been upgraded for the shared sources.

Steps for upgrading individual projects to use a new version of the Shared gradle sources

The next step is to update projects to depend on that new version of the shared sources, so that they start using the new version of Gradle. We'll continue with Spring Integration as an example.

After doing a git pull from a spring-integration repository, you should now see the following:

$ git pull
$ git status
# On branch master
# Changed but not updated:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#       modified:   buildSrc (new commits)

This status message is telling you that there have been changes to the shared Gradle sources, but you're not yet using them.

In order to use them, do the following:

  1. cd buildSrc
  2. git checkout master
  3. git pull
  4. cd ..
  5. ./gradlew --version and you should notice that you're now on the new version (0.9.1) as in the example above.
  6. git status and you should see the same message as earlier: modified: buildSrc (new commits)
  7. git add buildSrc && git commit -m"Update to latest buildSrc" && git push

The project has now been updated to the latest shared Gradle sources.