当前位置: 首页>>代码示例>>Java>>正文


Java ArtifactResult.getArtifact方法代码示例

本文整理汇总了Java中org.eclipse.aether.resolution.ArtifactResult.getArtifact方法的典型用法代码示例。如果您正苦于以下问题:Java ArtifactResult.getArtifact方法的具体用法?Java ArtifactResult.getArtifact怎么用?Java ArtifactResult.getArtifact使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.aether.resolution.ArtifactResult的用法示例。


在下文中一共展示了ArtifactResult.getArtifact方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: resolvePluginDependency

import org.eclipse.aether.resolution.ArtifactResult; //导入方法依赖的package包/类
/**
 * Uses the aether to resolve a plugin dependency and returns the file for further processing.
 *
 * @param d the dependency to resolve.
 * @param pluginRepos the plugin repositories to use for dependency resolution.
 * @param resolver the resolver for aether access.
 * @param repoSystemSession the session for the resolver.
 * @return optionally a file which is the resolved dependency.
 */
public static Optional<File> resolvePluginDependency(Dependency d, List<RemoteRepository> pluginRepos,
    ArtifactResolver resolver, RepositorySystemSession repoSystemSession) {
  Artifact a = new DefaultArtifact(d.getGroupId(), d.getArtifactId(), d.getClassifier(), d.getType(), d.getVersion());
  ArtifactRequest artifactRequest = new ArtifactRequest();
  artifactRequest.setArtifact(a);
  artifactRequest.setRepositories(pluginRepos);
  try {
    ArtifactResult artifactResult = resolver.resolveArtifact(repoSystemSession, artifactRequest);
    if (artifactResult.getArtifact() != null) {
      return Optional.fromNullable(artifactResult.getArtifact().getFile());
    }
    return Optional.absent();
  } catch (ArtifactResolutionException e) {
    return Optional.absent();
  }
}
 
开发者ID:shillner,项目名称:maven-cdi-plugin-utils,代码行数:26,代码来源:MavenUtil.java

示例2: createAndroidPomDependencySection

import org.eclipse.aether.resolution.ArtifactResult; //导入方法依赖的package包/类
public String createAndroidPomDependencySection() throws MojoFailureException {
	String dependencies = "";
	List<ArtifactResult> resolvedArtifacts = resolveArtifacts();
	for (ArtifactResult resolvedArtifact : resolvedArtifacts) {
		Artifact artifact = resolvedArtifact.getArtifact();
		if (artifact.getProperty("type", "").equals("aar")) {
			dependencies += "<dependency>";
			dependencies += "<groupId>" + artifact.getGroupId() + "</groupId>";
			dependencies += "<artifactId>" + artifact.getArtifactId() + "</artifactId>";
			dependencies += "<version>" + artifact.getVersion() + "</version>";
			dependencies += "<type>" + artifact.getProperty("type", "") + "</type>";
			dependencies += "</dependency>";
		}
	}
	return dependencies;
}
 
开发者ID:mestevens,项目名称:unity-maven-plugin,代码行数:17,代码来源:DependencyGatherer.java

示例3: createXcodePomDependencySection

import org.eclipse.aether.resolution.ArtifactResult; //导入方法依赖的package包/类
public String createXcodePomDependencySection() throws MojoFailureException {
	String dependencies = "";
	List<ArtifactResult> resolvedArtifacts = resolveArtifacts();
	for (ArtifactResult resolvedArtifact : resolvedArtifacts) {
		Artifact artifact = resolvedArtifact.getArtifact();
		if (artifact.getProperty("type", "").equals("xcode-framework")) {
			dependencies += "<dependency>";
			dependencies += "<groupId>" + artifact.getGroupId() + "</groupId>";
			dependencies += "<artifactId>" + artifact.getArtifactId() + "</artifactId>";
			dependencies += "<version>" + artifact.getVersion() + "</version>";
			dependencies += "<type>" + artifact.getProperty("type", "") + "</type>";
			dependencies += "</dependency>";
		}
	}
	return dependencies;
}
 
开发者ID:mestevens,项目名称:unity-maven-plugin,代码行数:17,代码来源:DependencyGatherer.java

示例4: get

import org.eclipse.aether.resolution.ArtifactResult; //导入方法依赖的package包/类
public Path get(@NotNull String groupName, @NotNull String artifactName, @NotNull String version, @NotNull String artifactFileExtension) {
    Artifact artifact = new DefaultArtifact(groupName, artifactName, artifactFileExtension, version);

    RepositorySystem system = newRepositorySystem();
    RepositorySystemSession session = newRepositorySystemSession(system);

    ArtifactRequest request = new ArtifactRequest();
    request.setArtifact(artifact);
    request.setRepositories(repositories(system, session));

    try {
        ArtifactResult artifactResult = system.resolveArtifact(session, request);

        artifact = artifactResult.getArtifact();

        Log.info(artifact + " resolved to  " + artifact.getFile());

        return artifact.getFile().toPath();

    } catch (ArtifactResolutionException e) {
        throw new RuntimeException(format("Couldn't resolve a '%s' artifact for '%s:%s:%s'",
                artifactFileExtension, groupName, artifactName, version
        ), e);
    }
}
 
开发者ID:jan-molak,项目名称:jenkins-build-monitor-plugin,代码行数:26,代码来源:ArtifactTransporter.java

示例5: getArtifacts

import org.eclipse.aether.resolution.ArtifactResult; //导入方法依赖的package包/类
public List<Artifact> getArtifacts(DependencyFilter transitiveFilter)
		throws DependencyCollectionException, DependencyResolutionException {
	CollectRequest request = new CollectRequest(dependency, remoteRepos);
	DependencyRequest dependencyRequest = new DependencyRequest(request,
			transitiveFilter);
	DependencyResult dependencyResult = repoSystem.resolveDependencies(
			repoSession, dependencyRequest);
	List<ArtifactResult> artifactResults = dependencyResult
			.getArtifactResults();

	List<Artifact> artifacts = new ArrayList<Artifact>();
	for (ArtifactResult artifactResult : artifactResults) {
		Artifact artifact = artifactResult.getArtifact();
		artifacts.add(artifact);
	}
	return artifacts;
}
 
开发者ID:link-intersystems,项目名称:maven,代码行数:18,代码来源:RichDependency.java

示例6: getRunTimeTransitiveDeps

import org.eclipse.aether.resolution.ArtifactResult; //导入方法依赖的package包/类
private ImmutableMap<String, Artifact> getRunTimeTransitiveDeps(Iterable<Dependency> mavenCoords)
    throws RepositoryException {

  CollectRequest collectRequest = new CollectRequest();
  collectRequest.setRequestContext(JavaScopes.RUNTIME);
  collectRequest.setRepositories(repos);

  for (Dependency dep : mavenCoords) {
    collectRequest.addDependency(dep);
  }

  DependencyFilter filter = DependencyFilterUtils.classpathFilter(JavaScopes.RUNTIME);
  DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, filter);

  DependencyResult dependencyResult = repoSys.resolveDependencies(session, dependencyRequest);

  ImmutableSortedMap.Builder<String, Artifact> knownDeps = ImmutableSortedMap.naturalOrder();
  for (ArtifactResult artifactResult : dependencyResult.getArtifactResults()) {
    Artifact node = artifactResult.getArtifact();
    knownDeps.put(buildKey(node), node);
  }
  return knownDeps.build();
}
 
开发者ID:facebook,项目名称:buck,代码行数:24,代码来源:Resolver.java

示例7: downloadAttachments

import org.eclipse.aether.resolution.ArtifactResult; //导入方法依赖的package包/类
/**
 * Downloads additional artifacts like javadoc or sources.
 * 
 * @param depResult
 *          a set of resolved dependencies
 * @param attachment
 *          type of attachment. Either "javadoc" or "sources"
 * @throws DependencyCollectionException
 */
private void downloadAttachments(DependencyResult depResult, final String attachment) throws DependencyCollectionException {

  for (ArtifactResult artifactResult : depResult.getArtifactResults()) {

    final Artifact artifact = artifactResult.getArtifact();
    final String artifactId = artifact.getArtifactId();
    final String groupId = artifact.getGroupId();
    final String extension = artifact.getExtension();
    final String version = artifact.getVersion();

    log.info("Resolving {} for {}", attachment, artifact);

    try {
      DefaultArtifact extraArtifact = new DefaultArtifact(groupId, artifactId, attachment, extension, version);
      Dependency attachedDependency = new Dependency(extraArtifact, JavaScopes.COMPILE);

      DependencyNode attachmentNode = repoSystemHelper.collectDependencies(attachedDependency);
      DependencyRequest javadocDependencyRequest = new DependencyRequest(attachmentNode, null);

      repoSystemHelper.resolveDependencies(javadocDependencyRequest);
    } catch (DependencyResolutionException de) {
      log.warn("No {} found for {}", attachment, artifact);
    }
  }
}
 
开发者ID:Gemba,项目名称:mvn-dd,代码行数:35,代码来源:DependencyResolver.java

示例8: resolveArtifact

import org.eclipse.aether.resolution.ArtifactResult; //导入方法依赖的package包/类
private Artifact resolveArtifact(Artifact artifact) throws Exception {
    ArtifactRequest request = new ArtifactRequest();
    request.setArtifact(artifact);
    request.setRepositories(repositories());
    ArtifactResult result = system.resolveArtifact(session, request);
    return result.getArtifact();
}
 
开发者ID:shlee89,项目名称:athena,代码行数:8,代码来源:AetherResolver.java

示例9: getResolutionResult

import org.eclipse.aether.resolution.ArtifactResult; //导入方法依赖的package包/类
private ResolutionResult getResolutionResult(ArtifactResult artifactResult, boolean remoteOnly) {
  ResolutionResult result = null;
  Artifact artifact = artifactResult.getArtifact();
  if (artifact != null) {
    String repositoryId = artifactResult.getRepository().getId();
    if (remoteOnly) {
      if (!Objects.equal(repositoryId, this.repoSession.getLocalRepository().getId())) {
        result = new ResolutionResult(artifact.getFile(), repositoryId);
      }
    } else {
      result = new ResolutionResult(artifact.getFile(), repositoryId);
    }
  }
  return result;
}
 
开发者ID:shillner,项目名称:unleash-maven-plugin,代码行数:16,代码来源:ArtifactResolver.java

示例10: getFileFromLocalRepository

import org.eclipse.aether.resolution.ArtifactResult; //导入方法依赖的package包/类
/**
 * try to resolve a maven reference and return corresponding file in local
 * repository mavenReference url is not updated
 */
@Override
public File getFileFromLocalRepository(MavenReference mavenRef) {
    Artifact artifactToFind = convertToArtifact(mavenRef);
    ArtifactResult result;
    try {
        result = resolveArtifact(artifactToFind);
    } catch (ArtifactResolutionException e) {
        throw new MavenReferenceResolutionException(mavenRef, e);
    }
    Artifact artifact = result.getArtifact();
    if (artifact == null)
        throw new MavenReferenceResolutionException(mavenRef, "artifact is null");
    return artifact.getFile();
}
 
开发者ID:orange-cloudfoundry,项目名称:elpaaso-core,代码行数:19,代码来源:MvnRepoDaoImpl.java

示例11: resolveArtifact

import org.eclipse.aether.resolution.ArtifactResult; //导入方法依赖的package包/类
private Artifact resolveArtifact(Artifact artifact, RepositorySystemSession session) throws ArtifactResolutionException {
    ArtifactRequest request = new ArtifactRequest().setArtifact(artifact)
            .setRepositories(repositories);

    ArtifactResult result = repositorySystem.resolveArtifact(session, request);
    return result.getArtifact();
}
 
开发者ID:revapi,项目名称:revapi,代码行数:8,代码来源:ArtifactResolver.java

示例12: downloadArtifact

import org.eclipse.aether.resolution.ArtifactResult; //导入方法依赖的package包/类
private Artifact downloadArtifact(
    Artifact artifact,
    RemoteRepository repository,
    RepositorySystemSession session,
    RepositorySystem system)
    throws ArtifactResolutionException {
  ArtifactRequest artifactRequest = new ArtifactRequest();
  artifactRequest.setArtifact(artifact);
  artifactRequest.setRepositories(ImmutableList.of(repository));
  ArtifactResult artifactResult = system.resolveArtifact(session, artifactRequest);
  return artifactResult.getArtifact();
}
 
开发者ID:bazelbuild,项目名称:bazel,代码行数:13,代码来源:MavenDownloader.java

示例13: resolveResources

import org.eclipse.aether.resolution.ArtifactResult; //导入方法依赖的package包/类
@Override
public Response<File[]> resolveResources(final AddonId addonId)
{
   RepositorySystem system = container.getRepositorySystem();
   Settings settings = getSettings();
   DefaultRepositorySystemSession session = container.setupRepoSession(system, settings);
   final String mavenCoords = toMavenCoords(addonId);
   Artifact queryArtifact = new DefaultArtifact(mavenCoords);
   session.setDependencyTraverser(new AddonDependencyTraverser(classifier));
   session.setDependencySelector(new AddonDependencySelector(classifier));
   Dependency dependency = new Dependency(queryArtifact, null);

   List<RemoteRepository> repositories = MavenRepositories.getRemoteRepositories(container, settings);

   CollectRequest collectRequest = new CollectRequest(dependency, repositories);
   DependencyResult result;
   try
   {
      result = system.resolveDependencies(session, new DependencyRequest(collectRequest, null));
   }
   catch (DependencyResolutionException e)
   {
      throw new RuntimeException(e);
   }
   List<Exception> collectExceptions = result.getCollectExceptions();
   Set<File> files = new HashSet<File>();
   List<ArtifactResult> artifactResults = result.getArtifactResults();
   for (ArtifactResult artifactResult : artifactResults)
   {
      Artifact artifact = artifactResult.getArtifact();
      if (isFurnaceAPI(artifact) ||
               (this.classifier.equals(artifact.getClassifier())
                        && !addonId.getName().equals(artifact.getGroupId() + ":" + artifact.getArtifactId())))
      {
         continue;
      }
      files.add(artifact.getFile());
   }
   return new MavenResponseBuilder<File[]>(files.toArray(new File[files.size()])).setExceptions(collectExceptions);
}
 
开发者ID:forge,项目名称:furnace,代码行数:41,代码来源:MavenAddonDependencyResolver.java

示例14: resolve

import org.eclipse.aether.resolution.ArtifactResult; //导入方法依赖的package包/类
/**
 * Resolves an artifact and returns its resolved instance.
 *
 * @param pArtifactRequest
 *          The request of the artifact.
 * @return The resolved artifact.
 * @throws MojoExecutionException
 *           if anything happens.
 */
public Artifact resolve(final ArtifactRequest pArtifactRequest) throws MojoExecutionException {
  ArtifactRequest artifactRequest =
      new ArtifactRequest(pArtifactRequest.getArtifact(), remoteRepositories, null);
  ArtifactResult artifactResult;
  try {
    artifactResult = repositorySystem.resolveArtifact(repositorySystemSession, artifactRequest);
  } catch (ArtifactResolutionException e) {
    throw new MojoExecutionException(
        "Could not resolve artifact: " + artifactRequest.getArtifact(), e);
  }
  if (!artifactResult.isResolved()) {
    List<Exception> exceptions = artifactResult.getExceptions();
    if (exceptions.size() == 0) {
      throw new MojoExecutionException(
          "Could not resolve artifact: " + artifactRequest.getArtifact());
    } else if (exceptions.size() == 1) {
      throw new MojoExecutionException(
          "Could not resolve artifact: " + artifactRequest.getArtifact(), exceptions.get(0));
    } else {
      Iterator<Exception> iterator = exceptions.iterator();
      while (iterator.hasNext()) {
        Exception exception = iterator.next();
        if (iterator.hasNext()) {
          log.error(exception);
        } else {
          throw new MojoExecutionException(
              "Could not resolve artifact: " + artifactRequest.getArtifact(), exception);
        }
      }

    }
  }
  return artifactResult.getArtifact();
}
 
开发者ID:everit-org,项目名称:eosgi-maven-plugin,代码行数:44,代码来源:PredefinedRepoArtifactResolver.java

示例15: resolveResources

import org.eclipse.aether.resolution.ArtifactResult; //导入方法依赖的package包/类
@Override
public Response<File[]> resolveResources(final AddonId addonId)
{
   RepositorySystem system = container.getRepositorySystem();
   Settings settings = getSettings();
   DefaultRepositorySystemSession session = container.setupRepoSession(system, settings);
   final String mavenCoords = toMavenCoords(addonId);
   Artifact queryArtifact = new DefaultArtifact(mavenCoords);
   session.setDependencyTraverser(new AddonDependencyTraverser(classifier));
   session.setDependencySelector(new AddonDependencySelector(classifier));
   Dependency dependency = new Dependency(queryArtifact, null);

   List<RemoteRepository> repositories = MavenRepositories.getRemoteRepositories(container, settings);

   CollectRequest collectRequest = new CollectRequest(dependency, repositories);
   DependencyResult result;
   try
   {
      result = system.resolveDependencies(session, new DependencyRequest(collectRequest, null));
   }
   catch (DependencyResolutionException e)
   {
      throw new RuntimeException(e);
   }
   List<Exception> collectExceptions = result.getCollectExceptions();
   Set<File> files = new HashSet<File>();
   List<ArtifactResult> artifactResults = result.getArtifactResults();
   for (ArtifactResult artifactResult : artifactResults)
   {
      Artifact artifact = artifactResult.getArtifact();
      if (this.classifier.equals(artifact.getClassifier())
               && !mavenCoords.equals(artifact.toString()))
      {
         continue;
      }
      files.add(artifact.getFile());
   }
   return new MavenResponseBuilder<File[]>(files.toArray(new File[files.size()])).setExceptions(collectExceptions);
}
 
开发者ID:koentsje,项目名称:forge-furnace,代码行数:40,代码来源:MavenAddonDependencyResolver.java


注:本文中的org.eclipse.aether.resolution.ArtifactResult.getArtifact方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。