Skip to content

Setup

This guide will help you set up refreshVersions in a Gradle project.

Update Gradle (if needed)

Only Gradle 6.3+ is supported at the moment, because there were a lot of changes in dependencies management in Gradle 6, and other compatibility concerns. It also allows for a simpler setup for plugins for example.

Updating Gradle is anyway usually a good idea. You get fewer bugs, more features, and faster builds.

Run this command to update:

./gradlew wrapper --gradle-version 6.9

You should also try to update the Gradle plugins present in your build to the latest version. For example on an Android project, do update the version of the Gradle Android Plugin.

The Gradle documentation has detailed migration guide if you are stuck:

Add the plugin

Here is how to configure gradle refreshVersions:

plugins {
    // See https://jmfayard.github.io/refreshVersions
    id("de.fayard.refreshVersions") version "0.23.0"
}
plugins {
    // See https://jmfayard.github.io/refreshVersions
    id 'de.fayard.refreshVersions' version '0.23.0'
}

If you have a buildSrc module

If you use the buildSrc module and have dependencies declared in the buildSrc/build.gradle[.kts] file, you probably want to use refreshVersions there as well. The setup is the same:

pluginManagement {
    plugins {
        id("de.fayard.refreshVersions") version "0.23.0"
    }
}

plugins {
    id("de.fayard.refreshVersions")
}
pluginManagement {
    plugins {
        id 'de.fayard.refreshVersions' version '0.23.0'
    }
}

plugins {
    id 'de.fayard.refreshVersions'
}

If you use Groovy DSL, i.e. build.gradle files (not kts)

Auto-completion for dependency notations won’t work out of the box.

A workaround is to configure the plugin in the buildSrc module (create the directory if it doesn’t exist yet):

pluginManagement {
    plugins {
        id 'de.fayard.refreshVersions' version '0.23.0'
    }
}

plugins {
    id 'de.fayard.refreshVersions'
}

If you have a composite/included build

Sharing used versions with included builds is not supported at the moment.

If you need/want this feature, please vote with a 👍 on this issue, subscribe to it, and tell us about your use case, to help us prioritize.

If you want to use a snapshot version

pluginManagement {
    repositories {
        gradlePluginPortal()
        maven("https://s01.oss.sonatype.org/content/repositories/snapshots")
    }
}
plugins {
    // See https://jmfayard.github.io/refreshVersions
    id("de.fayard.refreshVersions") version "0.23.0-SNAPSHOT"
}
pluginManagement {
    repositories {
        gradlePluginPortal()
        maven { url 'https://s01.oss.sonatype.org/content/repositories/snapshots' }
    }
}
plugins {
    // See https://jmfayard.github.io/refreshVersions
    id 'de.fayard.refreshVersions' version '0.23.0-SNAPSHOT'
}

Configure the plugin

There is no required configuration!

There are some options which can be configured in the refreshVersions { } block.

If you are curious about what are the available options, you can use auto-complete (you can also type this. before to filter the results).

Earlier versions

If you are upgrading from the buildSrcVersions plugin

Before refreshVersions, there was the plugin buildSrcVersions.

If your project is using it, remove all its configuration from the top build.gradle[.kts] file to avoid any clashes between the two plugins:

-plugins {
-    id("de.fayard.buildSrcVersions") version "0.3.2"
-}

-buildSrcVersions {
-    someOption = "somevalue"
-}

Then, enable buildSrcLibs as such:

plugins {
    // See https://jmfayard.github.io/refreshVersions
    id("de.fayard.refreshVersions") version "0.23.0"
}

refreshVersions {
    enableBuildSrcLibs() // <-- Add this
}
plugins {
    // See https://jmfayard.github.io/refreshVersions
    id 'de.fayard.refreshVersions' version '0.23.0'
}

refreshVersions {
    enableBuildSrcLibs() // <-- Add this
}

Read more: gradle buildSrcVersions.

Next steps

You did it! refreshVersions is now properly setup.

Now, you might want to: