Skip to content

Commit

Permalink
Change default recommendation strategy to ConflictResolved
Browse files Browse the repository at this point in the history
  • Loading branch information
jkschneider committed Jun 7, 2016
1 parent 63f03c9 commit 24bb2cb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
}
Expand Down Expand Up @@ -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']
}
Expand All @@ -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'
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
public class RecommendationProviderContainer extends DefaultNamedDomainObjectList<RecommendationProvider> {

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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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']
}

Expand Down

0 comments on commit 24bb2cb

Please sign in to comment.