interface ResolutionStrategy
Defines the strategies around dependency resolution. For example, forcing certain dependency versions, substitutions, conflict resolutions or snapshot timeouts.
Examples:
apply plugin: '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') with project(':api') substitute project(':util') with 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
class SortOrder
Defines the sort order for components and artifacts produced by the configuration. |
abstract fun activateDependencyLocking(): ResolutionStrategy
Activates dependency locking support in Gradle. Once turned on on a configuration, resolution result can be saved and then reused for subsequent builds. This enables reproducible builds when using dynamic versions. |
|
abstract fun cacheChangingModulesFor(value: Int, units: String): Unit
Sets the length of time that changing modules will be cached, with units expressed as a String. A convenience method for abstract fun cacheChangingModulesFor(value: Int, units: TimeUnit): Unit
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. |
|
abstract fun cacheDynamicVersionsFor(value: Int, units: String): Unit
Sets the length of time that dynamic versions will be cached, with units expressed as a String. A convenience method for abstract fun cacheDynamicVersionsFor(value: Int, units: TimeUnit): Unit
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. |
|
abstract fun componentSelection(action: Action<in ComponentSelectionRules>): ResolutionStrategy
The componentSelection block provides rules to filter or blacklist certain components from appearing in the resolution result. |
|
abstract fun dependencySubstitution(action: Action<in DependencySubstitutions>): ResolutionStrategy
Configures the set of dependency substitution rules for this configuration. The action receives an instance of DependencySubstitutions which can then be configured with substitution rules. Examples:
|
|
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. The action receives an instance of DependencyResolveDetails that can be used to find out what dependency is being resolved and to influence the resolution process. Example: The rules are evaluated in order they are declared. Rules are evaluated after forced modules are applied (see #force(Object...)
|
|
abstract fun failOnVersionConflict(): ResolutionStrategy
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:
|
|
abstract fun force(vararg moduleVersionSelectorNotations: Any): ResolutionStrategy
Allows forcing certain versions of dependencies, including transitive dependencies. Appends new forced modules to be considered when resolving dependencies. It accepts following notations:
|
|
abstract fun getComponentSelection(): ComponentSelectionRules
Returns the currently configured version selection rules object. |
|
abstract fun getDependencySubstitution(): DependencySubstitutions
Returns the set of dependency substitution rules that are set for this configuration. |
|
abstract fun getForcedModules(): MutableSet<ModuleVersionSelector>
Returns currently configured forced modules. For more information on forcing versions see |
|
abstract fun preferProjectModules(): Unit
Gradle can resolve conflicts purely by version number or prioritize project dependencies over binary. The default is by version number. This applies to both first level and transitive dependencies. See example below:
|
|
abstract fun setForcedModules(vararg moduleVersionSelectorNotations: Any): ResolutionStrategy
Allows forcing certain versions of dependencies, including transitive dependencies. Replaces existing forced modules with the input. For information on notations see Example:
|
|
abstract fun sortArtifacts(sortOrder: SortOrder): Unit
Specifies the ordering for resolved artifacts. Options are:
|