Groovy Documentation

org.gradle.api.artifacts
[Java] Interface ResolutionStrategy


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


Method Summary
void cacheChangingModulesFor(int value, java.lang.String units)

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

void cacheChangingModulesFor(int value, java.util.concurrent.TimeUnit units)

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

void cacheDynamicVersionsFor(int value, java.lang.String units)

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

void cacheDynamicVersionsFor(int value, java.util.concurrent.TimeUnit units)

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

ResolutionStrategy failOnVersionConflict()

In case of conflict, Gradle by default uses the newest of conflicting versions.

ResolutionStrategy force(java.lang.String... forcedModules)

Experimental.

java.util.Set getForcedModules()

Experimental.

ResolutionStrategy setForcedModules(java.lang.Object... forcedModules)

Experimental.

 

Method Detail

cacheChangingModulesFor

public void cacheChangingModulesFor(int value, java.lang.String units)
Sets the length of time that changing modules will be cached, with units expressed as a String.

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

Parameters:
value - The number of time units
units - The units


cacheChangingModulesFor

public void cacheChangingModulesFor(int value, java.util.concurrent.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.

Parameters:
value - The number of time units
units - The units


cacheDynamicVersionsFor

public void cacheDynamicVersionsFor(int value, java.lang.String units)
Sets the length of time that dynamic versions will be cached, with units expressed as a String.

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

Parameters:
value - The number of time units
units - The units


cacheDynamicVersionsFor

public void cacheDynamicVersionsFor(int value, java.util.concurrent.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.

Parameters:
value - The number of time units
units - The units


failOnVersionConflict

public 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()
 }
 
Returns:
this resolution strategy instance


force

public ResolutionStrategy force(java.lang.String... forcedModules)
Experimental. This part of the api is yet experimental - may change without notice.

Configures forced versions in DSL friendly fashion.

Parameters:
forcedModules - group:name:version notations
Returns:
this ResolutionStrategy instance


getForcedModules

public java.util.Set getForcedModules()
Experimental. This part of the api is yet experimental - may change without notice.

returns currently configured forced modules

Returns:
forced modules


setForcedModules

public ResolutionStrategy setForcedModules(java.lang.Object... forcedModules)
Experimental. This part of the api is yet experimental - may change without notice.

Replaces existing forced modules with the passed ones.

Parameters:
forcedModules - forced modules to set
Returns:
this ResolutionStrategy instance


 

Groovy Documentation