How to resolve a dynamic version to a static one

Hi,

how can I resolve a dependency’s dynamic version to a static version from within a task? For example, I’d like to be able to turn “commons-io:commons-io:2.+” to “2.4”.

Thanks in advance for any hints.

Hi Jochen,

I don’t understand the context of “within a task”, but I think you can mitigate your problem by setting up a resolution strategy, e.g.:

allprojects {

configurations.all { configuration ->

resolutionStrategy {

eachDependency {

if (requested.name == ‘some-artifact-name’) {

useVersion ‘2.2’

}

}

}

}

}

For more information on ResolutionStrategy, see http://www.gradle.org/docs/current/dsl/org.gradle.api.artifacts.ResolutionStrategy.html

Thanks, that actually got me a step further.

dependencies {

def x = compile ‘backport-util-concurrent:backport-util-concurrent:3.+’

def resolved = configurations.compile.resolvedConfiguration.getFirstLevelModuleDependencies(Specs.convertClosureToSpec {it == x})

println resolved.find().moduleVersion

} However, I feel that I’m overcomplicating things.

And another question is coming up: How do I determine whether a version is dynamic in the first place?