Last active
July 27, 2022 04:20
-
-
Save joshafeinberg/30828d27c5ac6bf85c9eea8fcc135510 to your computer and use it in GitHub Desktop.
Using Version Catalogs with Dependency Analysis Plugin
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
ext.reversedMap = [:] as Map<String, String> | |
void buildReversedMap(String versionCatalogName) { | |
def versionCatalog = rootProject.extensions | |
.getByType(VersionCatalogsExtension).named(versionCatalogName) | |
reversedMap = versionCatalog.getDependencyAliases() | |
.collectEntries { alias -> | |
def versionCatalogAlias = "${versionCatalogName}.${alias}" | |
def module = versionCatalog.findDependency(alias).get().get() | |
def fullModuleName = "${module.getModule()}:${module.getVersionConstraint()}" | |
[(fullModuleName.toString()): versionCatalogAlias.toString()] | |
} | |
} | |
buildReversedMap("libs") | |
dependencyAnalysis { | |
dependencies { | |
map.set(reversedMap) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment