ben-manes/gradle-versions-plugin — pull request #40 by tkruse (2014-09-28 10:53:49+00:00)
Title: Feature: revision excludes

So this is the PR is was preparing. It includes all commits of #38, so #38 should be decided and merged first, and then may this PR be amended.

This PR is mostly for early discussion, though it is fully functional and tested.

The README.md change explain how to use the new feature.

As an example, for a real-world project:

Before
```
Using these dependencies:
project.ext {
JDK_VERSION = 1.7

versions = [
servlet_api : '3.1.0',
spring : '4.0.6.RELEASE',
spring_boot : '1.1.5.RELEASE',
wicket : '6.16.0',
jackson : '2.3.3',
slf4j : '1.7.6',
mockito : '1.9.5',
assertj : '1.6.1'
]

}

dependencies {
compile "org.slf4j:slf4j-api:$versions.slf4j"

compile("org.apache.commons:commons-lang3:3.3.2") { force = true }

compile("com.google.guava:guava:18.0") { force = true }

compile "org.springframework:spring-core:$versions.spring"

compile("com.fasterxml.jackson.core:jackson-core:$versions.jackson") { force = true }

compile("org.apache.wicket:wicket-core:$versions.wicket") { force = true }
compile "org.apache.wicket:wicket-util:$versions.wicket"

testCompile 'junit:junit:4.11'
testCompile("org.assertj:assertj-core:$versions.assertj")
testCompile("org.mockito:mockito-core:$versions.mockito") {
exclude group: 'org.hamcrest'
}
}

------------------------------------------------------------
: Project Dependency Updates (report to plain text file)
------------------------------------------------------------

The following dependencies are using the latest milestone version:
- com.google.guava:guava:18.0
- org.apache.commons:commons-lang3:3.3.2
- org.assertj:assertj-core:1.6.1

The following dependencies have later milestone versions:
- com.fasterxml.jackson.core:jackson-core [2.3.3 -> 2.4.2]
- junit:junit [4.11 -> 4.12-beta-2]
- org.apache.wicket:wicket-core [6.16.0 -> 7.0.0-M3]
- org.apache.wicket:wicket-util [6.16.0 -> 7.0.0-M3]
- org.mockito:mockito-core [1.9.5 -> 1.10.3]
- org.slf4j:slf4j-api [1.7.6 -> 1.7.7]
- org.springframework:spring-core [4.0.6.RELEASE -> 4.1.0.RC2]
```

After
```
/ / Using this block:
versionsConfig {
lookupRevisionMapper = { Dependency dep ->
if (dep.group == 'org.apache.wicket') {
return '(,7.0['
}
if (dep.group == 'org.springframework') {
return '(,4.1['
}
if (dep.group == 'junit') {
return '4.12'
}
}
}

------------------------------------------------------------
: Project Dependency Updates (report to plain text file)
------------------------------------------------------------

The following dependencies are using the latest milestone version:
- com.google.guava:guava:18.0
- org.apache.commons:commons-lang3:3.3.2
- org.assertj:assertj-core:1.6.1

The following dependencies have later milestone versions:
- com.fasterxml.jackson.core:jackson-core [2.3.3 -> 2.4.2]
- org.apache.wicket:wicket-core [6.16.0 -> 6.17.0]
- org.apache.wicket:wicket-util [6.16.0 -> 6.17.0]
- org.mockito:mockito-core [1.9.5 -> 1.10.3]
- org.slf4j:slf4j-api [1.7.6 -> 1.7.7]
- org.springframework:spring-core [4.0.6.RELEASE -> 4.0.7.RELEASE]

Failed to determine the latest version for the following dependencies (use --info for details):
- junit:junit

```
So the manually fixed report shows the update to wicket and spring that matter to me.

Concerns:
- The message "Failed to determine the *latest* version..." does not really fit
- Not sure whether you like the way a the configuration uses a closure to return a String:

An alternative would be to try to mimic the way in default gradle transitive dependencies can be modified:
```
configurations {
all {
resolutionStrategy {
eachDependency(new Action() {
@Override
void execute(DependencyResolveDetails details) {
def requested = details.requested
if (requested.group == 'org.springframework') {
details.useVersion "4.0.6"
...
```
See
http://www.gradle.org/docs/current/userguide/dependency_management.html
section 51.8.2.1
But that would require more code.