├── .gitignore ├── src └── main │ └── java │ └── no │ └── finntech │ ├── HelpMojo.java │ ├── MavenRelationships.java │ ├── ReverseDependencyMojo.java │ ├── ArtifactHelper.java │ └── StoreGraphDependencyMojo.java ├── README.md ├── pom.xml └── LICENSE.txt /.gitignore: -------------------------------------------------------------------------------- 1 | atlassian-ide-plugin.xml 2 | *.iml 3 | target 4 | .idea 5 | -------------------------------------------------------------------------------- /src/main/java/no/finntech/HelpMojo.java: -------------------------------------------------------------------------------- 1 | /* Copyright (2013) FINN.no AS 2 | * 3 | * This is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version, with the Classpath Exception. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | package no.finntech; 18 | 19 | import org.apache.maven.plugin.AbstractMojo; 20 | import org.apache.maven.plugin.MojoExecutionException; 21 | import org.apache.maven.plugin.MojoFailureException; 22 | 23 | /** 24 | * Goal which reads reverse dependency trees from a neo4j database 25 | * 26 | * @goal help 27 | * @threadSafe 28 | */ 29 | public class HelpMojo extends AbstractMojo{ 30 | 31 | @Override 32 | public void execute() throws MojoExecutionException, MojoFailureException { 33 | getLog().info("target:help - prints this helptext"); 34 | getLog().info(""); 35 | getLog().info("target:store - stores dependency data in neo4j."); 36 | getLog().info("\tparameters: neo4jServer (defaults to http://localhost:7474)"); 37 | getLog().info(""); 38 | getLog().info("target:read - reads dependant artifacts from your neo4j database"); 39 | getLog().info("\tparameters: neo4jServer (defaults to http://localhost:7474)"); 40 | } 41 | } 42 | 43 | -------------------------------------------------------------------------------- /src/main/java/no/finntech/MavenRelationships.java: -------------------------------------------------------------------------------- 1 | /* Copyright (2013) FINN.no AS 2 | * 3 | * This is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version, with the Classpath Exception. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | package no.finntech; 18 | 19 | import org.neo4j.graphdb.RelationshipType; 20 | 21 | public enum MavenRelationships implements RelationshipType { 22 | UNKONWN, 23 | COMPILE, 24 | PROVIDED, 25 | RUNTIME, 26 | TEST, 27 | SYSTEM, 28 | PLUGIN, 29 | IMPORT, 30 | PARENT; 31 | 32 | public static MavenRelationships getByName(String name) { 33 | if (name.equalsIgnoreCase("COMPILE")) { 34 | return COMPILE; 35 | } else if (name.equalsIgnoreCase("PROVIDED")) { 36 | return PROVIDED; 37 | } else if (name.equalsIgnoreCase("RUNTIME")) { 38 | return RUNTIME; 39 | } else if (name.equalsIgnoreCase("TEST")) { 40 | return TEST; 41 | } else if (name.equalsIgnoreCase("SYSTEM")) { 42 | return SYSTEM; 43 | } else if (name.equalsIgnoreCase("PLUGIN")) { 44 | return PLUGIN; 45 | } else if (name.equalsIgnoreCase("IMPORT")) { 46 | return IMPORT; 47 | } else if (name.equalsIgnoreCase("PARENT")) { 48 | return PARENT; 49 | } else { 50 | return UNKONWN; 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/no/finntech/ReverseDependencyMojo.java: -------------------------------------------------------------------------------- 1 | /* Copyright (2013) FINN.no AS 2 | * 3 | * This is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version, with the Classpath Exception. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | package no.finntech; 18 | 19 | import org.apache.maven.plugin.AbstractMojo; 20 | import org.apache.maven.plugin.MojoExecutionException; 21 | import org.apache.maven.plugin.MojoFailureException; 22 | import org.apache.maven.project.MavenProject; 23 | import org.neo4j.graphdb.Direction; 24 | import org.neo4j.graphdb.Relationship; 25 | import org.neo4j.graphdb.index.IndexHits; 26 | import org.neo4j.rest.graphdb.RestAPI; 27 | import org.neo4j.rest.graphdb.RestAPIFacade; 28 | import org.neo4j.rest.graphdb.entity.RestNode; 29 | import org.neo4j.rest.graphdb.index.RestIndex; 30 | 31 | /** 32 | * Goal which reads reverse dependency trees from a neo4j database 33 | * 34 | * @goal read 35 | * 36 | * @phase process-sources 37 | * 38 | * @threadSafe 39 | */ 40 | public class ReverseDependencyMojo extends AbstractMojo{ 41 | 42 | private static final String GROUP_ID_AND_ARTIFACT_ID = "groupIdAndArtifactId"; 43 | private static final String PRETTY_PRINT = "prettyPrint"; 44 | 45 | /** 46 | * 47 | * 48 | * @parameter expression="${project}" 49 | * @required 50 | * @readonly 51 | */ 52 | private MavenProject project; 53 | 54 | /** 55 | * Neo4J Server. 56 | * @parameter 57 | * expression="${neo4jServer}" 58 | * default-value="http://localhost:7474" 59 | */ 60 | private String neo4jServer; 61 | 62 | RestAPI restAPI; 63 | 64 | 65 | @Override 66 | public void execute() throws MojoExecutionException, MojoFailureException { 67 | getLog().info("Resolving reverse dependencies"); 68 | restAPI = new RestAPIFacade(neo4jServer + "/db/data"); 69 | listDependants(); 70 | } 71 | 72 | private void listDependants(){ 73 | final RestIndex index = restAPI.getIndex("artifact"); 74 | final IndexHits nodes = index.query(GROUP_ID_AND_ARTIFACT_ID, ArtifactHelper.getGroupIdAndArtifactId(project.getArtifact())); 75 | for (RestNode node : nodes) { 76 | listNodeDependants(node); 77 | } 78 | 79 | } 80 | 81 | private void listNodeDependants(RestNode dependency) { 82 | for (Relationship r : dependency.getRelationships(Direction.INCOMING)) { 83 | getLog().info(r.getStartNode().getProperty(PRETTY_PRINT) + " -> " + r.getEndNode().getProperty(PRETTY_PRINT)); 84 | } 85 | } 86 | 87 | 88 | } 89 | -------------------------------------------------------------------------------- /src/main/java/no/finntech/ArtifactHelper.java: -------------------------------------------------------------------------------- 1 | /* Copyright (2013) FINN.no AS 2 | * 3 | * This is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version, with the Classpath Exception. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | package no.finntech; 18 | 19 | import org.apache.maven.artifact.Artifact; 20 | import org.apache.maven.artifact.DefaultArtifact; 21 | import org.apache.maven.model.Dependency; 22 | import org.apache.maven.project.MavenProject; 23 | 24 | import java.util.HashMap; 25 | import java.util.Map; 26 | 27 | 28 | public class ArtifactHelper { 29 | static final String SEPARATOR = "#"; 30 | public static String getId(Artifact artifact){ 31 | return artifact.getGroupId() + ":"+ artifact.getArtifactId()+ ":" + artifact.getVersion(); 32 | } 33 | 34 | public static String getId(Dependency dependency){ 35 | return dependency.getGroupId() + ":"+ dependency.getArtifactId()+ ":" + dependency.getVersion(); 36 | } 37 | 38 | public static Map getProperties(Artifact artifact){ 39 | Map propertyMap = new HashMap(); 40 | propertyMap.put("name",getId(artifact)); 41 | propertyMap.put("groupId",artifact.getGroupId()); 42 | propertyMap.put("artifactId",artifact.getArtifactId()); 43 | propertyMap.put("version",artifact.getVersion()); 44 | propertyMap.put("groupIdAndArtifactId", artifact.getGroupId() + "#" + artifact.getArtifactId()); 45 | propertyMap.put("prettyPrint", artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getVersion()); 46 | return propertyMap; 47 | } 48 | 49 | public static Map getProperties(Dependency dependency){ 50 | Map propertyMap = new HashMap(); 51 | propertyMap.put("name",getId(dependency)); 52 | propertyMap.put("groupId",dependency.getGroupId()); 53 | propertyMap.put("artifactId",dependency.getArtifactId()); 54 | propertyMap.put("version",dependency.getVersion()); 55 | propertyMap.put("groupIdAndArtifactId", dependency.getGroupId() + "#" + dependency.getArtifactId()); 56 | propertyMap.put("prettyPrint", dependency.getGroupId() + ":" + dependency.getArtifactId() + ":" + dependency.getVersion()); 57 | return propertyMap; 58 | } 59 | 60 | public static String getGroupIdAndArtifactId(Artifact artifact){ 61 | return splice (artifact.getGroupId(), artifact.getArtifactId()); 62 | } 63 | 64 | 65 | public static String splice(String ... s) { 66 | StringBuilder spliced = new StringBuilder(); 67 | String separator = ""; 68 | for(String tmp : s){ 69 | spliced.append(separator).append(tmp); 70 | separator = SEPARATOR; 71 | 72 | } 73 | return spliced.toString(); 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Maven dependency mapper 2 | ======================= 3 | Stores dependency relationships in a graph database (neo4j) 4 | ----------------------------------------------------------- 5 | 6 | Local environment: 7 | ------------------ 8 | * install neo4j http://www.neo4j.org/develop#install 9 | * checkout this repo 10 | * mvn install 11 | * Go to a maven project and run "mvn no.finntech:dependency-mapper-maven-plugin:1.0-SNAPSHOT:store" 12 | * Do a "mvn no.finntech:dependency-mapper-maven-plugin:1.0-SNAPSHOT:read" 13 | 14 | Override neo4j server setting with -Dneo4jServer=http://yourserver:yourport, defaults to http://localhost:7474 15 | 16 | 17 | Example output: 18 | --------------- 19 | mvn no.finntech:dependency-mapper-maven-plugin:1.0-SNAPSHOT:read 20 |
21 | [INFO] Scanning for projects...
22 | [INFO]                                                                         
23 | [INFO] ------------------------------------------------------------------------
24 | [INFO] Building greenpages thrift-client 3.4.5-SNAPSHOT
25 | [INFO] ------------------------------------------------------------------------
26 | [INFO] 
27 | [INFO] --- dependency-mapper-maven-plugin:1.0-SNAPSHOT:read (default-cli) @ commons-thrift-client ---
28 | [INFO] Resolving reverse dependencies
29 | [INFO] no.finntech.travel.supplier:supplier-client:1.2-SNAPSHOT -> no.finntech:commons-thrift-client:3.1.1
30 | [INFO] no.finntech.cop:client:1.1-SNAPSHOT -> no.finntech:commons-thrift-client:3.1.1
31 | [INFO] no.finntech.oppdrag-services:iad-model:2013.2-SNAPSHOT -> no.finntech:commons-thrift-client:3.4.3
32 | [INFO] no.finntech:minfinn:2013.2-SNAPSHOT -> no.finntech:commons-thrift-client:3.4.3
33 | [INFO] no.finntech:service-user:2013.2-SNAPSHOT -> no.finntech:commons-thrift-client:3.4.3
34 | [INFO] no.finntech:service-oppdrag:2013.2-SNAPSHOT -> no.finntech:commons-thrift-client:3.4.3
35 | [INFO] no.finntech:kernel:2013.2-SNAPSHOT -> no.finntech:commons-thrift-client:3.4.3
36 | [INFO] no.finntech.travelstats:travelstats-collector:1.7.6-SNAPSHOT -> no.finntech:commons-thrift-client:3.2.7
37 | [INFO] no.finntech.travelstats:travelstats-server:1.7.6-SNAPSHOT -> no.finntech:commons-thrift-client:3.2.7
38 | [INFO] no.finntech.travelstats:travelstats-db:1.7.6-SNAPSHOT -> no.finntech:commons-thrift-client:3.2.7
39 | [INFO] no.finntech.travelstats:travelstats-common:1.7.6-SNAPSHOT -> no.finntech:commons-thrift-client:3.2.7
40 | [INFO] no.finntech.travelstats:travelstats-api:1.7.6-SNAPSHOT -> no.finntech:commons-thrift-client:3.2.7
41 | [INFO] no.finntech:travelstats:1.7.6-SNAPSHOT -> no.finntech:commons-thrift-client:3.2.7
42 | [INFO] no.finntech:kart:12.10.1-SNAPSHOT -> no.finntech:commons-thrift-client:3.2.7
43 | [INFO] no.finntech:currency-client:2.1-SNAPSHOT -> no.finntech:commons-thrift-client:3.2.7
44 | [INFO] no.finntech.attribute:attribute-client:1.2-SNAPSHOT -> no.finntech:commons-thrift-client:3.2.7
45 | [INFO] no.finntech.vetting:vetting-client:3.6-SNAPSHOT -> no.finntech:commons-thrift-client:3.4.2
46 | [INFO] no.finntech.user:user-client:0.6.4-SNAPSHOT -> no.finntech:commons-thrift-client:3.4.2
47 | [INFO] no.finntech.user:user-server:0.6.4-SNAPSHOT -> no.finntech:commons-thrift-client:3.4.2
48 | [INFO] no.finntech.objectrelation:objectrelation-client:1.3-SNAPSHOT -> no.finntech:commons-thrift-client:3.4.2
49 | [INFO] no.finntech:myinbox-client:1.2.2-SNAPSHOT -> no.finntech:commons-thrift-client:3.4.2
50 | [INFO] no.finntech.mail:mail-test-api:3.4-SNAPSHOT -> no.finntech:commons-thrift-client:3.4.2
51 | [INFO] no.finntech.mail:mail-client:3.4-SNAPSHOT -> no.finntech:commons-thrift-client:3.4.2
52 | [INFO] no.finntech.api:finn-api-war:2013.2-SNAPSHOT -> no.finntech:commons-thrift-client:3.4.2
53 | [INFO] no.finntech.cardata:cardata-client:1.4-SNAPSHOT -> no.finntech:commons-thrift-client:3.4.2
54 | [INFO] no.finntech.broadcast:broadcast-client:3.1.2-SNAPSHOT -> no.finntech:commons-thrift-client:3.0.1
55 | [INFO] no.finntech:cms-client:1.0-SNAPSHOT -> no.finntech:commons-thrift-client:3.2.4
56 | [INFO] no.finntech:countstatistics-count-reduce:3.6-SNAPSHOT -> no.finntech:commons-thrift-client:3.3
57 | [INFO] no.finntech:countstatistics-count-listener:3.6-SNAPSHOT -> no.finntech:commons-thrift-client:3.3
58 | [INFO] no.finntech:countstatistics-count-impl:3.6-SNAPSHOT -> no.finntech:commons-thrift-client:3.3
59 | [INFO] no.finntech.attribute:attribute-client:1.2.3-SNAPSHOT -> no.finntech:commons-thrift-client:3.3
60 | [INFO] no.finntech.organisation:organisation-client:1.6-SNAPSHOT -> no.finntech:commons-thrift-client:3.4
61 | [INFO] ------------------------------------------------------------------------
62 | [INFO] BUILD SUCCESS
63 | [INFO] ------------------------------------------------------------------------
64 | [INFO] Total time: 1.957s
65 | [INFO] Finished at: Thu Jan 31 09:50:19 CET 2013
66 | [INFO] Final Memory: 9M/211M
67 | [INFO] ------------------------------------------------------------------------
68 | 
69 | 70 | To include this in your project: 71 | -------------------------------- 72 | put this in you pom.xml 73 | 74 | 75 | no.finntech 76 | dependency-mapper-maven-plugin 77 | 1.0-SNAPSHOT 78 | 79 | http://neo4jServer:7474 80 | 81 | 82 | 83 | Now you can use the plugin with mvn dependency-mapper:store and mvn dependency-mapper:read 84 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 18 | 19 | 20 | 22 | 4.0.0 23 | 24 | no.finntech 25 | dependency-mapper-maven-plugin 26 | 1.0-SNAPSHOT 27 | maven-plugin 28 | 29 | 30 | Maven dependency mapper plugin 31 | http://www.finn.no 32 | 33 | 34 | UTF-8 35 | 2.0 36 | 1.6 37 | 1.8 38 | 39 | 40 | 41 | 42 | org.apache.maven 43 | maven-artifact 44 | ${mavenVersion} 45 | 46 | 47 | org.apache.maven 48 | maven-plugin-api 49 | ${mavenVersion} 50 | 51 | 52 | org.apache.maven 53 | maven-project 54 | ${mavenVersion} 55 | 56 | 57 | org.apache.maven 58 | maven-model 59 | ${mavenVersion} 60 | 61 | 62 | org.apache.maven 63 | maven-core 64 | ${mavenVersion} 65 | 66 | 67 | org.neo4j 68 | neo4j-rest-graphdb 69 | ${neo4j.version} 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | org.apache.maven.plugins 78 | maven-compiler-plugin 79 | 2.5.1 80 | 81 | ${version.jdk} 82 | ${version.jdk} 83 | ${project.build.sourceEncoding} 84 | 85 | 86 | 87 | org.apache.maven.plugins 88 | maven-checkstyle-plugin 89 | 2.13 90 | 91 | 92 | validate 93 | validate 94 | 95 | UTF-8 96 | true 97 | true 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | check 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | neo4j-release-repository 124 | Neo4j Maven 2 release repository 125 | http://m2.neo4j.org/content/repositories/releases/ 126 | 127 | true 128 | 129 | 130 | false 131 | 132 | 133 | 134 | 135 | 136 | 137 | -------------------------------------------------------------------------------- /src/main/java/no/finntech/StoreGraphDependencyMojo.java: -------------------------------------------------------------------------------- 1 | /* Copyright (2013) FINN.no AS 2 | * 3 | * This is free software: you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version, with the Classpath Exception. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see . 15 | */ 16 | 17 | package no.finntech; 18 | 19 | 20 | import java.util.HashMap; 21 | import java.util.List; 22 | import java.util.Set; 23 | 24 | import org.apache.maven.artifact.Artifact; 25 | import org.apache.maven.model.Dependency; 26 | import org.apache.maven.plugin.AbstractMojo; 27 | import org.apache.maven.plugin.MojoExecutionException; 28 | import org.apache.maven.project.MavenProject; 29 | import org.neo4j.graphdb.Direction; 30 | import org.neo4j.graphdb.Node; 31 | import org.neo4j.graphdb.Relationship; 32 | import org.neo4j.rest.graphdb.RestAPI; 33 | import org.neo4j.rest.graphdb.RestAPIFacade; 34 | import org.neo4j.rest.graphdb.index.RestIndex; 35 | 36 | /** 37 | * Goal which stores dependency trees in neo4j database 38 | * 39 | * @goal store 40 | * 41 | * @phase process-sources 42 | * 43 | * @threadSafe 44 | */ 45 | public class StoreGraphDependencyMojo 46 | extends AbstractMojo { 47 | 48 | private static final String GROUP_ID_AND_ARTIFACT_ID = "groupIdAndArtifactId"; 49 | private static final String COMPLETE_ID = "completeId"; 50 | private static RestIndex index; 51 | private static final String ARTIFACT = "artifact"; 52 | 53 | /** 54 | * @parameter expression="${project}" 55 | * @required 56 | * @readonly 57 | */ 58 | private MavenProject project; 59 | 60 | /** 61 | * Neo4J Server. 62 | * @parameter 63 | * expression="${neo4jServer}" 64 | * default-value="http://localhost:7474" 65 | */ 66 | private String neo4jServer; 67 | 68 | RestAPI restAPI; 69 | 70 | 71 | 72 | 73 | public void execute() throws MojoExecutionException { 74 | final HashMap config = new HashMap(); 75 | restAPI = new RestAPIFacade(neo4jServer + "/db/data"); 76 | 77 | config.put("type", "exact"); 78 | config.put("provider", "lucene"); 79 | config.put("to_lower_case", "false"); 80 | 81 | index = restAPI.createIndex(Node.class, ARTIFACT, config); 82 | 83 | getDependencies(); 84 | getPlugins(); 85 | } 86 | 87 | private void getDependencies() { 88 | Node projectNode = makeNode(project.getArtifact()); 89 | for(Relationship r:projectNode.getRelationships(Direction.OUTGOING)){ 90 | r.delete(); 91 | } 92 | if (project.getParentArtifact() != null) { 93 | registerDependency("parent", projectNode, project.getParentArtifact()); 94 | } 95 | registerDependencies(project.getDependencies()); 96 | } 97 | 98 | private void registerDependencies(List dependencies) { 99 | 100 | Node projectNode = makeNode(project.getArtifact()); 101 | 102 | for (Dependency dependency : dependencies) { 103 | registerDependency(projectNode, dependency); 104 | } 105 | } 106 | 107 | private Node makeNode(Artifact artifact) { 108 | String completeId = ArtifactHelper.splice(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion()); 109 | Node projectNode = restAPI.getOrCreateNode(index, COMPLETE_ID, completeId, ArtifactHelper.getProperties(artifact)); 110 | restAPI.getIndex(ARTIFACT).add(projectNode, GROUP_ID_AND_ARTIFACT_ID, ArtifactHelper.splice(artifact.getGroupId(), artifact.getArtifactId())); 111 | restAPI.getIndex(ARTIFACT).add(projectNode, COMPLETE_ID, completeId); 112 | return projectNode; 113 | } 114 | 115 | private Node makeNode(Dependency dependency) { 116 | String completeId = ArtifactHelper.splice(dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion()); 117 | Node projectNode = restAPI.getOrCreateNode(index, COMPLETE_ID, completeId, ArtifactHelper.getProperties(dependency)); 118 | restAPI.getIndex(ARTIFACT).add(projectNode, GROUP_ID_AND_ARTIFACT_ID, ArtifactHelper.splice(dependency.getGroupId(), dependency.getArtifactId())); 119 | return projectNode; 120 | } 121 | 122 | private void registerDependency(Node projectNode, final Dependency dependency) { 123 | Node artifactNode; 124 | String scope = dependency.getScope(); 125 | 126 | if (scope == null) { 127 | scope = "compile"; // default scope 128 | } 129 | try { 130 | artifactNode = makeNode(dependency); 131 | projectNode.createRelationshipTo(artifactNode, MavenRelationships.getByName(scope)); 132 | getLog().info("Registered dependency to " + ArtifactHelper.getId(dependency) + ", scope: " + scope); 133 | } catch (Throwable e) { 134 | getLog().error(e.getMessage(), e); 135 | } 136 | } 137 | 138 | private void registerDependencies(Set artifacts, String type) { 139 | Node projectNode = makeNode(project.getArtifact()); 140 | 141 | for (Artifact artifact : artifacts) { 142 | registerDependency(type, projectNode, artifact); 143 | } 144 | } 145 | 146 | private void registerDependency(String type, Node projectNode, Artifact artifact) { 147 | projectNode.createRelationshipTo(makeNode(artifact), MavenRelationships.getByName(type)); 148 | getLog().info("Registered dependency of scope: " + type); 149 | } 150 | 151 | private void getPlugins() { 152 | Set plugins = project.getPluginArtifacts(); 153 | registerDependencies(plugins, "plugin"); 154 | } 155 | } 156 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | 9 | This version of the GNU Lesser General Public License incorporates 10 | the terms and conditions of version 3 of the GNU General Public 11 | License, supplemented by the additional permissions listed below. 12 | 13 | 0. Additional Definitions. 14 | 15 | As used herein, "this License" refers to version 3 of the GNU Lesser 16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU 17 | General Public License. 18 | 19 | "The Library" refers to a covered work governed by this License, 20 | other than an Application or a Combined Work as defined below. 21 | 22 | An "Application" is any work that makes use of an interface provided 23 | by the Library, but which is not otherwise based on the Library. 24 | Defining a subclass of a class defined by the Library is deemed a mode 25 | of using an interface provided by the Library. 26 | 27 | A "Combined Work" is a work produced by combining or linking an 28 | Application with the Library. The particular version of the Library 29 | with which the Combined Work was made is also called the "Linked 30 | Version". 31 | 32 | The "Minimal Corresponding Source" for a Combined Work means the 33 | Corresponding Source for the Combined Work, excluding any source code 34 | for portions of the Combined Work that, considered in isolation, are 35 | based on the Application, and not on the Linked Version. 36 | 37 | The "Corresponding Application Code" for a Combined Work means the 38 | object code and/or source code for the Application, including any data 39 | and utility programs needed for reproducing the Combined Work from the 40 | Application, but excluding the System Libraries of the Combined Work. 41 | 42 | 1. Exception to Section 3 of the GNU GPL. 43 | 44 | You may convey a covered work under sections 3 and 4 of this License 45 | without being bound by section 3 of the GNU GPL. 46 | 47 | 2. Conveying Modified Versions. 48 | 49 | If you modify a copy of the Library, and, in your modifications, a 50 | facility refers to a function or data to be supplied by an Application 51 | that uses the facility (other than as an argument passed when the 52 | facility is invoked), then you may convey a copy of the modified 53 | version: 54 | 55 | a) under this License, provided that you make a good faith effort to 56 | ensure that, in the event an Application does not supply the 57 | function or data, the facility still operates, and performs 58 | whatever part of its purpose remains meaningful, or 59 | 60 | b) under the GNU GPL, with none of the additional permissions of 61 | this License applicable to that copy. 62 | 63 | 3. Object Code Incorporating Material from Library Header Files. 64 | 65 | The object code form of an Application may incorporate material from 66 | a header file that is part of the Library. You may convey such object 67 | code under terms of your choice, provided that, if the incorporated 68 | material is not limited to numerical parameters, data structure 69 | layouts and accessors, or small macros, inline functions and templates 70 | (ten or fewer lines in length), you do both of the following: 71 | 72 | a) Give prominent notice with each copy of the object code that the 73 | Library is used in it and that the Library and its use are 74 | covered by this License. 75 | 76 | b) Accompany the object code with a copy of the GNU GPL and this license 77 | document. 78 | 79 | 4. Combined Works. 80 | 81 | You may convey a Combined Work under terms of your choice that, 82 | taken together, effectively do not restrict modification of the 83 | portions of the Library contained in the Combined Work and reverse 84 | engineering for debugging such modifications, if you also do each of 85 | the following: 86 | 87 | a) Give prominent notice with each copy of the Combined Work that 88 | the Library is used in it and that the Library and its use are 89 | covered by this License. 90 | 91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license 92 | document. 93 | 94 | c) For a Combined Work that displays copyright notices during 95 | execution, include the copyright notice for the Library among 96 | these notices, as well as a reference directing the user to the 97 | copies of the GNU GPL and this license document. 98 | 99 | d) Do one of the following: 100 | 101 | 0) Convey the Minimal Corresponding Source under the terms of this 102 | License, and the Corresponding Application Code in a form 103 | suitable for, and under terms that permit, the user to 104 | recombine or relink the Application with a modified version of 105 | the Linked Version to produce a modified Combined Work, in the 106 | manner specified by section 6 of the GNU GPL for conveying 107 | Corresponding Source. 108 | 109 | 1) Use a suitable shared library mechanism for linking with the 110 | Library. A suitable mechanism is one that (a) uses at run time 111 | a copy of the Library already present on the user's computer 112 | system, and (b) will operate properly with a modified version 113 | of the Library that is interface-compatible with the Linked 114 | Version. 115 | 116 | e) Provide Installation Information, but only if you would otherwise 117 | be required to provide such information under section 6 of the 118 | GNU GPL, and only to the extent that such information is 119 | necessary to install and execute a modified version of the 120 | Combined Work produced by recombining or relinking the 121 | Application with a modified version of the Linked Version. (If 122 | you use option 4d0, the Installation Information must accompany 123 | the Minimal Corresponding Source and Corresponding Application 124 | Code. If you use option 4d1, you must provide the Installation 125 | Information in the manner specified by section 6 of the GNU GPL 126 | for conveying Corresponding Source.) 127 | 128 | 5. Combined Libraries. 129 | 130 | You may place library facilities that are a work based on the 131 | Library side by side in a single library together with other library 132 | facilities that are not Applications and are not covered by this 133 | License, and convey such a combined library under terms of your 134 | choice, if you do both of the following: 135 | 136 | a) Accompany the combined library with a copy of the same work based 137 | on the Library, uncombined with any other library facilities, 138 | conveyed under the terms of this License. 139 | 140 | b) Give prominent notice with the combined library that part of it 141 | is a work based on the Library, and explaining where to find the 142 | accompanying uncombined form of the same work. 143 | 144 | 6. Revised Versions of the GNU Lesser General Public License. 145 | 146 | The Free Software Foundation may publish revised and/or new versions 147 | of the GNU Lesser General Public License from time to time. Such new 148 | versions will be similar in spirit to the present version, but may 149 | differ in detail to address new problems or concerns. 150 | 151 | Each version is given a distinguishing version number. If the 152 | Library as you received it specifies that a certain numbered version 153 | of the GNU Lesser General Public License "or any later version" 154 | applies to it, you have the option of following the terms and 155 | conditions either of that published version or of any later version 156 | published by the Free Software Foundation. If the Library as you 157 | received it does not specify a version number of the GNU Lesser 158 | General Public License, you may choose any version of the GNU Lesser 159 | General Public License ever published by the Free Software Foundation. 160 | 161 | If the Library as you received it specifies that a proxy can decide 162 | whether future versions of the GNU Lesser General Public License shall 163 | apply, that proxy's public statement of acceptance of any version is 164 | permanent authorization for you to choose that version for the 165 | Library. 166 | 167 | --------------------------------------------------------------------------------