com.versioneye.utils.DependencyUtils Maven / Gradle / Ivy
package com.versioneye.utils;
import org.apache.maven.project.MavenProject;
import org.eclipse.aether.artifact.Artifact;
import org.eclipse.aether.artifact.DefaultArtifact;
import org.eclipse.aether.collection.CollectRequest;
import org.eclipse.aether.graph.Dependency;
import org.eclipse.aether.graph.DependencyNode;
import org.eclipse.aether.repository.RemoteRepository;
import java.util.ArrayList;
import java.util.List;
/**
* Utility methods for Maven Dependencies.
*/
public class DependencyUtils {
public static List collectAllDependencies(List dependencies) {
List result = new ArrayList(dependencies.size());
for (Dependency dependency : dependencies) {
result.add(dependency.getArtifact());
}
return result;
}
public static List collectDirectDependencies(List dependencies) {
List result = new ArrayList(dependencies.size());
for (DependencyNode dependencyNode : dependencies) {
result.add(dependencyNode.getDependency().getArtifact());
}
return result;
}
public static CollectRequest getCollectRequest(MavenProject project, List repos, String scope){
Artifact a = new DefaultArtifact( project.getArtifact().toString() );
DefaultArtifact pom = new DefaultArtifact( a.getGroupId(), a.getArtifactId(), "pom", a.getVersion() );
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRoot(new Dependency(pom, scope ));
collectRequest.setRepositories(repos);
return collectRequest;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy