For AI agents: the documentation index is at https://docs.gradle.org/llms.txt. Request any page with the header Accept: text/markdown to get Markdown. User manual pages are also available as Markdown by replacing .html with .md in the URL.

eachDependency

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:

configurations {
  compileClasspath.resolutionStrategy {
    eachDependency { DependencyResolveDetails details ->
      //specifying a fixed version for all libraries with 'org.gradle' group
      if (details.requested.group == 'org.gradle') {
        details.useVersion '1.4'
      }
    }
    eachDependency { details ->
      //multiple actions can be specified
      if (details.requested.name == 'groovy-all') {
         //changing the name:
         details.useTarget group: details.requested.group, name: 'groovy', version: details.requested.version
      }
    }
  }
}
The rules are evaluated in order they are declared. Rules are evaluated after forced modules are applied (see force

Return

this

Since

1.4