You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by ga...@apache.org on 2007/10/15 18:33:23 UTC
svn commit: r584817 - in /geronimo/sandbox/gawor: ./
geronimo-dependency-plugin/ geronimo-dependency-plugin/src/
geronimo-dependency-plugin/src/main/
geronimo-dependency-plugin/src/main/java/
geronimo-dependency-plugin/src/main/java/org/ geronimo-depen...
Author: gawor
Date: Mon Oct 15 09:33:21 2007
New Revision: 584817
URL: http://svn.apache.org/viewvc?rev=584817&view=rev
Log:
maven plugin that generates graph data to visualize config dependencies
Added:
geronimo/sandbox/gawor/
geronimo/sandbox/gawor/geronimo-dependency-plugin/
geronimo/sandbox/gawor/geronimo-dependency-plugin/README.txt (with props)
geronimo/sandbox/gawor/geronimo-dependency-plugin/pom.xml (with props)
geronimo/sandbox/gawor/geronimo-dependency-plugin/src/
geronimo/sandbox/gawor/geronimo-dependency-plugin/src/main/
geronimo/sandbox/gawor/geronimo-dependency-plugin/src/main/java/
geronimo/sandbox/gawor/geronimo-dependency-plugin/src/main/java/org/
geronimo/sandbox/gawor/geronimo-dependency-plugin/src/main/java/org/apache/
geronimo/sandbox/gawor/geronimo-dependency-plugin/src/main/java/org/apache/geronimo/
geronimo/sandbox/gawor/geronimo-dependency-plugin/src/main/java/org/apache/geronimo/mavenplugins/
geronimo/sandbox/gawor/geronimo-dependency-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/
geronimo/sandbox/gawor/geronimo-dependency-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/Edge.java (with props)
geronimo/sandbox/gawor/geronimo-dependency-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/Graph.java (with props)
geronimo/sandbox/gawor/geronimo-dependency-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/GraphMLOutput.java (with props)
geronimo/sandbox/gawor/geronimo-dependency-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/GraphMojo.java (with props)
geronimo/sandbox/gawor/geronimo-dependency-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/Node.java (with props)
Added: geronimo/sandbox/gawor/geronimo-dependency-plugin/README.txt
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gawor/geronimo-dependency-plugin/README.txt?rev=584817&view=auto
==============================================================================
--- geronimo/sandbox/gawor/geronimo-dependency-plugin/README.txt (added)
+++ geronimo/sandbox/gawor/geronimo-dependency-plugin/README.txt Mon Oct 15 09:33:21 2007
@@ -0,0 +1,27 @@
+STEP I
+======
+
+Generate graph data files from config dependencies:
+
+1) To generate graph data file for each config module execute:
+
+$ cd configs/
+$ mvn org.apache.geronimo.plugins:geronimo-dependency-plugin:graph
+
+A "module.graphml" file will be created in the target/ directory of each module.
+
+2) To generate a single graph data file for all config modules run:
+
+$ cd configs/
+$ mvn org.apache.geronimo.plugins:geronimo-dependency-plugin:graph -DtmpDataFile=/tmp/graph -Dmode=update
+$ mvn org.apache.geronimo.plugins:geronimo-dependency-plugin:graph -DtmpDataFile=/tmp/graph -Dmode=output -N
+
+A "/tmp/graph.graphml" file will be created.
+
+
+STEP II
+=======
+
+Visualize the graph data:
+
+Use yEd (http://www.yworks.com/en/products_yed_about.htm) to display the graph data.
Propchange: geronimo/sandbox/gawor/geronimo-dependency-plugin/README.txt
------------------------------------------------------------------------------
svn:eol-style = native
Added: geronimo/sandbox/gawor/geronimo-dependency-plugin/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gawor/geronimo-dependency-plugin/pom.xml?rev=584817&view=auto
==============================================================================
--- geronimo/sandbox/gawor/geronimo-dependency-plugin/pom.xml (added)
+++ geronimo/sandbox/gawor/geronimo-dependency-plugin/pom.xml Mon Oct 15 09:33:21 2007
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+
+<!-- $Rev: 573798 $ $Date: 2007-09-08 04:11:25 -0400 (Sat, 08 Sep 2007) $ -->
+
+<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/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.geronimo.plugins</groupId>
+
+ <artifactId>geronimo-dependency-plugin</artifactId>
+ <name>Geronimo Maven2 Plugins :: Geronimo</name>
+ <packaging>maven-plugin</packaging>
+ <version>1.0</version>
+
+ <description>
+ </description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>plugin-support</artifactId>
+ <version>1.0-alpha-1</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
+
Propchange: geronimo/sandbox/gawor/geronimo-dependency-plugin/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: geronimo/sandbox/gawor/geronimo-dependency-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/Edge.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gawor/geronimo-dependency-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/Edge.java?rev=584817&view=auto
==============================================================================
--- geronimo/sandbox/gawor/geronimo-dependency-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/Edge.java (added)
+++ geronimo/sandbox/gawor/geronimo-dependency-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/Edge.java Mon Oct 15 09:33:21 2007
@@ -0,0 +1,70 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.geronimo.mavenplugins.geronimo;
+
+import java.io.Serializable;
+
+public class Edge implements Serializable {
+
+ String srcNodeId;
+ String dstNodeId;
+
+ public Edge(String src, String dst) {
+ srcNodeId = src;
+ dstNodeId = dst;
+ }
+
+ public String getSrcNodeId() {
+ return srcNodeId;
+ }
+
+ public String getDstNodeId() {
+ return dstNodeId;
+ }
+
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((dstNodeId == null) ? 0 : dstNodeId.hashCode());
+ result = prime * result + ((srcNodeId == null) ? 0 : srcNodeId.hashCode());
+ return result;
+ }
+
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ final Edge other = (Edge) obj;
+ if (dstNodeId == null) {
+ if (other.dstNodeId != null)
+ return false;
+ } else if (!dstNodeId.equals(other.dstNodeId))
+ return false;
+ if (srcNodeId == null) {
+ if (other.srcNodeId != null)
+ return false;
+ } else if (!srcNodeId.equals(other.srcNodeId))
+ return false;
+ return true;
+ }
+
+}
Propchange: geronimo/sandbox/gawor/geronimo-dependency-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/Edge.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: geronimo/sandbox/gawor/geronimo-dependency-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/Graph.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gawor/geronimo-dependency-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/Graph.java?rev=584817&view=auto
==============================================================================
--- geronimo/sandbox/gawor/geronimo-dependency-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/Graph.java (added)
+++ geronimo/sandbox/gawor/geronimo-dependency-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/Graph.java Mon Oct 15 09:33:21 2007
@@ -0,0 +1,57 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.geronimo.mavenplugins.geronimo;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+public class Graph implements Serializable {
+
+ Map<String, Node> nodes = new HashMap<String, Node>();
+ Set<Edge> edges = new HashSet<Edge>();
+
+ public boolean hasNode(String id) {
+ return nodes.containsKey(id);
+ }
+
+ public void addNode(Node n) {
+ nodes.put(n.getId(), n);
+ }
+
+ public Node getNode(String id) {
+ return nodes.get(id);
+ }
+
+ public void addEgde(Edge e) {
+ edges.add(e);
+ }
+
+ public Collection<Node> getNodes() {
+ return this.nodes.values();
+ }
+
+ public Collection<Edge> getEdges() {
+ return this.edges;
+ }
+
+}
Propchange: geronimo/sandbox/gawor/geronimo-dependency-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/Graph.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: geronimo/sandbox/gawor/geronimo-dependency-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/GraphMLOutput.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gawor/geronimo-dependency-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/GraphMLOutput.java?rev=584817&view=auto
==============================================================================
--- geronimo/sandbox/gawor/geronimo-dependency-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/GraphMLOutput.java (added)
+++ geronimo/sandbox/gawor/geronimo-dependency-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/GraphMLOutput.java Mon Oct 15 09:33:21 2007
@@ -0,0 +1,72 @@
+package org.apache.geronimo.mavenplugins.geronimo;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.PrintWriter;
+
+public class GraphMLOutput {
+
+ public File outputGraph(File location, Graph graph) throws Exception {
+
+ File file = null;
+ if (location.isDirectory()) {
+ file = new File(location, "module.graphml");
+ } else {
+ file = new File(location.getParentFile(), location.getName() + ".graphml");
+ }
+
+ PrintWriter writer = new PrintWriter(new FileOutputStream(file));
+
+ writer.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
+
+ writer.println("<graphml xmlns=\"http://graphml.graphdrawing.org/xmlns/graphml\"");
+ writer.println(" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"");
+ writer.println(" xmlns:y=\"http://www.yworks.com/xml/graphml\"");
+ writer.println(" xsi:schemaLocation=\"http://graphml.graphdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd\">");
+ writer.println();
+ writer.println("<key id=\"d0\" for=\"node\" yfiles.type=\"nodegraphics\"/>");
+ writer.println("<key id=\"d1\" for=\"edge\" yfiles.type=\"edgegraphics\"/>");
+ writer.println();
+
+ writer.println("<graph id=\"G\" edgedefault=\"directed\">");
+
+ for (Node node : graph.getNodes()) {
+ String shape = "car".equals(node.getType()) ? "rectangle" : "ellipse";
+ writeNode(writer, node.getId(), node.getLabel(), shape);
+ }
+
+ for (Edge edge : graph.getEdges()) {
+ writeEdge(writer, edge.getSrcNodeId(), edge.getDstNodeId());
+ }
+
+ writer.println("</graph>");
+ writer.println("</graphml>");
+
+ writer.close();
+
+ return file;
+ }
+
+ private void writeNode(PrintWriter writer, String id, String name, String type) {
+ writer.println(" <node id=\"" + id + "\">");
+ writer.println(" <data key=\"d0\">");
+ writer.println(" <y:ShapeNode>");
+ writer.println(" <y:NodeLabel>" + name + "</y:NodeLabel>");
+ writer.println(" <y:Shape type=\"" + type + "\"/>");
+ writer.println(" </y:ShapeNode>");
+ writer.println(" </data>");
+ writer.println(" </node>");
+ writer.println();
+ }
+
+ private void writeEdge(PrintWriter writer, String srcId, String destId) {
+ writer.println(" <edge source=\"" + srcId + "\" target=\"" + destId + "\">");
+ writer.println(" <data key=\"d1\">");
+ writer.println(" <y:PolyLineEdge>");
+ writer.println(" <y:Arrows source=\"none\" target=\"" + destId + "\"/>");
+ writer.println(" </y:PolyLineEdge>");
+ writer.println(" </data>");
+ writer.println(" </edge>");
+ writer.println();
+ }
+}
Propchange: geronimo/sandbox/gawor/geronimo-dependency-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/GraphMLOutput.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: geronimo/sandbox/gawor/geronimo-dependency-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/GraphMojo.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gawor/geronimo-dependency-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/GraphMojo.java?rev=584817&view=auto
==============================================================================
--- geronimo/sandbox/gawor/geronimo-dependency-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/GraphMojo.java (added)
+++ geronimo/sandbox/gawor/geronimo-dependency-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/GraphMojo.java Mon Oct 15 09:33:21 2007
@@ -0,0 +1,271 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.geronimo.mavenplugins.geronimo;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.List;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.factory.ArtifactFactory;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.model.Dependency;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.MavenProjectBuilder;
+import org.codehaus.mojo.pluginsupport.MojoSupport;
+
+/**
+ * Generate graph of Geronimo dependencies.
+ *
+ * @goal graph
+ *
+ * @version $Rev: 476061 $ $Date: 2006-11-17 01:36:50 -0500 (Fri, 17 Nov 2006) $
+ */
+public class GraphMojo extends MojoSupport {
+
+ private Graph graph;
+
+ /**
+ * The maven project.
+ *
+ * @parameter expression="${project}"
+ * @required
+ * @readonly
+ */
+ protected MavenProject project;
+
+ /**
+ * Artifact factory, needed to download source jars.
+ *
+ * @component role="org.apache.maven.project.MavenProjectBuilder"
+ * @required
+ * @readonly
+ */
+ protected MavenProjectBuilder mavenProjectBuilder;
+
+ /**
+ * Used to look up Artifacts in the remote repository.
+ *
+ * @parameter expression="${component.org.apache.maven.artifact.factory.ArtifactFactory}"
+ * @required
+ * @readonly
+ */
+ protected ArtifactFactory factory;
+
+ /**
+ * Location of the local repository.
+ *
+ * @parameter expression="${localRepository}"
+ * @readonly
+ * @required
+ */
+ protected ArtifactRepository local;
+
+ /**
+ * List of Remote Repositories used by the resolver
+ *
+ * @parameter expression="${project.remoteArtifactRepositories}"
+ * @readonly
+ * @required
+ */
+ protected List remoteRepos;
+
+ /**
+ * The location where the properties mapping will be generated.
+ *
+ * @parameter expression="${project.build.directory}"
+ * @required
+ */
+ private File buildDirectory = null;
+
+ /**
+ * Include or exclude jars in the dependency graph.
+ *
+ * @parameter expression="${includeJars}"
+ */
+ protected boolean includeJars = true;
+
+ /**
+ * Mode of operation: 'generate' or 'output'. For use with multiple modules.
+ *
+ * @parameter expression="${mode}"
+ */
+ protected String mode;
+
+ /**
+ * File to store the temporary graph data representation.
+ * Required when mode of operation is specified.
+ *
+ * @parameter expression="${tmpDataFile}"
+ */
+ protected File serFile;
+
+ protected void doExecute() throws Exception {
+ if (mode == null) {
+ graph = new Graph();
+ if (createGraph(project) != null) {
+ outputGraph(buildDirectory);
+ }
+ } else {
+ if (serFile == null) {
+ throw new MojoFailureException("Must specify temporary graph data file");
+ }
+
+ if (mode.equals("update")) {
+ updateMultiGraph();
+ } else if (mode.equals("output")) {
+ outputMultiGraph();
+ } else {
+ throw new MojoFailureException("Invalid mode: " + mode);
+ }
+ }
+ }
+
+ private void updateMultiGraph() throws Exception {
+ try {
+ readGraph(serFile);
+ } catch (FileNotFoundException e) {
+ getLog().info("Temporaty graph data file does not exist. Will create one.");
+ graph = new Graph();
+ } catch (IOException e) {
+ throw new MojoFailureException("Failed to read temporary graph data file: " + e.getMessage());
+ }
+
+ createGraph(project);
+ writeGraph(serFile);
+ }
+
+ private void outputMultiGraph() throws Exception {
+ try {
+ readGraph(serFile);
+ } catch (IOException e) {
+ throw new MojoFailureException("Failed to read temporary graph data file: " + e.getMessage());
+ }
+ outputGraph(serFile);
+ }
+
+ private void readGraph(File file) throws Exception {
+ getLog().info("Reading temporaty graph data file: " + file);
+ ObjectInputStream in = null;
+ try {
+ in = new ObjectInputStream(new FileInputStream(file));
+ graph = (Graph)in.readObject();
+ } finally {
+ if (in != null) {
+ in.close();
+ }
+ }
+ }
+
+ private void writeGraph(File file) throws Exception {
+ getLog().info("Writting temporaty graph data file: " + file);
+ ObjectOutputStream out = null;
+ try {
+ out = new ObjectOutputStream(new FileOutputStream(file));
+ out.writeObject(graph);
+ } finally {
+ if (out != null) {
+ out.close();
+ }
+ }
+ }
+
+ private void outputGraph(File location) throws Exception {
+ GraphMLOutput out = new GraphMLOutput();
+ File graphDataFile = out.outputGraph(location, graph);
+ getLog().info("Generated graph data file: " + graphDataFile);
+ }
+
+ protected Node createGraph(MavenProject p) throws Exception {
+ if (!"car".equals(p.getPackaging())) {
+ getLog().warn("Module '" + p.getId() + " is not a CAR module. Ignoring.");
+ return null;
+ }
+
+ Node srcNode = new Node(p.getId(), p.getArtifactId(), "car");
+ graph.addNode(srcNode);
+
+ List<Dependency> includedDependencies = p.getOriginalModel().getDependencies();
+ List<Dependency> artifacts = p.getDependencies();
+ for (Dependency dependency : includedDependencies) {
+ dependency = resolveDependency(dependency, artifacts);
+ String dependencyId = getId(dependency);
+
+ Node dstNode = graph.getNode(dependencyId);
+ if (dstNode == null) {
+ if ("car".equals(dependency.getType())) {
+ MavenProject depProject = resolveArtifactDependencies(dependency);
+ dstNode = createGraph(depProject);
+ } else if (includeJars) {
+ dstNode = new Node(dependencyId, dependency.getArtifactId(), dependency.getType());
+ graph.addNode(dstNode);
+ }
+ }
+
+ if (dstNode != null) {
+ graph.addEgde(new Edge(srcNode.getId(), dstNode.getId()));
+ }
+ }
+
+ return srcNode;
+ }
+
+ private String getId(Dependency dependency) {
+ return dependency.getGroupId() + ":" + dependency.getArtifactId() + ":" + dependency.getType() + ":" + dependency.getVersion();
+ }
+
+ protected MavenProject resolveArtifactDependencies(Dependency artifact) throws Exception {
+ Artifact pomArtifact = this.factory.createArtifact(artifact.getGroupId(),
+ artifact.getArtifactId(),
+ artifact.getVersion(), "", "pom" );
+
+ MavenProject pomProject = mavenProjectBuilder.buildFromRepository(pomArtifact, this.remoteRepos, this.local);
+ return pomProject;
+ }
+
+ protected Dependency resolveDependency(Dependency dependency, List<Dependency> artifacts) {
+ for (Dependency match: artifacts) {
+ if (matches(dependency, match)) {
+ return match;
+ }
+ }
+ throw new IllegalStateException("Dependency " + dependency + " is not resolved in project");
+ }
+
+ private boolean matches(Dependency dependency, Dependency match) {
+ if (dependency.getGroupId() != null && !dependency.getGroupId().equals(match.getGroupId())) {
+ return false;
+ }
+ if (dependency.getArtifactId() != null && !dependency.getArtifactId().equals(match.getArtifactId())) {
+ return false;
+ }
+ if (dependency.getType() != null && !dependency.getType().equals(match.getType())) {
+ return false;
+ }
+ return true;
+ }
+
+}
Propchange: geronimo/sandbox/gawor/geronimo-dependency-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/GraphMojo.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: geronimo/sandbox/gawor/geronimo-dependency-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/Node.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gawor/geronimo-dependency-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/Node.java?rev=584817&view=auto
==============================================================================
--- geronimo/sandbox/gawor/geronimo-dependency-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/Node.java (added)
+++ geronimo/sandbox/gawor/geronimo-dependency-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/Node.java Mon Oct 15 09:33:21 2007
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.geronimo.mavenplugins.geronimo;
+
+import java.io.Serializable;
+
+public class Node implements Serializable {
+
+ String id;
+ String label;
+ String type;
+
+ public Node(String id, String label, String type) {
+ this.id = id;
+ this.label = label;
+ this.type = type;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+}
Propchange: geronimo/sandbox/gawor/geronimo-dependency-plugin/src/main/java/org/apache/geronimo/mavenplugins/geronimo/Node.java
------------------------------------------------------------------------------
svn:eol-style = native