當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。