Skip to content

How it works

pfranccino edited this page Jun 15, 2026 · 1 revision

How it works

Module detection

  1. If settings.gradle.kts or settings.gradle exists at the root, it is used as the source of truth (extracts include(":module") entries).
  2. If not, rglob() finds all build.gradle* files as a fallback.
  3. Paths → names: payments/homepayments:home.

Dependency extraction

  1. Reads each build.gradle / build.gradle.kts.
  2. For .kts: uses tree-sitter (if installed) to get a real AST — handles multiline, comments, and named parameters. Falls back to regex if not available.
  3. For .gradle: preprocesses the content (strips // and /* */ comments, collapses multiline declarations) and applies regex.
  4. Supports the classic format (project(":foo:bar")) and type-safe accessors (projects.foo.barBaz).
  5. Exact matching against the list of known modules — no prefix heuristics.

The dynamic engine (--engine dynamic) replaces steps 1–4 by running Gradle and reading what it resolves. See Static vs Dynamic Engine.

Diagram generation

  1. Classifies modules by type (common, gateway, features).
  2. Applies colors based on classification.
  3. Generates PlantUML/Mermaid grouped by visual category.
  4. Marks modules involved in cycles in red.

Adjusting diagram spacing

In gradle_analyzer.py, function generate_plantuml():

"skinparam nodesep 150",    # Horizontal
"skinparam ranksep 150",    # Vertical
"skinparam padding 30",     # Internal
Style nodesep / ranksep / padding
Compact 60 / 60 / 10
Balanced 100 / 100 / 20
Spacious 150 / 150 / 30

Project structure

android-gradle-analyzer/
├── README.md
├── EXAMPLES.md
├── CHANGELOG.md · LICENSE · CONTRIBUTING.md
├── pyproject.toml               ← single source of dependencies
├── menu.py                      ← wrapper: python3 menu.py
├── menu/                        ← interactive menu package
│   ├── actions.py · branding.py · exporter.py
│   ├── prompts.py · state.py · ui.py
├── analyzer_utils.py            ← shared utilities
├── dependency_engine.py         ← dynamic engine (via Gradle)
├── analyzer_config.example.json ← example config
├── gradle_analyzer.py           ← tool 1: internal dependencies
├── external_callers.py          ← tool 2: external callers
├── gradle_sanity.py             ← tool 3: sanity + score
├── gradle_impact.py             ← tool 4: change impact
├── examples/
│   └── github-actions-dependency-health.yml
├── scripts/
│   ├── bump_version.py          ← syncs version and guides the release
│   └── extract_changelog.py
└── tests/                       ← test suite + reproducible fixtures

Clone this wiki locally