Skip to content

Instantly share code, notes, and snippets.

@Hazer
Forked from uarun/version_conflicts_gradle.md
Created July 14, 2016 22:00
Show Gist options
  • Save Hazer/35eea95eec56d692ccc552cb88f8a149 to your computer and use it in GitHub Desktop.
Save Hazer/35eea95eec56d692ccc552cb88f8a149 to your computer and use it in GitHub Desktop.
Resolving version conflicts in Gradle

Resolving Version Conflicts in Gradle

If one module has a dependency on version 1.1 of library X and another module on version 2.0 of the same library, gradle will use the latest version.

Failing a build on version conflict

To make gradle fail the build on encountering a conflict, we can do the following:

configurations.all {
    resolutionStrategy {
        failOnVersionConflict()
    }
}

Forcing a certain version

To force a certain version number for all dependencies:

configurations.compile {
    resolutionStrategy {
        force 'groupId:artifactId:desiredVersion'
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment