# ResolutionStrategy

API Documentation: | `ResolutionStrategy`

Defines the strategies around dependency resolution. For example, forcing certain dependency versions, conflict resolutions or snapshot timeouts.

Examples:

    configurations.all {
      resolutionStrategy {
        // fail eagerly on version conflict (includes transitive dependencies)
        // e.g. multiple different versions of the same dependency (group and name are equal)
        failOnVersionConflict()

        // cache dynamic versions for 10 minutes
        cacheDynamicVersionsFor 10, 'minutes'
        // don't cache changing modules at all
        cacheChangingModulesFor 0, 'seconds'
      }
    }

### Properties

No properties

### Script blocks

No script blocks

### Methods

Method | Description
`cacheChangingModulesFor(value, units)` | Sets the length of time that changing modules will be cached, with units expressed as a String.
`cacheChangingModulesFor(value, units)` | Sets the length of time that changing modules will be cached.
`cacheDynamicVersionsFor(value, units)` | Sets the length of time that dynamic versions will be cached, with units expressed as a String.
`cacheDynamicVersionsFor(value, units)` | Sets the length of time that dynamic versions will be cached.
`failOnVersionConflict()` | In case of conflict, Gradle by default uses the newest of conflicting versions. However, you can change this behavior. Use this method to configure the resolution to fail eagerly on any version conflict, e.g. multiple different versions of the same dependency (group and name are equal) in the same `Configuration`. The check includes both first level and transitive dependencies. See example below:

### Method details

#### `void` `cacheChangingModulesFor`(`int` value, `String` units)

Sets the length of time that changing modules will be cached, with units expressed as a String.

A convenience method for `ResolutionStrategy.cacheChangingModulesFor()` with units expressed as a String. Units are resolved by calling the `valueOf(String)` method of `TimeUnit` with the upper-cased string value.

#### `void` `cacheChangingModulesFor`(`int` value, `TimeUnit` units)

Sets the length of time that changing modules will be cached.

Gradle caches the contents and artifacts of changing modules. By default, these cached values are kept for 24 hours, after which the cached entry is expired and the module is resolved again.

Use this method to provide a custom expiry time after which the cached entries for any changing module will be expired.

#### `void` `cacheDynamicVersionsFor`(`int` value, `String` units)

Sets the length of time that dynamic versions will be cached, with units expressed as a String.

A convenience method for `ResolutionStrategy.cacheDynamicVersionsFor()` with units expressed as a String. Units are resolved by calling the `valueOf(String)` method of `TimeUnit` with the upper-cased string value.

#### `void` `cacheDynamicVersionsFor`(`int` value, `TimeUnit` units)

Sets the length of time that dynamic versions will be cached.

Gradle keeps a cache of dynamic version => resolved version (ie 2.+ => 2.3). By default, these cached values are kept for 24 hours, after which the cached entry is expired and the dynamic version is resolved again.

Use this method to provide a custom expiry time after which the cached value for any dynamic version will be expired.

#### `ResolutionStrategy` `failOnVersionConflict`()

In case of conflict, Gradle by default uses the newest of conflicting versions. However, you can change this behavior. Use this method to configure the resolution to fail eagerly on any version conflict, e.g. multiple different versions of the same dependency (group and name are equal) in the same `Configuration`. The check includes both first level and transitive dependencies. See example below:

    configurations.all {
      resolutionStrategy.failOnVersionConflict()
    }