Last active
October 6, 2020 06:55
-
-
Save arindamxd/8b233d2cf6240be86c4b84dea9eb67db to your computer and use it in GitHub Desktop.
List Configuration Dependency Size
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
// List Release Configuration Dependencies | |
tasks.create("dependency-size-all") { | |
configurations.each { | |
if (it.isCanBeResolved()) { | |
listConfigurationDependencies(it) | |
} | |
} | |
} | |
project.afterEvaluate { | |
tasks.create("dependency-size-release") { | |
configurations.each { | |
if (it.isCanBeResolved() && it.name.contains("ReleaseCompileClasspath")) { | |
listConfigurationDependencies(it) | |
} | |
} | |
} | |
} | |
def listConfigurationDependencies(Configuration configuration) { | |
def formatStr = "%,10.2f" | |
def size = configuration.collect { it.length() / (1024 * 1024) }.sum() | |
def out = new StringBuffer() | |
out << "\nConfiguration Name: \"${configuration.name}\"\n" | |
if (size) { | |
out << 'Total Dependencies Size:'.padRight(65) | |
out << "${String.format(formatStr, size)} MB\n\n" | |
configuration.sort { -it.length() } | |
.each { | |
out << "${it.name}".padRight(65) | |
out << "${String.format(formatStr, (it.length() / 1024))} KB\n" | |
} | |
} else { | |
out << 'No Dependencies Found.' | |
} | |
println(out) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment