-
Notifications
You must be signed in to change notification settings - Fork 0
Commands
All four CLIs share common flags: --engine static|dynamic|auto, --config <path>, --quiet, and --json. All output on this page was generated by running the commands against tests/fixtures/leaf_coupling (10 modules), so it's reproducible.
The sample project
leaf_couplinghas this graph:app → cart, checkout, core;cart, checkout → payments;payments → core, database, model, network, util;database, model, network, util → core; andlegacy → app.
gradle-analyzer <path_to_module>| Flag | Description | Default |
|---|---|---|
--format plantuml|mermaid|dot|ascii|json|all |
Output format | all |
--output-dir <dir> |
Output directory | diagrams |
--engine static|dynamic|auto |
Extraction engine | static |
--exclude <module> |
Exclude a module (repeatable) | — |
--focus <module[,module]> |
Root module(s) for the dependency tree | — |
--depth N|all |
Tree depth: integer ≥ 1 or all
|
all |
--config <path> |
Path to analyzer_config.json
|
auto-detect |
--quiet |
Suppress progress output | off |
--json |
Dump JSON to stdout | off |
Generates: diagrams/gradle-dependencies.puml · .mmd · gradle-report.txt · gradle-dependencies.json (with --format json or all)
Real output
$ gradle-analyzer tests/fixtures/leaf_coupling
🚀 Analizador de Dependencias via Gradle
======================================================================
📁 Escaneando módulos en: .../tests/fixtures/leaf_coupling
• app
• cart
• checkout
• core
• database
• legacy
• model
• network
• payments
• util
✓ 10 módulos encontrados
🔍 Analizando dependencias (motor: static)...
✓ app: 3 dependencia(s)
✓ cart: 1 dependencia(s)
✓ checkout: 1 dependencia(s)
○ core: sin dependencias internas
✓ database: 1 dependencia(s)
✓ legacy: 1 dependencia(s)
✓ model: 1 dependencia(s)
✓ network: 1 dependencia(s)
✓ payments: 5 dependencia(s)
✓ util: 1 dependencia(s)
✓ Análisis completado: 15 dependencias detectadas
📊 Generando archivos...
======================================================================
✓ PlantUML: diagrams/gradle-dependencies.puml
✓ Mermaid: diagrams/gradle-dependencies.mmd
✓ Reporte: diagrams/gradle-report.txt
✓ JSON: diagrams/gradle-dependencies.jsonThe text report (gradle-report.txt) lists dependencies per module and statistics:
======================================================================
DEPENDENCIAS POR MÓDULO
======================================================================
📦 app
→ cart [implementation]
→ checkout [implementation]
→ core [implementation]
📦 payments
→ core [implementation]
→ database [implementation]
→ model [implementation]
→ network [implementation]
→ util [implementation]
...
======================================================================
ESTADÍSTICAS
======================================================================
Módulos más utilizados:
• core: usado por 6 módulo(s)
• payments: usado por 2 módulo(s)
...
Módulos sin dependencias internas (1):
• core
Módulos no utilizados por otros (1):
• legacy
JSON output (--json or --format json)
$ gradle-analyzer tests/fixtures/leaf_coupling --json --quiet{
"schema_version": 1,
"tool": "internal",
"focus": null,
"depth": null,
"modules": ["app", "cart", "checkout", "core", "database", "legacy", "model", "network", "payments", "util"],
"dependencies": [
{"from": "app", "to": "cart", "scope": "implementation"},
{"from": "app", "to": "checkout", "scope": "implementation"},
{"from": "app", "to": "core", "scope": "implementation"},
{"from": "payments", "to": "core", "scope": "implementation"},
{"from": "payments", "to": "database", "scope": "implementation"}
],
"cycles": []
}The
dependenciesarray is shown truncated; the real output includes all 15 edges. When--focusand--depthare used, the JSON reflects the rooted subtree, not the full graph.
Examples:
gradle-analyzer /path/to/project/payments --format mermaid # Mermaid only
gradle-analyzer /path/to/project/payments --exclude test-utils # exclude a module
gradle-analyzer /path/to/project/payments --focus payments --depth 2 # rooted tree, depth 2
gradle-analyzer /path/to/project/payments --output-dir docs/diagrams # custom output dir
gradle-analyzer /path/to/project/payments --json --quiet # JSON to stdoutgradle-externals <project_root> <module_name>Answers: "which modules outside my feature are consuming it?" — essential before a refactor.
| Flag | Description | Default |
|---|---|---|
--format plantuml|mermaid|dot|ascii|json|all |
Output format | all |
--output-dir <dir> |
Output directory | external-calls |
--engine static|dynamic|auto |
Extraction engine | static |
--depth N|all |
Caller cone levels: integer ≥ 1 or all
|
all |
--config <path> |
Custom config | auto-detect |
--quiet |
Suppress progress output | off |
--json |
Dump JSON to stdout | off |
Generates: external-calls/<module>-external-calls.puml · .mmd · <module>-external-report.txt · <module>-external-calls.json (with --format json or all)
Real output
$ gradle-externals tests/fixtures/leaf_coupling payments
======================================================================
ANÁLISIS DE LLAMADAS EXTERNAS A PAYMENTS
======================================================================
Proyecto: .../tests/fixtures/leaf_coupling
Módulo analizado: payments
======================================================================
MÓDULOS EXTERNOS QUE LLAMAN
======================================================================
📦 cart
└─→ payments [implementation]
📦 checkout
└─→ payments [implementation]
======================================================================
ESTADÍSTICAS
======================================================================
Módulos más llamados desde fuera:
• payments: 2 llamada(s)JSON output (--json)
{
"schema_version": 1,
"tool": "external",
"target": "payments",
"external_callers": [
{"module": "cart", "scope": "implementation"},
{"module": "checkout", "scope": "implementation"}
],
"caller_cone": {
"cart": 1,
"checkout": 1,
"app": 2,
"legacy": 3
}
}
external_callerslists direct callers with their scope.caller_conemaps each transitive caller to its level (1 = direct, 2 = one hop away, etc.).
gradle-sanity <path_to_module>| Flag | Description | Default |
|---|---|---|
--focus <module[,module]> |
Focus the report on these modules | — |
--output-dir <dir> |
Output directory | sanity |
--engine static|dynamic|auto |
Extraction engine | static |
--config <path> |
Custom config | auto-detect |
--quiet |
Suppress progress output | off |
--json |
Dump JSON to stdout | off |
--fail-on-cycle |
exit 1 if any cycle is detected |
off |
--fail-on-score-below N |
exit 1 if score is below N |
off |
Generates: sanity/sanity-report.txt · sanity/sanity-report.json (always written alongside the report)
For details on what each metric measures and how the score is calculated, see Sanity Metrics.
Real output (metrics table)
$ gradle-sanity tests/fixtures/leaf_coupling
...
======================================================================
MÉTRICAS POR MÓDULO
======================================================================
Módulo Ca Ce I Estado
────────────────────────────── ──── ──── ────── ──────────────────────────────
app 1 3 0.75 🟠 Moderadamente inestable
cart 1 1 0.50 🟡 Moderadamente estable
checkout 1 1 0.50 🟡 Moderadamente estable
core 6 0 0.00 🟢 Estable
database 1 1 0.50 🟡 Moderadamente estable
legacy 0 1 1.00 🔴 Inestable (módulo hoja)
model 1 1 0.50 🟡 Moderadamente estable
network 1 1 0.50 🟡 Moderadamente estable
payments 2 5 0.71 🟠 Moderadamente inestable
util 1 1 0.50 🟡 Moderadamente estable======================================================================
PUNTUACIÓN DE SANIDAD
======================================================================
Puntaje base: 100
Ciclos (0 × 20 pts): -0
Violaciones SDP (0 × 10 pts): -0
Api innecesario (0 × 5 pts): -0
Fan-out excesivo (0 × 3 pts): -0
Versiones hardcodeadas (0 × 2 pts): -0
Lógica compartida mal ubicada (2 issue(s)): -0
───────────────────────────────────────────────────
PUNTUACIÓN FINAL: 100 / 100
Resultado: 🟢 Excelente — arquitectura de dependencias muy sanaJSON output (--json, ideal for CI)
$ gradle-sanity tests/fixtures/leaf_coupling --json --quiet{
"schema_version": 1,
"tool": "sanity",
"path": "tests/fixtures/leaf_coupling",
"score": 100,
"modules": {
"core": { "ca": 6, "ce": 0, "I": 0.0 },
"payments": { "ca": 2, "ce": 5, "I": 0.71 },
"legacy": { "ca": 0, "ce": 1, "I": 1.0 }
},
"cycles": [],
"sdp_violations": [],
"api_issues": [],
"fan_out_issues": [],
"version_issues": [],
"orphan_modules": [],
"coupling_issues": [
{ "module": "app", "kind": "app", "I": 0.75, "ca": 1, "max_ca": 0 },
{ "module": "payments", "kind": "feature", "I": 0.71, "ca": 2, "max_ca": 1 }
]
}The
modulesblock is shown truncated; the real JSON includes all 10 modules.
gradle-impact <project_root> <module>Answers: "which modules break if I change this module?" Builds the inverted dependency graph and runs BFS from the target, assigning a level to each impacted module (1 = direct, 2 = transitive, etc.).
| Flag | Description | Default |
|---|---|---|
--format plantuml|mermaid|dot|ascii|json|all |
Output format | all |
--output-dir <dir> |
Output directory | impact |
--engine static|dynamic|auto |
Extraction engine | static |
--config <path> |
Custom config | auto-detect |
--quiet |
Suppress progress output | off |
--json |
Dump JSON to stdout | off |
Generates: impact/<module>-impact.puml · .mmd · <module>-impact-report.txt · <module>-impact.json (with --format json or all)
Real output
$ gradle-impact tests/fixtures/leaf_coupling core
======================================================================
IMPACTO DE CAMBIOS EN: CORE
======================================================================
Proyecto : .../tests/fixtures/leaf_coupling
Módulo : core
Total módulos : 10
Nivel 1 — dependientes directos (6):
• app
• database
• model
• network
• payments
• util
Nivel 2 — dependientes transitivos (3):
• cart
• checkout
• legacy
🔥 Impacto total: 9 módulos (90% del proyecto)
Cambiar core requiere verificar 9 módulo(s).In
leaf_coupling,coreis the base module: touching it impacts 90% of the project. This is exactly what the sanity metrics flag withCa=6, I=0.00(very stable → many depend on it).
All four tools emit structured JSON with a stable schema. Key fields:
| Field | Present in | Description |
|---|---|---|
schema_version |
all | Schema version (currently 1). Increment on breaking changes. |
tool |
all |
"internal" · "external" · "impact" · "sanity"
|
cycles |
internal, sanity | Array of cycle arrays (empty = no cycles) |
focus |
internal | Root module(s) used, or null
|
depth |
internal, external | Depth limit applied, or null
|
caller_cone |
external | Map of module → level for transitive callers |
score |
sanity | Integer 0–100 |
Use --json to get the JSON on stdout (for pipes), or --format json to write it as a file in the output directory.
The .puml and .mmd files are plain text; to convert them to PNG/SVG:
plantuml diagrams/gradle-dependencies.puml # PNG
plantuml -tsvg diagrams/gradle-dependencies.puml # SVG (scalable)brew install plantuml # macOS
sudo apt install plantuml # Ubuntu/Debian
choco install plantuml # Windows.mmd files render directly on GitHub (```mermaid blocks) or at mermaid.live.