Skip to content

bug(gradle): MODULE_DEPENDS_ON is empty on multi-module Android projects; settings.gradle never parsed #1603

Description

@Shashankss1205

Split out of #1595 (report 6 of 9) — filed by @rrodriguesNutrium, credit to them. Described as the most consequential one for multi-module Android projects.

Three compounding defects in gradle.py:

1. _SETTINGS_INCLUDE_PATTERN (gradle.py:22) is dead code. It appears exactly once in the file — its own definition. There is no settings.gradle parsing pass at all, so declared module includes never reach the graph.

2. The path character classes omit :. Both _SETTINGS_INCLUDE_PATTERN and _PROJECT_DEP_PATTERN (gradle.py:19) use ([\\w.\\-/]+), which cannot match a colon:

include(":feature:symptoms")                   -> NO MATCH
include(":app")                                -> app
implementation(project(":feature:symptoms"))   -> NO MATCH
implementation(project(":core:network"))       -> NO MATCH

Only single-segment modules match, so on a standard Android multi-module layout MODULE_DEPENDS_ON is empty — edges missing, failing silently.

3. Module identity is the leaf directory. gradle.py:47 uses module_name = gradle_path.parent.name, so :feature:a:impl and :feature:b:impl both become impl and collide on GradleModule's MERGE key (writer.py:1533) — two distinct modules merge into one node.

A fix needs : in the path character classes, a real settings.gradle pass, and canonical :a:b:c identity used consistently on both the nodes and both endpoints of the dependency lookups (writer.py:1543-1560) — changing one side alone silently yields zero edges.

Also noted while there: _DEP_PATTERN (gradle.py:13) does not match Kotlin-DSL parenthesized dependency literals, so implementation(\"group:artifact:version\") declarations are missed for ExternalLibrary extraction.

The reporter has a working fix for the identity and settings-parsing parts on a local branch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status
    Backlog tasks
    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions