Last active
December 13, 2017 05:21
-
-
Save asahui/95b0d9c1a0cf486e4fdb370b3f6e14c1 to your computer and use it in GitHub Desktop.
a task to display all dependencies when run this build script
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
// a task to display all dependencies when run this build script | |
import groovy.json.JsonOutput | |
task printDependencies { | |
doLast { | |
println "print dependencies:" | |
buildscript.configurations.getByName("classpath").allDependencies.each { | |
println it.name | |
} | |
println "print dependecies files:" | |
buildscript.configurations.getByName("classpath").files.each { | |
println it.name | |
} | |
println "print resolved artifacts:" | |
def json = '"dependencies": [' | |
// buildscript configurations is not the same as project configurations | |
buildscript.configurations.classpath.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 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment