當前位置: 首頁>>代碼示例>>Java>>正文


Java ArtifactResult.getExceptions方法代碼示例

本文整理匯總了Java中org.eclipse.aether.resolution.ArtifactResult.getExceptions方法的典型用法代碼示例。如果您正苦於以下問題:Java ArtifactResult.getExceptions方法的具體用法?Java ArtifactResult.getExceptions怎麽用?Java ArtifactResult.getExceptions使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.aether.resolution.ArtifactResult的用法示例。


在下文中一共展示了ArtifactResult.getExceptions方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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

示例2: asResult

import org.eclipse.aether.resolution.ArtifactResult; //導入方法依賴的package包/類
/**
 * Convert aether result list to AetherResult object
 *
 * @param results
 *            the result collection
 * @param cfg
 *            the import configuration
 * @param dependencyResult
 *            The result of the dependency resolution
 * @return the AetherResult object
 */
public static AetherResult asResult ( final Collection<ArtifactResult> results, final ImportConfiguration cfg, final Optional<DependencyResult> dependencyResult )
{
    final AetherResult result = new AetherResult ();

    // create set of requested coordinates

    final Set<String> requested = new HashSet<> ( cfg.getCoordinates ().size () );
    for ( final MavenCoordinates mc : cfg.getCoordinates () )
    {
        requested.add ( mc.toString () );
    }

    // generate dependency map

    final Map<String, Boolean> optionalDeps = new HashMap<> ();
    fillOptionalDependenciesMap ( dependencyResult, optionalDeps );

    // convert artifacts

    for ( final ArtifactResult ar : results )
    {
        final AetherResult.Entry entry = new AetherResult.Entry ();

        final MavenCoordinates coordinates = MavenCoordinates.fromResult ( ar );
        final String key = coordinates.toBase ().toString ();

        entry.setCoordinates ( coordinates );
        entry.setResolved ( ar.isResolved () );
        entry.setRequested ( requested.contains ( key ) );
        entry.setOptional ( optionalDeps.getOrDefault ( key, Boolean.FALSE ) );

        // convert error

        if ( ar.getExceptions () != null && !ar.getExceptions ().isEmpty () )
        {
            final StringBuilder sb = new StringBuilder ( ar.getExceptions ().get ( 0 ).getMessage () );
            if ( ar.getExceptions ().size () > 1 )
            {
                sb.append ( " ..." );
            }
            entry.setError ( sb.toString () );
        }

        // add to list

        result.getArtifacts ().add ( entry );
    }

    // sort by coordinates

    Collections.sort ( result.getArtifacts (), Comparator.comparing ( AetherResult.Entry::getCoordinates ) );

    // set repo url

    result.setRepositoryUrl ( cfg.getRepositoryUrl () );

    return result;
}
 
開發者ID:eclipse,項目名稱:packagedrone,代碼行數:70,代碼來源:AetherImporter.java


注:本文中的org.eclipse.aether.resolution.ArtifactResult.getExceptions方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。