Skip to content

Resolves PR #1 issues :) #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 31 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,36 @@ Maven dependency mapper
Stores dependency relationships in a graph database (neo4j)
-----------------------------------------------------------

Local environment:
------------------
* [Example project and Screenshots](documentation/README.md)

Stores dependency relationships in a graph database (neo4j). This maven plugin provides two operations:

```
# stores all dependencies in neo4j graph db
mvn dependency-mapper:store

# reads all reverse dependencies from neo4j graph db
mvn dependency-mapper:read
```

### Local environment

* install neo4j http://www.neo4j.org/develop#install
* checkout this repo
* mvn install
* Go to a maven project and run "mvn no.finntech:dependency-mapper-maven-plugin:1.0-SNAPSHOT:store"
* Do a "mvn no.finntech:dependency-mapper-maven-plugin:1.0-SNAPSHOT:read"
* Go to a maven project and run *mvn dependency-mapper:store*
* To find out who is depending on your project do "mvn dependency-mapper:read"

Override neo4j server setting with `-Dneo4jServer=http://yourserver:yourport`, defaults to `http://localhost:7474`

Override neo4j server setting with -Dneo4jServer=http://yourserver:yourport, defaults to http://localhost:7474
Optional authentication:
`-Dneo4jUser` and `-Dneo4jPass`

### Example output

```
mvn nodependency-mapper:read

Example output:
---------------
mvn no.finntech:dependency-mapper-maven-plugin:1.0-SNAPSHOT:read
<pre>
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
Expand All @@ -30,32 +45,7 @@ mvn no.finntech:dependency-mapper-maven-plugin:1.0-SNAPSHOT:read
[INFO] no.finntech.cop:client:1.1-SNAPSHOT -> no.finntech:commons-thrift-client:3.1.1
[INFO] no.finntech.oppdrag-services:iad-model:2013.2-SNAPSHOT -> no.finntech:commons-thrift-client:3.4.3
[INFO] no.finntech:minfinn:2013.2-SNAPSHOT -> no.finntech:commons-thrift-client:3.4.3
[INFO] no.finntech:service-user:2013.2-SNAPSHOT -> no.finntech:commons-thrift-client:3.4.3
[INFO] no.finntech:service-oppdrag:2013.2-SNAPSHOT -> no.finntech:commons-thrift-client:3.4.3
[INFO] no.finntech:kernel:2013.2-SNAPSHOT -> no.finntech:commons-thrift-client:3.4.3
[INFO] no.finntech.travelstats:travelstats-collector:1.7.6-SNAPSHOT -> no.finntech:commons-thrift-client:3.2.7
[INFO] no.finntech.travelstats:travelstats-server:1.7.6-SNAPSHOT -> no.finntech:commons-thrift-client:3.2.7
[INFO] no.finntech.travelstats:travelstats-db:1.7.6-SNAPSHOT -> no.finntech:commons-thrift-client:3.2.7
[INFO] no.finntech.travelstats:travelstats-common:1.7.6-SNAPSHOT -> no.finntech:commons-thrift-client:3.2.7
[INFO] no.finntech.travelstats:travelstats-api:1.7.6-SNAPSHOT -> no.finntech:commons-thrift-client:3.2.7
[INFO] no.finntech:travelstats:1.7.6-SNAPSHOT -> no.finntech:commons-thrift-client:3.2.7
[INFO] no.finntech:kart:12.10.1-SNAPSHOT -> no.finntech:commons-thrift-client:3.2.7
[INFO] no.finntech:currency-client:2.1-SNAPSHOT -> no.finntech:commons-thrift-client:3.2.7
[INFO] no.finntech.attribute:attribute-client:1.2-SNAPSHOT -> no.finntech:commons-thrift-client:3.2.7
[INFO] no.finntech.vetting:vetting-client:3.6-SNAPSHOT -> no.finntech:commons-thrift-client:3.4.2
[INFO] no.finntech.user:user-client:0.6.4-SNAPSHOT -> no.finntech:commons-thrift-client:3.4.2
[INFO] no.finntech.user:user-server:0.6.4-SNAPSHOT -> no.finntech:commons-thrift-client:3.4.2
[INFO] no.finntech.objectrelation:objectrelation-client:1.3-SNAPSHOT -> no.finntech:commons-thrift-client:3.4.2
[INFO] no.finntech:myinbox-client:1.2.2-SNAPSHOT -> no.finntech:commons-thrift-client:3.4.2
[INFO] no.finntech.mail:mail-test-api:3.4-SNAPSHOT -> no.finntech:commons-thrift-client:3.4.2
[INFO] no.finntech.mail:mail-client:3.4-SNAPSHOT -> no.finntech:commons-thrift-client:3.4.2
[INFO] no.finntech.api:finn-api-war:2013.2-SNAPSHOT -> no.finntech:commons-thrift-client:3.4.2
[INFO] no.finntech.cardata:cardata-client:1.4-SNAPSHOT -> no.finntech:commons-thrift-client:3.4.2
[INFO] no.finntech.broadcast:broadcast-client:3.1.2-SNAPSHOT -> no.finntech:commons-thrift-client:3.0.1
[INFO] no.finntech:cms-client:1.0-SNAPSHOT -> no.finntech:commons-thrift-client:3.2.4
[INFO] no.finntech:countstatistics-count-reduce:3.6-SNAPSHOT -> no.finntech:commons-thrift-client:3.3
[INFO] no.finntech:countstatistics-count-listener:3.6-SNAPSHOT -> no.finntech:commons-thrift-client:3.3
[INFO] no.finntech:countstatistics-count-impl:3.6-SNAPSHOT -> no.finntech:commons-thrift-client:3.3
...
[INFO] no.finntech.attribute:attribute-client:1.2.3-SNAPSHOT -> no.finntech:commons-thrift-client:3.3
[INFO] no.finntech.organisation:organisation-client:1.6-SNAPSHOT -> no.finntech:commons-thrift-client:3.4
[INFO] ------------------------------------------------------------------------
Expand All @@ -65,12 +55,13 @@ mvn no.finntech:dependency-mapper-maven-plugin:1.0-SNAPSHOT:read
[INFO] Finished at: Thu Jan 31 09:50:19 CET 2013
[INFO] Final Memory: 9M/211M
[INFO] ------------------------------------------------------------------------
</pre>
```

### To include this in your project

To include this in your project:
--------------------------------
put this in you pom.xml
Put this in you pom.xml

```
<plugin>
<groupId>no.finntech</groupId>
<artifactId>dependency-mapper-maven-plugin</artifactId>
Expand All @@ -79,5 +70,6 @@ put this in you pom.xml
<neo4jServer>http://neo4jServer:7474</neo4jServer>
</configuration>
</plugin>
```

Now you can use the plugin with mvn dependency-mapper:store and mvn dependency-mapper:read
Binary file added documentation/1-dependency-graph-for-project1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added documentation/2-project1-node.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added documentation/3-cyclic-dependencies.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added documentation/4-cycle-detection.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added documentation/5-neo4j-results-table-view.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
83 changes: 83 additions & 0 deletions documentation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
## Running analysis on project

```
cd documentation/dependency-test/project1
$ mvn dependency-mapper:read
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Quick Start Archetype 1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- dependency-mapper-maven-plugin:1.0-SNAPSHOT:read (default-cli) @ project1 ---
[INFO] Resolving reverse dependencies
[INFO] de.codecentric:project3:3.2.1 -> de.codecentric:project1:1.0
[INFO] de.codecentric:project4:2.1.0 -> de.codecentric:project1:1.0
[INFO] de.codecentric:project5:1.1.0 -> de.codecentric:project1:1.0
[INFO] de.codecentric:project5:1.0 -> de.codecentric:project1:1.0
[INFO] de.codecentric:project4:1.0 -> de.codecentric:project1:1.0
[INFO] de.codecentric:project3:1.0 -> de.codecentric:project1:1.0
[INFO] de.codecentric:project2:1.0 -> de.codecentric:project1:1.0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.820s
[INFO] Finished at: Wed Dec 03 08:55:42 CET 2014
[INFO] Final Memory: 5M/15M
[INFO] ------------------------------------------------------------------------
```

## Graph Database screenshots

![dependency graphfor project1](1-dependency-graph-for-project1.png)

![project1 reverse dependencies](2-project1-node.png)

![cyclic dependencies](3-cyclic-dependencies.png)

![cycle detection](4-cycle-detection.png)

![neo4j results table view](5-neo4j-results-table-view.png)

## CYPHER Queries

Delete all nodes and relations

```
MATCH (n)
OPTIONAL MATCH (n)-[r]-()
DELETE n,r
```

Get all projects that have a 'COMPILE' dependency on 'project1' by name

```
MATCH (n)-[:COMPILE]-(dependencies)
WHERE n.name = "de.codecentric:project1:1.0"
RETURN n, dependencies
```

Get all projects that have a 'COMPILE' dependency on 'project1' by groupId and artifactId

```
MATCH (n)-[:COMPILE]-(dependencies)
WHERE n.groupId = "de.codecentric"
AND n.artifactId = "project1"
RETURN n, dependencies
```

Get all cycles for COMPILE dependencies

```
START n = node(*)
MATCH p = n-[:COMPILE*]->n
RETURN p
```

Get all cycles for COMPILE dependencies

```
START n = node(*)
MATCH p = n-[:COMPILE|RUNTIME|PROVIDED|TEST*]->n
RETURN p
```
31 changes: 31 additions & 0 deletions documentation/dependency-test/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>de.codecentric</groupId>
<artifactId>project-modules</artifactId>
<packaging>pom</packaging>
<version>1.0</version>

<modules>
<module>project1</module>
<module>project2</module>
<module>project3</module>
<module>project4</module>
</modules>

<build>
<plugins>
<plugin>
<groupId>no.finntech</groupId>
<artifactId>dependency-mapper-maven-plugin</artifactId>
<version>1.1</version>
<configuration>
<neo4jServer>http://localhost:7474</neo4jServer>
</configuration>
</plugin>
</plugins>
</build>

</project>
34 changes: 34 additions & 0 deletions documentation/dependency-test/project1/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>de.codecentric</groupId>
<artifactId>project1</artifactId>
<version>1.0</version>
<packaging>jar</packaging>

<!-- run mvn install on project5 first -->
<dependencies>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>project5</artifactId>
<version>1.0</version>
</dependency>
</dependencies>

<!-- In real projects you would move this configuration to a parent pom -->
<build>
<plugins>
<plugin>
<groupId>no.finntech</groupId>
<artifactId>dependency-mapper-maven-plugin</artifactId>
<version>1.1</version>
<configuration>
<neo4jServer>http://localhost:7474</neo4jServer>
</configuration>
</plugin>
</plugins>
</build>

</project>
33 changes: 33 additions & 0 deletions documentation/dependency-test/project2/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>de.codecentric</groupId>
<artifactId>project2</artifactId>
<packaging>jar</packaging>
<version>1.0</version>

<dependencies>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>project1</artifactId>
<version>1.0</version>
</dependency>
</dependencies>

<!-- In real projects you would move this configuration to a parent pom -->
<build>
<plugins>
<plugin>
<groupId>no.finntech</groupId>
<artifactId>dependency-mapper-maven-plugin</artifactId>
<version>1.1</version>
<configuration>
<neo4jServer>http://localhost:7474</neo4jServer>
</configuration>
</plugin>
</plugins>
</build>

</project>
33 changes: 33 additions & 0 deletions documentation/dependency-test/project3/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>de.codecentric</groupId>
<artifactId>project3</artifactId>
<packaging>jar</packaging>
<version>1.0</version>

<dependencies>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>project1</artifactId>
<version>1.0</version>
</dependency>
</dependencies>

<!-- In real projects you would move this configuration to a parent pom -->
<build>
<plugins>
<plugin>
<groupId>no.finntech</groupId>
<artifactId>dependency-mapper-maven-plugin</artifactId>
<version>1.1</version>
<configuration>
<neo4jServer>http://localhost:7474</neo4jServer>
</configuration>
</plugin>
</plugins>
</build>

</project>
33 changes: 33 additions & 0 deletions documentation/dependency-test/project4/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>de.codecentric</groupId>
<artifactId>project4</artifactId>
<packaging>jar</packaging>
<version>1.0</version>

<dependencies>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>project1</artifactId>
<version>1.0</version>
</dependency>
</dependencies>

<!-- In real projects you would move this configuration to a parent pom -->
<build>
<plugins>
<plugin>
<groupId>no.finntech</groupId>
<artifactId>dependency-mapper-maven-plugin</artifactId>
<version>1.1</version>
<configuration>
<neo4jServer>http://localhost:7474</neo4jServer>
</configuration>
</plugin>
</plugins>
</build>

</project>
33 changes: 33 additions & 0 deletions documentation/dependency-test/project5-with-cycle/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>de.codecentric</groupId>
<artifactId>project5</artifactId>
<version>1.0</version>
<packaging>jar</packaging>

<dependencies>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>project4</artifactId>
<version>1.0</version>
</dependency>
</dependencies>

<!-- In real projects you would move this configuration to a parent pom -->
<build>
<plugins>
<plugin>
<groupId>no.finntech</groupId>
<artifactId>dependency-mapper-maven-plugin</artifactId>
<version>1.1</version>
<configuration>
<neo4jServer>http://localhost:7474</neo4jServer>
</configuration>
</plugin>
</plugins>
</build>

</project>
Loading