Search in sources :

Example 1 with PatternExclusionsDependencyFilter

use of org.eclipse.aether.util.filter.PatternExclusionsDependencyFilter in project zeppelin by apache.

the class DependencyResolver method getArtifactsWithDep.

/**
 * @param dependency
 * @param excludes list of pattern can either be of the form groupId:artifactId
 * @return
 * @throws Exception
 */
@Override
public List<ArtifactResult> getArtifactsWithDep(String dependency, Collection<String> excludes) throws RepositoryException {
    Artifact artifact = new DefaultArtifact(dependency);
    DependencyFilter classpathFilter = DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE);
    PatternExclusionsDependencyFilter exclusionFilter = new PatternExclusionsDependencyFilter(excludes);
    CollectRequest collectRequest = new CollectRequest();
    collectRequest.setRoot(new Dependency(artifact, JavaScopes.COMPILE));
    synchronized (repos) {
        for (RemoteRepository repo : repos) {
            collectRequest.addRepository(repo);
        }
    }
    DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, DependencyFilterUtils.andFilter(exclusionFilter, classpathFilter));
    try {
        return system.resolveDependencies(session, dependencyRequest).getArtifactResults();
    } catch (NullPointerException | DependencyResolutionException ex) {
        throw new RepositoryException(String.format("Cannot fetch dependencies for %s", dependency), ex);
    }
}
Also used : DependencyRequest(org.eclipse.aether.resolution.DependencyRequest) DependencyFilter(org.eclipse.aether.graph.DependencyFilter) PatternExclusionsDependencyFilter(org.eclipse.aether.util.filter.PatternExclusionsDependencyFilter) RemoteRepository(org.eclipse.aether.repository.RemoteRepository) DependencyResolutionException(org.eclipse.aether.resolution.DependencyResolutionException) RepositoryException(org.eclipse.aether.RepositoryException) Dependency(org.eclipse.aether.graph.Dependency) CollectRequest(org.eclipse.aether.collection.CollectRequest) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact) Artifact(org.eclipse.aether.artifact.Artifact) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact) PatternExclusionsDependencyFilter(org.eclipse.aether.util.filter.PatternExclusionsDependencyFilter)

Aggregations

RepositoryException (org.eclipse.aether.RepositoryException)1 Artifact (org.eclipse.aether.artifact.Artifact)1 DefaultArtifact (org.eclipse.aether.artifact.DefaultArtifact)1 CollectRequest (org.eclipse.aether.collection.CollectRequest)1 Dependency (org.eclipse.aether.graph.Dependency)1 DependencyFilter (org.eclipse.aether.graph.DependencyFilter)1 RemoteRepository (org.eclipse.aether.repository.RemoteRepository)1 DependencyRequest (org.eclipse.aether.resolution.DependencyRequest)1 DependencyResolutionException (org.eclipse.aether.resolution.DependencyResolutionException)1 PatternExclusionsDependencyFilter (org.eclipse.aether.util.filter.PatternExclusionsDependencyFilter)1