本文整理汇总了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();
}
示例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;
}