ResolutionStrategy

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'
  }
}

Since

1.0-milestone-6

Types

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

Functions

Link copied to clipboard
Activates dependency locking support in Gradle.
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.
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.
Link copied to clipboard
Configures the capabilities resolution strategy.
Link copied to clipboard
The componentSelection block provides rules to filter or prevent certain components from appearing in the resolution result.
Link copied to clipboard
Deactivates dependency locking support in Gradle.
Link copied to clipboard
Configures the set of dependency substitution rules for this configuration.
Link copied to clipboard
Deactivates dependency verification for this configuration.
Link copied to clipboard
Adds a dependency substitution rule that is triggered for every dependency (including transitive) when the configuration is being resolved.
Link copied to clipboard
Enabled dependency verification for this configuration.
Link copied to clipboard
If this method is called, Gradle will make sure that no changing version participates in resolution.
Link copied to clipboard
If this method is called, Gradle will make sure that no dynamic version was used in the resulting dependency graph.
Link copied to clipboard
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.
Link copied to clipboard
In case of conflict, Gradle by default uses the newest of conflicting versions.
Link copied to clipboard
abstract fun force(moduleVersionSelectorNotations: Array<Any>): ResolutionStrategy
Allows forcing certain versions of dependencies, including transitive dependencies.
Link copied to clipboard
Returns the capabilities resolution strategy.
Link copied to clipboard
Returns the currently configured version selection rules object.
Link copied to clipboard
Returns the set of dependency substitution rules that are set for this configuration.
Link copied to clipboard
Returns currently configured forced modules.
Link copied to clipboard
Gradle implicitly registers dependency substitution rules for all configurations in the whole build tree to find projects in other included builds.
Link copied to clipboard
abstract fun preferProjectModules()
Gradle can resolve conflicts purely by version number or prioritize project dependencies over binary.
Link copied to clipboard
abstract fun setForcedModules(moduleVersionSelectorNotations: Array<Any>): ResolutionStrategy
Allows forcing certain versions of dependencies, including transitive dependencies.
Link copied to clipboard
Specifies the ordering for resolved artifacts.