Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
adutra
committed
May 17, 2011
0 parents
commit 69fefd7
Showing
73 changed files
with
8,089 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
target | ||
.project | ||
.classpath | ||
.settings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Copyright 2011 Alexandre Dutra | ||
|
||
Licensed 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
This library contains: | ||
|
||
- A set of parsers that parse the output of the maven command "mvn dependency:tree"; | ||
different parsers can be used to parse the following output formats: text, dot, graphml and tgf. | ||
See http://maven.apache.org/plugins/maven-dependency-plugin/tree-mojo.html for further details. | ||
The following idiom is the recommended way to parse any input: | ||
|
||
MavenDependencyTreeFormat format = ...; | ||
MavenDependencyTreeParser parser = format.newParser(); | ||
Reader r = ... | ||
MavenDependencyNode tree = parser.parse(r); | ||
|
||
|
||
- A set of utilities to create HTML representations of the parsed tree. These utilities rely upon JQuery (see http://jquery.com) and some JQuery plugins: | ||
- jstree: see http://www.jstree.com/ | ||
- treeTable: see http://plugins.jquery.com/project/treeTable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<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> | ||
<name>Maven Dependency Tree Parser</name> | ||
<groupId>fr.dutra.tools.maven.deptree</groupId> | ||
<artifactId>maven-dependency-tree-parser</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<description> | ||
This library contains a set of parsers that parse the output of the maven command "mvn dependency:tree", and | ||
a set of utilities to create HTML representations of the parsed tree. | ||
</description> | ||
<packaging>jar</packaging> | ||
<inceptionYear>2011</inceptionYear> | ||
|
||
<developers> | ||
|
||
<developer> | ||
<id>adutra</id> | ||
<name>Alexandre Dutra</name> | ||
<email>adutra@gmail.com</email> | ||
</developer> | ||
|
||
</developers> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<powermock.version>1.4.9</powermock.version> | ||
</properties> | ||
|
||
<build> | ||
|
||
<plugins> | ||
|
||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<!-- http://maven.apache.org/plugins/maven-compiler-plugin/ --> | ||
<source>1.6</source> | ||
<target>1.6</target> | ||
</configuration> | ||
</plugin> | ||
|
||
</plugins> | ||
|
||
</build> | ||
|
||
<dependencies> | ||
|
||
<dependency> | ||
<groupId>org.apache.velocity</groupId> | ||
<artifactId>velocity</artifactId> | ||
<version>1.6.4</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.8.1</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.mockito</groupId> | ||
<artifactId>mockito-all</artifactId> | ||
<version>1.8.5</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.powermock</groupId> | ||
<artifactId>powermock-core</artifactId> | ||
<version>${powermock.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.powermock</groupId> | ||
<artifactId>powermock-module-junit4</artifactId> | ||
<version>${powermock.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.powermock</groupId> | ||
<artifactId>powermock-api-mockito</artifactId> | ||
<version>${powermock.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>commons-io</groupId> | ||
<artifactId>commons-io</artifactId> | ||
<version>2.0.1</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
250 changes: 250 additions & 0 deletions
250
src/main/java/fr/dutra/tools/maven/deptree/model/MavenDependencyNode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,250 @@ | ||
package fr.dutra.tools.maven.deptree.model; | ||
|
||
import java.io.Serializable; | ||
import java.util.LinkedList; | ||
|
||
public class MavenDependencyNode implements Serializable { | ||
|
||
/** | ||
* | ||
*/ | ||
private static final long serialVersionUID = 5530155206443082802L; | ||
|
||
private final String groupId; | ||
|
||
private final String artifactId; | ||
|
||
private final String packaging; | ||
|
||
private final String classifier; | ||
|
||
private final String version; | ||
|
||
private final String scope; | ||
|
||
private final String description; | ||
|
||
private final boolean omitted; | ||
|
||
private MavenDependencyNode parent; | ||
|
||
private final LinkedList<MavenDependencyNode> childNodes = new LinkedList<MavenDependencyNode>(); | ||
|
||
public MavenDependencyNode( | ||
final String groupId, | ||
final String artifactId, | ||
final String packaging, | ||
final String classifier, | ||
final String version, | ||
final String scope, | ||
final String description, | ||
boolean omitted) { | ||
super(); | ||
this.groupId = groupId; | ||
this.artifactId = artifactId; | ||
this.packaging = packaging; | ||
this.classifier = classifier; | ||
this.version = version; | ||
this.scope = scope; | ||
this.description = description; | ||
this.omitted = omitted; | ||
} | ||
|
||
public String getGroupId() { | ||
return this.groupId; | ||
} | ||
|
||
public String getArtifactId() { | ||
return this.artifactId; | ||
} | ||
|
||
public String getPackaging() { | ||
return this.packaging; | ||
} | ||
|
||
public String getClassifier() { | ||
return this.classifier; | ||
} | ||
|
||
public String getVersion() { | ||
return this.version; | ||
} | ||
|
||
public String getDescription() { | ||
return this.description; | ||
} | ||
|
||
public String getScope() { | ||
return this.scope; | ||
} | ||
|
||
public boolean isOmitted() { | ||
return omitted; | ||
} | ||
|
||
public MavenDependencyNode getParent() { | ||
return parent; | ||
} | ||
|
||
public LinkedList<MavenDependencyNode> getChildNodes() { | ||
return this.childNodes; | ||
} | ||
|
||
public boolean addChildNode(final MavenDependencyNode o) { | ||
o.parent = this; | ||
return this.childNodes.add(o); | ||
} | ||
|
||
public boolean remove(final MavenDependencyNode o) { | ||
return this.childNodes.remove(o); | ||
} | ||
|
||
public MavenDependencyNode getChildNode(int index) { | ||
return childNodes.get(index); | ||
} | ||
|
||
public MavenDependencyNode getFirstChildNode() { | ||
return childNodes.getFirst(); | ||
} | ||
|
||
public MavenDependencyNode getLastChildNode() { | ||
return childNodes.getLast(); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
final int prime = 31; | ||
int result = 1; | ||
result = prime * result + ((artifactId == null) ? 0 : artifactId.hashCode()); | ||
result = prime * result + ((classifier == null) ? 0 : classifier.hashCode()); | ||
result = prime * result + ((description == null) ? 0 : description.hashCode()); | ||
result = prime * result + ((groupId == null) ? 0 : groupId.hashCode()); | ||
result = prime * result + (omitted ? 1231 : 1237); | ||
result = prime * result + ((packaging == null) ? 0 : packaging.hashCode()); | ||
result = prime * result + ((scope == null) ? 0 : scope.hashCode()); | ||
result = prime * result + ((version == null) ? 0 : version.hashCode()); | ||
return result; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) { | ||
return true; | ||
} | ||
if (obj == null) { | ||
return false; | ||
} | ||
if (getClass() != obj.getClass()) { | ||
return false; | ||
} | ||
MavenDependencyNode other = (MavenDependencyNode) obj; | ||
if (artifactId == null) { | ||
if (other.artifactId != null) { | ||
return false; | ||
} | ||
} else if (!artifactId.equals(other.artifactId)) { | ||
return false; | ||
} | ||
if (classifier == null) { | ||
if (other.classifier != null) { | ||
return false; | ||
} | ||
} else if (!classifier.equals(other.classifier)) { | ||
return false; | ||
} | ||
if (description == null) { | ||
if (other.description != null) { | ||
return false; | ||
} | ||
} else if (!description.equals(other.description)) { | ||
return false; | ||
} | ||
if (groupId == null) { | ||
if (other.groupId != null) { | ||
return false; | ||
} | ||
} else if (!groupId.equals(other.groupId)) { | ||
return false; | ||
} | ||
if (omitted != other.omitted) { | ||
return false; | ||
} | ||
if (packaging == null) { | ||
if (other.packaging != null) { | ||
return false; | ||
} | ||
} else if (!packaging.equals(other.packaging)) { | ||
return false; | ||
} | ||
if (scope == null) { | ||
if (other.scope != null) { | ||
return false; | ||
} | ||
} else if (!scope.equals(other.scope)) { | ||
return false; | ||
} | ||
if (version == null) { | ||
if (other.version != null) { | ||
return false; | ||
} | ||
} else if (!version.equals(other.version)) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
@Override | ||
public MavenDependencyNode clone() { | ||
final MavenDependencyNode clone = new MavenDependencyNode( | ||
this.groupId, | ||
this.artifactId, | ||
this.packaging, | ||
this.classifier, | ||
this.version, | ||
this.scope, | ||
this.description, | ||
this.omitted | ||
); | ||
for (final MavenDependencyNode childNode : this.childNodes) { | ||
clone.addChildNode(childNode.clone()); | ||
} | ||
return clone; | ||
} | ||
|
||
|
||
@Override | ||
public String toString() { | ||
MavenDependencyNodeToStringVisitor visitor = new MavenDependencyNodeToStringVisitor(); | ||
visitor.visit(this); | ||
return visitor.toString(); | ||
} | ||
|
||
public String toArtifactCanonicalForm() { | ||
final StringBuilder builder = new StringBuilder(); | ||
if(omitted) { | ||
builder.append("("); | ||
} | ||
builder.append(this.groupId); | ||
builder.append(":"); | ||
builder.append(this.artifactId); | ||
builder.append(":"); | ||
builder.append(this.packaging); | ||
builder.append(":"); | ||
builder.append(this.version); | ||
if(this.scope != null) { | ||
builder.append(":"); | ||
builder.append(this.scope); | ||
} | ||
if(omitted) { | ||
builder.append(" - "); | ||
builder.append(this.description); | ||
builder.append(")"); | ||
} else if(this.description != null) { | ||
builder.append(" ("); | ||
builder.append(this.description); | ||
builder.append(")"); | ||
} | ||
return builder.toString(); | ||
} | ||
|
||
} |
Oops, something went wrong.