Upgrade to a new version of gradle
Clone this wiki locally
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.
git clone email@example.com:spring-integration/spring-integration.git
./gradlew --versionto verify the current version in use. Let's say it's 0.9 GA, and we want to upgrade to 0.9.1 GA.
git co master
git pullto make sure you have the very latest changes locally
vi wrapper.gradleand change
cd .. && ./gradlew wrapper
./gradlew --versionto verify the change. The new Gradle version (0.9.1) should download.
git ci -am'Upgrade to Gradle 0.9.1 GA'
- 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/configand 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 = firstname.lastname@example.org:SpringSource/spring-build-gradle.git
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:
git checkout master
./gradlew --versionand you should notice that you're now on the new version (0.9.1) as in the example above.
git statusand you should see the same message as earlier:
modified: buildSrc (new commits)
git add buildSrc && git commit -m"Update to latest buildSrc" && git push
The project has now been updated to the latest shared Gradle sources.