Git Product home page Git Product logo

neomvn's Introduction

Maven repository importer for Neo4j

This little nifty tool will allow you to import your local Maven repository information into a Neo4j graph, in particular dependencies between artifacts. You can then take this graph and put it into a Neo4j server, and perform Cypher queries on it. Or whatever else awesome you want to do.

WARNING: if you open webadmin and use the graph visualization, whatever you do don't click on "junit". Dependency explosion ahead. You have been warned.

Usage

  • Clone and build using Maven
  • Run the Main class from command line with location of Maven repo as argument. Example:
java -jar neomvn-1.0-SNAPSHOT.jar /Users/rickard/.m2/repository
  • This will import and index your local Maven repository into a Neo4j graph database created under "neomvn" directory, from where the tool was invoked.

  • Copy database into your own application or server, and perform awesome Cypher queries against it

Model

This is the model currently used:

  • Each groupId gets a corresponding node with property "groupId"
  • Each artifactId gets a corresponding node, and a HAS_ARTIFACTID to its groupId, and properties "groupId" and "artifactId"
  • Each version gets a corresponding node, and a HAS_VERSION to its artifactId, and properties "groupId","artifactId", "version" and "name"
  • Each dependency is modeled as a HAS_DEPENDENCY from the depending version/artifactId/groupId to the depended on version/artifactId/groupId. Scope and optional as properties
  • There are three indices: groups, artifacts, and versions. Search by "groupId", "artifactId", and "version" respectively, to find starting points for queries

Example queries

Here's a few sample queries you can try out:

Find all transitive dependencies of all artifacts Neo Technology has ever published:

start group=node:groups(groupId='org.neo4j')
match group-[:HAS_ARTIFACT]->artifact-[:HAS_VERSION]->version-[:HAS_DEPENDENCY*..5]->dependency
return distinct dependency;

Find all projects where any version depends on any artifact that Neo Technology has published:

start group=node:groups(groupId='org.neo4j')
match group-[:HAS_ARTIFACT]->artifact-[:HAS_VERSION]->version<-[:HAS_DEPENDENCY]-dependent
where left(dependent.groupId,9)<>group.groupId
return distinct dependent.artifactId, dependent.groupId;

Find which version of JUnit is the most popular:

start group=node:groups(groupId='junit')
match group-[:HAS_ARTIFACT]->artifact-[:HAS_VERSION]->version<-[:HAS_DEPENDENCY]-dependent
return version.version, count(dependent) as depCount
order by depCount desc

For the latest version of all artifacts, what version of JUnit do they use:

start group=node:groups('groupId:*')
match group-[:HAS_ARTIFACT]->artifact-[:HAS_VERSION]->version
with artifact, version
order by version.version desc
with artifact, head(collect(version)) as latestVersion
match latestVersion-[:HAS_DEPENDENCY]->dependency
where dependency.artifactId='junit'
return artifact.artifactId, latestVersion.version, dependency.version
order by dependency.version

What projects' latest artifacts transitively depend on an outdated version of Neo4j:

start group=node:groups('groupId:*')
match group-[:HAS_ARTIFACT]->artifact-[:HAS_VERSION]->version
where group.groupId<>'org.neo4j'
with artifact,version
order by version.version desc
with artifact, head(collect(version)) as latestVersion
match latestVersion-[:HAS_DEPENDENCY*..5]->dep
where dep.groupId='org.neo4j'
return distinct artifact.artifactId, latestVersion.groupId, latestVersion.version, dep.artifactId, dep.version
order by dep.version

License

This library is made available under the Apache Software License 2.0.

neomvn's People

Contributors

rickardoberg avatar

Watchers

ABHINAV KUMAR avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.