Add support for Gradle version catalog dependencies #4704
+249
−5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #4521
Issue
Gradle parser reports incomplete Maven PURLs (e.g.,
pkg:maven/androidx) when scanningbuild.gradlefiles that use version catalog references likelibs.androidx.appcompat.Approach
gradle/libs.versions.tomlto resolve version catalog aliases to full Maven coordinatesDEPENDENCY-VERSION-CATALOGgrammar rule to matchlibs.x.y.zpatterns in the existing pygmars parserBefore Fix:
implementation libs.androidx.appcompatpkg:maven/androidx❌ (incomplete)After Fix:
implementation libs.androidx.appcompatpkg:maven/androidx.appcompat/appcompat@1.6.1✅ (complete)Summary of Changes
Modified:
src/packagedcode/build_gradle.pyparse_version_catalog()function to read and parselibs.versions.tomlget_dependencies()to resolve catalog referencestests/packagedcode/test_build_gradle.pyAdded:
tests/packagedcode/data/build_gradle/groovy/fdroid-version-catalog/Implementation Details
Studied existing gradle parser patterns and followed the codebase conventions:
DEPENDENCY-1throughDEPENDENCY-4patterns)Verification
All tests pass
BEFORE FIX
AFTER FIX
Ready for review. Happy to address any feedback or make adjustments as needed
Tasks