com.github.janssk1.maven.plugin.graph.MavenHelper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of maven-dependencygraph-plugin Show documentation
Show all versions of maven-dependencygraph-plugin Show documentation
Generates a dependency graph in graphml format
package com.github.janssk1.maven.plugin.graph;
import com.github.janssk1.maven.plugin.graph.domain.ArtifactDependency;
import com.github.janssk1.maven.plugin.graph.domain.ArtifactIdentifier;
import com.github.janssk1.maven.plugin.graph.domain.ArtifactRevisionIdentifier;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.Exclusion;
import org.apache.maven.project.MavenProject;
import java.util.ArrayList;
import java.util.List;
/**
* User: janssk1
* Date: 8/14/11
* Time: 12:32 AM
*/
class MavenHelper {
public static List resolveDependencies(MavenProject model) {
ArrayList dependencies;
dependencies = new ArrayList(model.getDependencies().size());
for (Dependency d : (List) model.getDependencies()) {
dependencies.add(createArtifactDependency(d));
}
return dependencies;
}
public static ArtifactDependency createArtifactDependency(Dependency d) {
ArtifactDependency dependency = new ArtifactDependency(
new ArtifactRevisionIdentifier(d),
d.getScope()
);
dependency.setClassifier(d.getClassifier());
dependency.setOptional(d.isOptional());
for (Exclusion ex : d.getExclusions()) {
ArtifactIdentifier id = new ArtifactIdentifier(ex.getArtifactId(), ex.getGroupId());
dependency.getExclusions().add(id);
}
return dependency;
}
}