npm.io
0.1.1 • Published yesterday

gcyphrq-ext-maven-dependency-tree

Licence
MIT
Version
0.1.1
Deps
2
Size
20 kB
Vulns
0
Weekly
0

gcyphrq-ext-maven-dependency-tree

Maven dependency tree extension for gcyphrq.

Runs mvn dependency:tree -DoutputType=json on a Maven project and converts the resulting dependency graph into gcyphrq's in-memory format for Cypher querying.

Install

Global CLI install

npm install -g gcyphrq gcyphrq-ext-maven-dependency-tree
Project dependency install
npm install gcyphrq gcyphrq-ext-maven-dependency-tree

Prerequisites

  • Maven (mvn) must be installed and on your PATH, or the project must use the Maven Wrapper (mvnw).

Usage

CLI

Point the extension at a pom.xml file:

gcyphrq -g path/to/project/pom.xml --ext maven-dependency-tree -e 'MATCH (n) RETURN n'
Library
import { convertWithExtension, executeQuery } from 'gcyphrq';

const graphData = await convertWithExtension('maven-dependency-tree', {
  filePath: 'path/to/project/pom.xml',
});

const results = await executeQuery(graphData, 'MATCH (n) RETURN n');

Graph model

Element Attributes
Nodes label: "MavenArtifact", groupId, artifactId, version, type, scope, optional, classifier (if present)
Edges type: "DEPENDS_ON", scope — directed from parent → dependency

Shared transitive dependencies are deduplicated: a single node is created per unique Maven coordinate (groupId:artifactId:version[:classifier]).

Node key format
groupId:artifactId:version[:classifier]

For example: org.junit.jupiter:junit-jupiter-engine:5.14.4

Examples

List all dependencies
gcyphrq -g pom.xml --ext maven-dependency-tree -e 'MATCH (n:MavenArtifact) RETURN n.groupId, n.artifactId, n.version'
Find test-only dependencies
gcyphrq -g pom.xml --ext maven-dependency-tree -e 'MATCH (n:MavenArtifact {scope: "test"}) RETURN n.groupId, n.artifactId'
Find dependencies of a specific artifact
gcyphrq -g pom.xml --ext maven-dependency-tree -e 'MATCH (a:MavenArtifact {artifactId: "mockito-core"})-[r:DEPENDS_ON]->(dep) RETURN dep.groupId, dep.artifactId, dep.version'
Find shared transitive dependencies (depended on by 2+ artifacts)
gcyphrq -g pom.xml --ext maven-dependency-tree -e 'MATCH (a)-[:DEPENDS_ON]->(dep) WITH dep, count(a) AS parents WHERE parents > 1 RETURN dep.groupId, dep.artifactId, dep.version, parents'
Dependency depth from root
gcyphrq -g pom.xml --ext maven-dependency-tree -e 'MATCH path=(root:MavenArtifact)-[:DEPENDS_ON*]->(leaf) WHERE NOT ((leaf)-[:DEPENDS_ON]->()) RETURN leaf.artifactId, length(path) AS depth ORDER BY depth DESC'

License

MIT