Automatic dependency update detection with Gradle

Gradle has the possibility to check if the libraries used by your project has a new version. In order to use the feature, you need to add following elements to your Gradle configuration:

buildscript {
   dependencies {
        classpath 'com.github.ben-manes:gradle-versions-plugin:0.17.0'

apply plugin: 'com.github.ben-manes.versions'


After configuring the project, you can start the following command to get the update info:

gradlew dependencyUpdates -Drevision=release

It lists the dependencies and possible newer versions.

What I learned

  • Be careful, with the result of dependencyUpdates, while it is not hundred percent accurate.
  • It also can happen, that there are indirect dependencies between your libraries. In case of you need to get detailed information about the dependency hierarchy, you can use Gradle’s dependency tree command:  gradlew dependencies”
    Unfortunately at the time of writing this post, there is no Eclipse support for the hierarchy tree.
  • Sometimes it is not even possible to use the latest version of a library. For example in case of Powermock, you need to check the compatibility page first
  • Due to indirect dependencies, it is not always possible to change to the latest version of a library directly. Simple defining the latest version can cause problems in Eclipse build or in the Gradle build process.In order to solve the problem, you need to exclude previous version of a given library used by another one. Excluding in Gradle looks like this:
    compile('org.springframework.boot:spring-boot-starter-test') {
        exclude group: 'org.mockito', module: 'mockito-core'


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s