private static void printMissingArtifactsToSysErr(Iterable<ArtifactResult> missingArtifacts) { for (ArtifactResult artifactResult : missingArtifacts) { System.err.println("ArtifactResult : " + artifactResult + " / Errors : " + artifactResult.getExceptions()); } }
private void process( DefaultDependencyResolutionResult result, Collection<ArtifactResult> results ) { for ( ArtifactResult ar : results ) { DependencyNode node = ar.getRequest().getDependencyNode(); if ( ar.isResolved() ) { result.addResolvedDependency( node.getDependency() ); } else { result.setResolutionErrors( node.getDependency(), ar.getExceptions() ); } } }
/** * Logs the paths for each dependency not found * * @param node root {@link DependencyNode}, can be a "null" root (imaginary root) * @param e {@link DependencyResolutionException} the error to collect paths. */ private void logUnresolvedArtifacts(DependencyNode node, DependencyResolutionException e) { List<ArtifactResult> artifactResults = e.getResult().getArtifactResults().stream() .filter(artifactResult -> !artifactResult.getExceptions().isEmpty()).collect(toList()); final List<String> patternInclusion = artifactResults.stream().map(artifactResult -> toId(artifactResult.getRequest().getArtifact())).collect(toList()); PathRecordingDependencyVisitor visitor = new PathRecordingDependencyVisitor(new PatternInclusionsDependencyFilter(patternInclusion), node.getArtifact() != null); node.accept(visitor); visitor.getPaths().stream().forEach(path -> { List<DependencyNode> unresolvedArtifactPath = path.stream().filter(dependencyNode -> dependencyNode.getArtifact() != null).collect(toList()); if (!unresolvedArtifactPath.isEmpty()) { logger.warn("Dependency path to not resolved artifacts -> {}", unresolvedArtifactPath.toString()); } }); }
/** * Indicates whether the requested artifact is not present in any of the specified repositories. * * @return {@code true} if the artifact is not present in any repository, {@code false} otherwise. */ public boolean isMissing() { for ( Exception e : getExceptions() ) { if ( !( e instanceof ArtifactNotFoundException ) ) { return false; } } return !isResolved(); }
/** * Indicates whether the requested artifact is not present in any of the specified repositories. * * @return {@code true} if the artifact is not present in any repository, {@code false} otherwise. */ public boolean isMissing() { for ( Exception e : getExceptions() ) { if ( !( e instanceof ArtifactNotFoundException ) ) { return false; } } return !isResolved(); }
for ( Throwable t : result.getExceptions() )
for ( Throwable t : result.getExceptions() )
/** * Logs the paths for each dependency not found * * @param node root {@link DependencyNode}, can be a "null" root (imaginary root) * @param e {@link DependencyResolutionException} the error to collect paths. */ private void logUnresolvedArtifacts(DependencyNode node, DependencyResolutionException e) { List<ArtifactResult> artifactResults = e.getResult().getArtifactResults().stream() .filter(artifactResult -> !artifactResult.getExceptions().isEmpty()).collect(toList()); final List<String> patternInclusion = artifactResults.stream().map(artifactResult -> toId(artifactResult.getRequest().getArtifact())).collect(toList()); PathRecordingDependencyVisitor visitor = new PathRecordingDependencyVisitor(new PatternInclusionsDependencyFilter(patternInclusion), node.getArtifact() != null); node.accept(visitor); visitor.getPaths().stream().forEach(path -> { List<DependencyNode> unresolvedArtifactPath = path.stream().filter(dependencyNode -> dependencyNode.getArtifact() != null).collect(toList()); if (!unresolvedArtifactPath.isEmpty()) { logger.warn("Dependency path to not resolved artifacts -> {}", unresolvedArtifactPath.toString()); } }); }
processorpath.add(artifactResult.getArtifact().getFile()); } else { errors.addAll(artifactResult.getExceptions());
processorpath.add(artifactResult.getArtifact().getFile()); } else { errors.addAll(artifactResult.getExceptions());
artifact.setResolved(true); } else { throw new MavenException(result.getExceptions().toArray(new Exception[result.getExceptions().size()]));
@Override public ArtifactResult loadArtifact(String groupId, String artifactId, String classifier, String extension, String version) { Moment before = X_Time.now(); RepositorySystem repoSystem = this.repoSystem.get(); RepositorySystemSession session = this.session.get(); DefaultArtifact artifact = new DefaultArtifact( groupId,artifactId,classifier, X_String.isEmpty(extension) ? "jar" : extension, version); try { ArtifactRequest request = new ArtifactRequest(artifact, remoteRepos(), null); return repoSystem.resolveArtifact(session, request); } catch (ArtifactResolutionException e) { X_Log.log(getClass(), getLogLevel(), "Resolved? ", e.getResult().isResolved(), e.getResult().getExceptions()); X_Log.log(getClass(), getLogLevel(), "Could not download " + artifact, e); throw X_Debug.rethrow(e); } finally { if (X_Log.loggable(LogLevel.DEBUG)) { X_Log.debug("Resolved: " + artifact.toString() + " in " + X_Time.difference(before)); } } }
artifactResolved( session, trace, artifact, null, result.getExceptions() ); if ( result.getExceptions().isEmpty() ) artifactResolved( session, trace, request.getArtifact(), null, result.getExceptions() );
artifactResolved( session, trace, artifact, null, result.getExceptions() ); if ( result.getExceptions().isEmpty() ) artifactResolved( session, trace, request.getArtifact(), null, result.getExceptions() );
pomArtifact = downloadPom(artifact, session); } catch (ArtifactResolutionException e1) { if (e1.getResult() != null && !e1.getResult().getExceptions().isEmpty() && e1.getResult().getExceptions().get(0) instanceof ArtifactNotFoundException) { throw new ExtensionNotFoundException("Could not find artifact [" + artifact + "] descriptor", e1); } else {