Skip to content

Instantly share code, notes, and snippets.

@arunkumar9t2
Created March 21, 2021 15:09
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arunkumar9t2/1e612e26a02d1b8b1060376354e4fe36 to your computer and use it in GitHub Desktop.
Save arunkumar9t2/1e612e26a02d1b8b1060376354e4fe36 to your computer and use it in GitHub Desktop.
Gradle task to generate project dependency graph as json
tasks.register("dependencyGraph") {
description = "Generate dependency graph json"
doLast {
def dependencyGraph = subprojects
.collect { project ->
[
"project" : project.path,
"dependencies": project.configurations
.collectMany { config ->
config
.dependencies
.withType(ProjectDependency)
.collect { it.dependencyProject.path }
}
]
}
def json = JsonOutput.prettyPrint(JsonOutput.toJson(dependencyGraph))
logger.quiet(json)
new File(project.buildDir, "dependencyGraph.json").write(json)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment