Skip to content

Instantly share code, notes, and snippets.

@dudadornelles
Last active December 30, 2017 16:50
Show Gist options
  • Save dudadornelles/be0bea9f98d3aa17404c to your computer and use it in GitHub Desktop.
Save dudadornelles/be0bea9f98d3aa17404c to your computer and use it in GitHub Desktop.
Gradle - get resolved version of a dependency
def getResolvedVersionOf(dependency) {
return configurations.compile.resolvedConfiguration.firstLevelModuleDependencies.asList().collectAll { e ->
if (e.moduleName == dependency) {
return e
}
}[0].moduleVersion
}
@nbruno
Copy link

nbruno commented Feb 27, 2017

I trimmed it down a bit by using findAll():

def getResolvedVersionOf(dependency) {
    return configurations.compile.resolvedConfiguration.firstLevelModuleDependencies.findAll { it.moduleName == dependency }[0].moduleVersion
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment