Java 类org.apache.maven.project.ProjectDependenciesResolver 实例源码

项目:intellij-ce-playground    文件:Maven30ServerEmbedderImpl.java   
/**
 * copied from {@link DefaultProjectBuilder#resolveDependencies(MavenProject, RepositorySystemSession)}
 */
private DependencyResolutionResult resolveDependencies(MavenProject project, RepositorySystemSession session) {
  DependencyResolutionResult resolutionResult;

  try {
    ProjectDependenciesResolver dependencyResolver = getComponent(ProjectDependenciesResolver.class);
    DefaultDependencyResolutionRequest resolution = new DefaultDependencyResolutionRequest(project, session);
    resolutionResult = dependencyResolver.resolve(resolution);
  }
  catch (DependencyResolutionException e) {
    resolutionResult = e.getResult();
  }

  Set<Artifact> artifacts = new LinkedHashSet<Artifact>();
  if (resolutionResult.getDependencyGraph() != null) {
    RepositoryUtils.toArtifacts(artifacts, resolutionResult.getDependencyGraph().getChildren(),
                                Collections.singletonList(project.getArtifact().getId()), null);

    // Maven 2.x quirk: an artifact always points at the local repo, regardless whether resolved or not
    LocalRepositoryManager lrm = session.getLocalRepositoryManager();
    for (Artifact artifact : artifacts) {
      if (!artifact.isResolved()) {
        String path = lrm.getPathForLocalArtifact(RepositoryUtils.toArtifact(artifact));
        artifact.setFile(new File(lrm.getRepository().getBasedir(), path));
      }
    }
  }
  project.setResolvedArtifacts(artifacts);
  project.setArtifacts(artifacts);

  return resolutionResult;
}
项目:intellij-ce-playground    文件:Maven32ServerEmbedderImpl.java   
/**
 * copied from {@link DefaultProjectBuilder#resolveDependencies(MavenProject, org.sonatype.aether.RepositorySystemSession)}
 */
private DependencyResolutionResult resolveDependencies(MavenProject project, RepositorySystemSession session) {
  DependencyResolutionResult resolutionResult;

  try {
    ProjectDependenciesResolver dependencyResolver = getComponent(ProjectDependenciesResolver.class);
    DefaultDependencyResolutionRequest resolution = new DefaultDependencyResolutionRequest(project, session);
    resolutionResult = dependencyResolver.resolve(resolution);
  }
  catch (DependencyResolutionException e) {
    resolutionResult = e.getResult();
  }

  Set<Artifact> artifacts = new LinkedHashSet<Artifact>();
  if (resolutionResult.getDependencyGraph() != null) {
    RepositoryUtils.toArtifacts(artifacts, resolutionResult.getDependencyGraph().getChildren(),
                                Collections.singletonList(project.getArtifact().getId()), null);

    // Maven 2.x quirk: an artifact always points at the local repo, regardless whether resolved or not
    LocalRepositoryManager lrm = session.getLocalRepositoryManager();
    for (Artifact artifact : artifacts) {
      if (!artifact.isResolved()) {
        String path = lrm.getPathForLocalArtifact(RepositoryUtils.toArtifact(artifact));
        artifact.setFile(new File(lrm.getRepository().getBasedir(), path));
      }
    }
  }
  project.setResolvedArtifacts(artifacts);
  project.setArtifacts(artifacts);

  return resolutionResult;
}
项目:incubator-taverna-osgi    文件:MavenOsgiUtils.java   
public MavenOsgiUtils(MavenProject project, RepositorySystemSession repositorySystemSession,
        ProjectDependenciesResolver projectDependenciesResolver, Set<String> systemPackages,
        Log log) {
    this.project = project;
    this.repositorySystemSession = repositorySystemSession;
    this.projectDependenciesResolver = projectDependenciesResolver;
    this.systemPackages = systemPackages;
    this.log = log;
    javaPackages = Utils.getJavaPackages(log);
}
项目:incubator-taverna-osgi    文件:MavenOsgiUtils.java   
public MavenOsgiUtils(MavenProject project, RepositorySystemSession repositorySystemSession,
        ProjectDependenciesResolver projectDependenciesResolver, Log log) {
    this(project, repositorySystemSession, projectDependenciesResolver, new HashSet<String>(),
            log);
}
项目:oceano    文件:LifecycleDependencyResolver.java   
public LifecycleDependencyResolver( ProjectDependenciesResolver projectDependenciesResolver, Logger logger )
{
    this.dependenciesResolver = projectDependenciesResolver;
    this.logger = logger;
}