Skip to content

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

Closed

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.

Activity

  1. github-actions commented on Aug 13, 2026

    @github-actions
    Contributor

    Hi! 👋 Join our CodeGraphContext Discord channel to collaborate: https://discord.gg/dR4QY32uYQ

  2. Shashankss1205 commented on Aug 13, 2026

    @Shashankss1205
    CollaboratorAuthor

    Partially fixed by #1621 (merged), which lands the module-identity half:

    • settings.gradle(.kts) is now actually parsed (_SETTINGS_INCLUDE_PATTERN is no longer dead code)
    • : added to the path character classes, so multi-segment paths match
    • modules identified by canonical Gradle path, so :feature:a:impl and :feature:b:impl no longer collide on the GradleModule primary key

    Verified on a four-module fixture: [':app', ':core:network', ':feature:other:impl', ':feature:symptoms'].

    Keeping this open, because the headline symptom — MODULE_DEPENDS_ON empty on multi-module Android projects — still reproduces on Kotlin DSL.

    gradle.py:168 requires whitespace between the configuration keyword and project(:

    r"""(\w+)\s+project\(['"]:([\w.\-/:]+)['"]\)"""

    Groovy implementation project(":core:network") matches; Kotlin DSL implementation(project(":core:network")) does not. Measured on two otherwise-identical fixtures:

    Groovy      modules=2  inter_module_deps=1   (:app -> :core:network)
    Kotlin DSL  modules=4  inter_module_deps=0
    

    Since build.gradle.kts is the modern Android default, the nodes are now right but the edges are still absent for most real projects. Same root cause as the _DEP_PATTERN gap noted in the original report, so both can be fixed together.

  3. moved this from Backlog tasks to In progress in CGC Progress Boardon Aug 18, 2026
  4. moved this from In progress to Done in CGC Progress Boardon Aug 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions