Created
March 21, 2021 15:09
-
-
Save arunkumar9t2/1e612e26a02d1b8b1060376354e4fe36 to your computer and use it in GitHub Desktop.
Gradle task to generate project dependency graph as json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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