Skip to content

Instantly share code, notes, and snippets.

@p120ph37
Last active May 10, 2018 19:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save p120ph37/e4fb0bdc52d2f1961a45f77e22303bcc to your computer and use it in GitHub Desktop.
Save p120ph37/e4fb0bdc52d2f1961a45f77e22303bcc to your computer and use it in GitHub Desktop.
Gradle depsize target
task depsize {
group 'Help'
description 'Displays the sizes of all dependencies.'
doLast {
def size = 0, formatStr = "%,10.2f", out = new StringBuffer()
configurations.default.collect{it.length() / (1024 * 1024)}.each{size += it}
out << 'Total dependencies size:'.padRight(45)
out << "${String.format(formatStr, size)} Mb\n\n"
configurations.default.sort{-it.length()}.each {
out << "${it.name}".padRight(45)
out << "${String.format(formatStr, (it.length() / 1024))} kb\n"
}
println(out)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment