Repository navigation
feat(scanners): add support for simple Gradle version catalog aliases - #10
Open
Prabhat0770 wants to merge 1 commit into
Open
Prabhat0770 wants to merge 1 commit into
Prabhat0770 wants to merge 1 commit into
Conversation
Support reading dependencies declared via Gradle version catalog aliases (gradle/libs.versions.toml) in build.gradle and build.gradle.kts. - Parse [versions] and [libraries] tables from version catalog TOML - Resolve aliases defined via inline version strings, version.ref references, module coordinates, and group/name attributes - Recognize libs.<alias> declarations across supported Gradle configurations (implementation, api, testImplementation, compileOnly, etc.) - Keep unsupported expressions and unresolved references unparsed without guessing - Add fixture-based tests and update docs/languages.md Fixes ayushdoesdev#4
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
This PR adds support for resolving simple Gradle version catalog aliases (
gradle/libs.versions.toml) inbuild.gradleandbuild.gradle.ktsfiles.Context & Problem
Previously,
JavaAnalyzeronly extracted Gradle dependencies declared with literalgroup:artifact:versionstrings or map arguments. In modern Gradle projects utilizing version catalogs, dependencies declared asimplementation(libs.androidx.core)orapi(libs.some.lib)were missed during scans.Changes
Catalog Parser (
_parse_version_catalog):[versions]and[libraries]fromgradle/libs.versions.toml(and*.versions.toml).version = "..."), version references (version.ref = "..."), and module/group-name formats.version = None) rather than guessed.Gradle Script Scanner (
_parse_gradle):libs.<alias>references for all supported Gradle configurations (implementation,api,testImplementation,compileOnly,runtimeOnly,kapt, etc.).libs.foo.bar.get()) and unmapped aliases unresolved.Manifest Scanner (
parse_dependencies):gradle/libs.versions.tomland records it infiles_found._parse_gradle.Documentation:
docs/languages.mdto reflect catalog alias support and current limitations.Testing
backend/tests/scanners/test_java_analyzer.py:test_parse_version_catalog_resolves_inline_and_ref_versions: Verifies inline version,version.ref, shorthand strings, and unresolved ref handling.test_parse_gradle_resolves_catalog_aliases_and_supported_configurations: Verifies all configurations, dev markers, literal co-existence, and ignoring complex expressions.test_parse_dependencies_with_gradle_version_catalog: End-to-end repository fixture scan withgradle/libs.versions.tomlandbuild.gradle.kts.ruff check(100% pass rate).Closes #4