Enforce no snapshot dependencies in gradle

(suman jakkula) #1

How do I force gradle to use release versions and not snapshot versions for dependencies? I want to fail the build if a snapshot dependency is used. Is this available with a property on dependencies? or some other means?

(Peter Niederwieser) #2

You could use a dependency resolve rule:

configurations.all {
    resolutionStrategy.eachDependency { details ->
        if (details.requested.version.endsWith("-SNAPSHOT") {
            throw new GradleException("found snapshot dependency")

You can learn more about this API in the Gradle Build Language Reference (e.g. starting from ‘Configuration’).