I know that doing:
gradle dependencies
Lists the full dependency tree. Now, I\'m looking for a way to manipulate that dependencies tree program
You could create a task within your Gradle file to iterate over all dependencies and generate the JSON as you see fit. Here is an example task that will pretty print the JSON for you:
task printDependencies << {
def json = '"dependencies": ['
configurations.runtime.resolvedConfiguration.resolvedArtifacts.each { artifact ->
def id = artifact.moduleVersion.id
// println "group: ${id.group}, name: ${id.name}, version: ${id.version}"
json += JsonOutput.toJson(id)
}
json += "]"
json = JsonOutput.prettyPrint(json)
println json
}
With sample output:
"dependencies": [
{
"group": "com.fasterxml.jackson.core",
"version": "2.6.5",
"name": "jackson-core",
"module": {
"group": "com.fasterxml.jackson.core",
"name": "jackson-core"
}
}{
"group": "org.springframework",
"version": "4.2.5.RELEASE",
"name": "spring-aop",
"module": {
"group": "org.springframework",
"name": "spring-aop"
}
}
]