Search in sources :

Example 1 with PatternInclusionsDependencyFilter

use of org.eclipse.aether.util.filter.PatternInclusionsDependencyFilter in project mule by mulesoft.

the class DependencyResolver method logUnresolvedArtifacts.

/**
 * 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());
        }
    });
}
Also used : DependencyFilter(org.eclipse.aether.graph.DependencyFilter) ArtifactDescriptorRequest(org.eclipse.aether.resolution.ArtifactDescriptorRequest) MavenConfiguration(org.mule.maven.client.api.model.MavenConfiguration) Dependency(org.eclipse.aether.graph.Dependency) LoggerFactory(org.slf4j.LoggerFactory) RepositorySystemSession(org.eclipse.aether.RepositorySystemSession) PatternInclusionsDependencyFilter(org.eclipse.aether.util.filter.PatternInclusionsDependencyFilter) ArtifactDescriptorException(org.eclipse.aether.resolution.ArtifactDescriptorException) AetherResolutionContext(org.mule.maven.client.internal.AetherResolutionContext) ArtifactResolutionException(org.eclipse.aether.resolution.ArtifactResolutionException) DependencyResolutionException(org.eclipse.aether.resolution.DependencyResolutionException) ArtifactIdUtils.toId(org.eclipse.aether.util.artifact.ArtifactIdUtils.toId) CollectRequest(org.eclipse.aether.collection.CollectRequest) DependencyCollectionException(org.eclipse.aether.collection.DependencyCollectionException) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) ReflectionToStringBuilder(org.apache.commons.lang3.builder.ReflectionToStringBuilder) DependencyNode(org.eclipse.aether.graph.DependencyNode) Artifact(org.eclipse.aether.artifact.Artifact) PreorderNodeListGenerator(org.eclipse.aether.util.graph.visitor.PreorderNodeListGenerator) Preconditions.checkNotNull(org.mule.runtime.api.util.Preconditions.checkNotNull) AetherRepositoryState(org.mule.maven.client.internal.AetherRepositoryState) ArtifactResult(org.eclipse.aether.resolution.ArtifactResult) DependencyRequest(org.eclipse.aether.resolution.DependencyRequest) Joiner.on(com.google.common.base.Joiner.on) File(java.io.File) WorkspaceReader(org.eclipse.aether.repository.WorkspaceReader) RemoteRepository(org.eclipse.aether.repository.RemoteRepository) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List) ArtifactRequest(org.eclipse.aether.resolution.ArtifactRequest) Optional(java.util.Optional) PathRecordingDependencyVisitor(org.eclipse.aether.util.graph.visitor.PathRecordingDependencyVisitor) ArtifactDescriptorResult(org.eclipse.aether.resolution.ArtifactDescriptorResult) RepositorySystem(org.eclipse.aether.RepositorySystem) PatternInclusionsDependencyFilter(org.eclipse.aether.util.filter.PatternInclusionsDependencyFilter) PathRecordingDependencyVisitor(org.eclipse.aether.util.graph.visitor.PathRecordingDependencyVisitor) DependencyNode(org.eclipse.aether.graph.DependencyNode) ArtifactResult(org.eclipse.aether.resolution.ArtifactResult)

Aggregations

Joiner.on (com.google.common.base.Joiner.on)1 File (java.io.File)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Optional (java.util.Optional)1 Collectors.toList (java.util.stream.Collectors.toList)1 ReflectionToStringBuilder (org.apache.commons.lang3.builder.ReflectionToStringBuilder)1 RepositorySystem (org.eclipse.aether.RepositorySystem)1 RepositorySystemSession (org.eclipse.aether.RepositorySystemSession)1 Artifact (org.eclipse.aether.artifact.Artifact)1 CollectRequest (org.eclipse.aether.collection.CollectRequest)1 DependencyCollectionException (org.eclipse.aether.collection.DependencyCollectionException)1 Dependency (org.eclipse.aether.graph.Dependency)1 DependencyFilter (org.eclipse.aether.graph.DependencyFilter)1 DependencyNode (org.eclipse.aether.graph.DependencyNode)1 RemoteRepository (org.eclipse.aether.repository.RemoteRepository)1 WorkspaceReader (org.eclipse.aether.repository.WorkspaceReader)1 ArtifactDescriptorException (org.eclipse.aether.resolution.ArtifactDescriptorException)1 ArtifactDescriptorRequest (org.eclipse.aether.resolution.ArtifactDescriptorRequest)1 ArtifactDescriptorResult (org.eclipse.aether.resolution.ArtifactDescriptorResult)1