Skip to content

Resolving Differences Between Recommendation Providers

jkschneider edited this page Nov 21, 2014 · 3 revisions

Resolving differences between recommendation providers

By default, recommendation providers are queried for recommendations in LIFO order.

dependencyRecommendations {
   map recommendations: ['commons-logging:commons-logging': '1.2', 'com.google.guava:guava': '18.0']
   map recommendations: ['commons-logging:commons-logging': '1.1']
}

dependencies {
   compile 'commons-logging:commons-logging' // resolves to 1.1
   compile 'com.google.guava:guava' // resolves to 18.0
}

Notice that unlike Gradle conflict resolution, the relative age of a version is not a factor in determining the version, only the order in which the recommenders were defined.

Suppose you have a parent Gradle script:

subprojects {
   dependencyRecommendations {
      map recommendations: ['commons-logging:commons-logging': '1.2']
   }
}

And a subproject Gradle script with a dependency on commons-logging:

dependencyRecommendations {
   map recommendations: ['commons-logging:commons-logging': '1.1']
}

dependencies {
   compile 'commons-logging:commons-logging' // resolves to 1.1
}

Because the parent's dependencyRecommendations block gets evaluated before the subproject's, version 1.1 wins here.