# ResolutionStrategy

interface ResolutionStrategy(source)

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

Examples:

    plugins {
        id 'java' // so that there are some configurations
    }

    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()

        // prefer modules that are part of this build (multi-project or composite build) over external modules
        preferProjectModules()

        // force certain versions of dependencies (including transitive)
        //  *append new forced modules:
        force 'asm:asm-all:3.3.1', 'commons-io:commons-io:1.4'
        //  *replace existing forced modules with new ones:
        forcedModules = ['asm:asm-all:3.3.1']

        // add dependency substitution rules
        dependencySubstitution {
          substitute module('org.gradle:api') using project(':api')
          substitute project(':util') using module('org.gradle:util:3.0')
        }

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

Content copied to clipboard

#### Since

1.0-milestone-6

## Types

SortOrder
Link copied to clipboard
enum SortOrder
Defines the sort order for components and artifacts produced by the configuration.

## Functions

activateDependencyLocking
Link copied to clipboard
abstract fun activateDependencyLocking(): ResolutionStrategy
Activates dependency locking support in Gradle.
cacheChangingModulesFor
Link copied to clipboard
abstract fun cacheChangingModulesFor(value: Int, units: String)
Sets the length of time that changing modules will be cached, with units expressed as a String.
abstract fun cacheChangingModulesFor(value: Int, units: TimeUnit)
Sets the length of time that changing modules will be cached.
cacheDynamicVersionsFor
Link copied to clipboard
abstract fun cacheDynamicVersionsFor(value: Int, units: String)
Sets the length of time that dynamic versions will be cached, with units expressed as a String.
abstract fun cacheDynamicVersionsFor(value: Int, units: TimeUnit)
Sets the length of time that dynamic versions will be cached.
capabilitiesResolution
Link copied to clipboard
abstract fun capabilitiesResolution(action: Action<in CapabilitiesResolution>): ResolutionStrategy
Configures the capabilities resolution strategy.
componentSelection
Link copied to clipboard
abstract fun componentSelection(action: Action<in ComponentSelectionRules>): ResolutionStrategy
The componentSelection block provides rules to filter or prevent certain components from appearing in the resolution result.
deactivateDependencyLocking
Link copied to clipboard
abstract fun deactivateDependencyLocking(): ResolutionStrategy
Deactivates dependency locking support in Gradle.
dependencySubstitution
Link copied to clipboard
abstract fun dependencySubstitution(action: Action<in DependencySubstitutions>): ResolutionStrategy
Configures the set of dependency substitution rules for this configuration.
disableDependencyVerification
Link copied to clipboard
abstract fun disableDependencyVerification(): ResolutionStrategy
Deactivates dependency verification for this configuration.
eachDependency
Link copied to clipboard
abstract fun eachDependency(rule: Action<in DependencyResolveDetails>): ResolutionStrategy
Adds a dependency substitution rule that is triggered for every dependency (including transitive) when the configuration is being resolved.
enableDependencyVerification
Link copied to clipboard
abstract fun enableDependencyVerification(): ResolutionStrategy
Enabled dependency verification for this configuration.
failOnChangingVersions
Link copied to clipboard
abstract fun failOnChangingVersions(): ResolutionStrategy
If this method is called, Gradle will make sure that no changing version participates in resolution.
failOnDynamicVersions
Link copied to clipboard
abstract fun failOnDynamicVersions(): ResolutionStrategy
If this method is called, Gradle will make sure that no dynamic version was used in the resulting dependency graph.
failOnNonReproducibleResolution
Link copied to clipboard
abstract fun failOnNonReproducibleResolution(): ResolutionStrategy
Configures Gradle to fail the build is the resolution result is expected to be unstable, that is to say that it includes dynamic versions or changing versions and therefore the result may change depending on when the build is executed.
failOnVersionConflict
Link copied to clipboard
abstract fun failOnVersionConflict(): ResolutionStrategy
In case of conflict, Gradle by default uses the newest of conflicting versions.
force
Link copied to clipboard
abstract fun force(moduleVersionSelectorNotations: Array<Any>): ResolutionStrategy
Allows forcing certain versions of dependencies, including transitive dependencies.
getCapabilitiesResolution
Link copied to clipboard
abstract fun getCapabilitiesResolution(): CapabilitiesResolution
Returns the capabilities resolution strategy.
getComponentSelection
Link copied to clipboard
abstract fun getComponentSelection(): ComponentSelectionRules
Returns the currently configured version selection rules object.
getDependencySubstitution
Link copied to clipboard
abstract fun getDependencySubstitution(): DependencySubstitutions
Returns the set of dependency substitution rules that are set for this configuration.
getForcedModules
Link copied to clipboard
abstract fun getForcedModules(): Set<ModuleVersionSelector>
Returns currently configured forced modules.
getUseGlobalDependencySubstitutionRules
Link copied to clipboard
abstract fun getUseGlobalDependencySubstitutionRules(): Property<Boolean>
Gradle implicitly registers dependency substitution rules for all configurations in the whole build tree to find projects in other included builds.
preferProjectModules
Link copied to clipboard
abstract fun preferProjectModules()
Gradle can resolve conflicts purely by version number or prioritize project dependencies over binary.
setForcedModules
Link copied to clipboard
abstract fun setForcedModules(moduleVersionSelectorNotations: Array<Any>): ResolutionStrategy
Allows forcing certain versions of dependencies, including transitive dependencies.
sortArtifacts
Link copied to clipboard
abstract fun sortArtifacts(sortOrder: ResolutionStrategy.SortOrder)
Specifies the ordering for resolved artifacts.