Last active
March 3, 2024 02:38
-
-
Save martinda/56638e34fc8e316d32389a3568f6e183 to your computer and use it in GitHub Desktop.
List artifacts of dependencies using Gradle
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
// build.gradle | |
void printArtifacts(Set<ResolvedArtifact> resolvedArtifacts, int level) { | |
println(" "*level + "Artifacts:") | |
for (def resolvedArtifact in resolvedArtifacts) { | |
println(" " * level + resolvedArtifact) | |
} | |
} | |
void printDependencies(ResolvedDependency parent, Set<ResolvedDependency> resolvedDependencies, int level) { | |
if (resolvedDependencies.size() == 0) return | |
println(" "*level + "Resolved dependencies:") | |
resolvedDependencies.each { | |
println(" "*level + it) | |
printArtifacts(it.getArtifacts(parent), level + 4) | |
printDependencies(it, it.getChildren(), level + 4) | |
} | |
} | |
void printDependencies(Set<ResolvedDependency> resolvedDependencies, int level) { | |
if (resolvedDependencies.size() == 0) return | |
println(" "*level + "Resolved dependencies:") | |
resolvedDependencies.each { | |
println(" "*level + it) | |
printDependencies(it, it.getChildren(), level + 4) | |
} | |
} | |
void printResolvedConfiguration(ResolvedConfiguration rc) { | |
printDependencies(rc.getFirstLevelModuleDependencies(), 4) | |
} | |
task printDeps { | |
doLast { | |
for (def rd in configurations) { | |
println(rd) | |
if (!rd.isCanBeResolved()) continue | |
def rc = rd.getResolvedConfiguration() | |
printResolvedConfiguration(rc) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment