diff --git a/README.md b/README.md index 085b631..18c4e3a 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ buildscript { repositories { jcenter() } dependencies { - classpath 'com.netflix.nebula:nebula-dependency-recommender:3.1.0' + classpath 'com.netflix.nebula:nebula-dependency-recommender:3.4.0' } } @@ -227,13 +227,13 @@ dependencies { Transitive dependencies interact with the plugin in different ways depending on which of two available strategies is selected. -#### 5.4.1. `OverrideTransitives` Strategy (default) +#### 5.4.1. `ConflictResolved` Strategy (default) -In the following example version `commons-logging:commons-logging:1.0` is selected even though `commons-logging` is not explicitly mentioned in dependencies. This would not work with the ConflictResolved strategy: +Consider the following example with dependencies on `commons-configuration` and `commons-logging`. `commons-configuration:1.6` depends on `commons-logging:1.1.1`. In this case, the transitive dependency on `commons-logging` via `commons-configuration` is conflict resolved against the recommended version of 1.0. Normal Gradle conflict resolution selects 1.1.1. ```groovy dependencyRecommendations { - strategy OverrideTransitives // this is the default, so this line is NOT necessary + strategy ConflictResolved map recommendations: ['commons-logging:commons-logging': '1.0'] } @@ -242,26 +242,26 @@ dependencies { } ``` -#### 5.4.2. `ConflictResolved` Strategy - -Consider the following example with dependencies on `commons-configuration` and `commons-logging`. `commons-configuration:1.6` depends on `commons-logging:1.1.1`. In this case, the transitive dependency on `commons-logging` via `commons-configuration` is conflict resolved against the recommended version of 1.0. Normal Gradle conflict resolution selects 1.1.1. +However, if we have a first-order recommendation eligible dependency on `commons-logging`, 1.0 will be selected. ```groovy -dependencyRecommendations { - strategy ConflictResolved - map recommendations: ['commons-logging:commons-logging': '1.0'] -} - dependencies { - compile 'commons-configuration:commons-configuration:1.6' + compile 'commons-configuration:commons-logging' } ``` -However, if we have a first-order recommendation eligible dependency on `commons-logging`, 1.0 will be selected. +#### 5.4.2. `OverrideTransitives` Strategy + +In the following example version `commons-logging:commons-logging:1.0` is selected even though `commons-logging` is not explicitly mentioned in dependencies. This would not work with the ConflictResolved strategy: ```groovy +dependencyRecommendations { + strategy OverrideTransitives // this is the default, so this line is NOT necessary + map recommendations: ['commons-logging:commons-logging': '1.0'] +} + dependencies { - compile 'commons-configuration:commons-logging' + compile 'commons-configuration:commons-configuration:1.6' } ``` diff --git a/src/main/groovy/netflix/nebula/dependency/recommender/provider/RecommendationProviderContainer.java b/src/main/groovy/netflix/nebula/dependency/recommender/provider/RecommendationProviderContainer.java index 9670fdf..f0a9373 100644 --- a/src/main/groovy/netflix/nebula/dependency/recommender/provider/RecommendationProviderContainer.java +++ b/src/main/groovy/netflix/nebula/dependency/recommender/provider/RecommendationProviderContainer.java @@ -15,7 +15,7 @@ public class RecommendationProviderContainer extends DefaultNamedDomainObjectList { private Project project; - private RecommendationStrategies strategy = RecommendationStrategies.OverrideTransitives; + private RecommendationStrategies strategy = RecommendationStrategies.ConflictResolved; // Make strategies available without import public static final RecommendationStrategies OverrideTransitives = RecommendationStrategies.OverrideTransitives; diff --git a/src/test/groovy/netflix/nebula/dependency/recommender/RecommendationProviderContainerSpec.groovy b/src/test/groovy/netflix/nebula/dependency/recommender/RecommendationProviderContainerSpec.groovy index 7ce7552..d641009 100644 --- a/src/test/groovy/netflix/nebula/dependency/recommender/RecommendationProviderContainerSpec.groovy +++ b/src/test/groovy/netflix/nebula/dependency/recommender/RecommendationProviderContainerSpec.groovy @@ -165,6 +165,7 @@ class RecommendationProviderContainerSpec extends Specification { def 'transitive dependency versions are overriden by recommendations with OverrideTransitives strategy'() { setup: project.dependencyRecommendations { + strategy OverrideTransitives map recommendations: ['commons-logging:commons-logging': '1.1'] }