当前位置: 首页>>代码示例>>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;未经允许,请勿转载。