Search in sources :

Example 1 with AndDependencySelector

use of org.sonatype.aether.util.graph.selector.AndDependencySelector in project karaf by apache.

the class Dependency30Helper method getDependencyTree.

private DependencyNode getDependencyTree(Artifact artifact) throws MojoExecutionException {
    try {
        CollectRequest collectRequest = new CollectRequest(new Dependency(artifact, "compile"), null, projectRepositories);
        DefaultRepositorySystemSession session = new DefaultRepositorySystemSession(repositorySystemSession);
        session.setDependencySelector(new AndDependencySelector(new OptionalDependencySelector(), new ScopeDependencySelector1(), new ExclusionDependencySelector()));
        DependencyGraphTransformer transformer = new ChainedDependencyGraphTransformer(new ConflictMarker(), new JavaEffectiveScopeCalculator(), new JavaDependencyContextRefiner());
        session.setDependencyGraphTransformer(transformer);
        CollectResult result = repositorySystem.collectDependencies(session, collectRequest);
        return result.getRoot();
    } catch (DependencyCollectionException e) {
        throw new MojoExecutionException("Cannot build project dependency tree", e);
    }
}
Also used : JavaDependencyContextRefiner(org.sonatype.aether.util.graph.transformer.JavaDependencyContextRefiner) DependencyCollectionException(org.sonatype.aether.collection.DependencyCollectionException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) CollectResult(org.sonatype.aether.collection.CollectResult) AndDependencySelector(org.sonatype.aether.util.graph.selector.AndDependencySelector) Dependency(org.sonatype.aether.graph.Dependency) CollectRequest(org.sonatype.aether.collection.CollectRequest) ChainedDependencyGraphTransformer(org.sonatype.aether.util.graph.transformer.ChainedDependencyGraphTransformer) OptionalDependencySelector(org.sonatype.aether.util.graph.selector.OptionalDependencySelector) DefaultRepositorySystemSession(org.sonatype.aether.util.DefaultRepositorySystemSession) JavaEffectiveScopeCalculator(org.sonatype.aether.util.graph.transformer.JavaEffectiveScopeCalculator) DependencyGraphTransformer(org.sonatype.aether.collection.DependencyGraphTransformer) ChainedDependencyGraphTransformer(org.sonatype.aether.util.graph.transformer.ChainedDependencyGraphTransformer) ConflictMarker(org.sonatype.aether.util.graph.transformer.ConflictMarker) ExclusionDependencySelector(org.sonatype.aether.util.graph.selector.ExclusionDependencySelector)

Example 2 with AndDependencySelector

use of org.sonatype.aether.util.graph.selector.AndDependencySelector in project archiva by apache.

the class Maven3DependencyTreeBuilder method newRepositorySystemSession.

private RepositorySystemSession newRepositorySystemSession(RepositorySystem system, String localRepoDir) {
    MavenRepositorySystemSession session = new MavenRepositorySystemSession();
    DependencySelector depFilter = new AndDependencySelector(new ExclusionDependencySelector());
    session.setDependencySelector(depFilter);
    session.setLocalRepositoryManager(new SimpleLocalRepositoryManager(localRepoDir));
    return session;
}
Also used : SimpleLocalRepositoryManager(org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager) AndDependencySelector(org.sonatype.aether.util.graph.selector.AndDependencySelector) DependencySelector(org.sonatype.aether.collection.DependencySelector) ExclusionDependencySelector(org.sonatype.aether.util.graph.selector.ExclusionDependencySelector) AndDependencySelector(org.sonatype.aether.util.graph.selector.AndDependencySelector) MavenRepositorySystemSession(org.apache.maven.repository.internal.MavenRepositorySystemSession) ExclusionDependencySelector(org.sonatype.aether.util.graph.selector.ExclusionDependencySelector)

Aggregations

AndDependencySelector (org.sonatype.aether.util.graph.selector.AndDependencySelector)2 ExclusionDependencySelector (org.sonatype.aether.util.graph.selector.ExclusionDependencySelector)2 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 MavenRepositorySystemSession (org.apache.maven.repository.internal.MavenRepositorySystemSession)1 CollectRequest (org.sonatype.aether.collection.CollectRequest)1 CollectResult (org.sonatype.aether.collection.CollectResult)1 DependencyCollectionException (org.sonatype.aether.collection.DependencyCollectionException)1 DependencyGraphTransformer (org.sonatype.aether.collection.DependencyGraphTransformer)1 DependencySelector (org.sonatype.aether.collection.DependencySelector)1 Dependency (org.sonatype.aether.graph.Dependency)1 SimpleLocalRepositoryManager (org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager)1 DefaultRepositorySystemSession (org.sonatype.aether.util.DefaultRepositorySystemSession)1 OptionalDependencySelector (org.sonatype.aether.util.graph.selector.OptionalDependencySelector)1 ChainedDependencyGraphTransformer (org.sonatype.aether.util.graph.transformer.ChainedDependencyGraphTransformer)1 ConflictMarker (org.sonatype.aether.util.graph.transformer.ConflictMarker)1 JavaDependencyContextRefiner (org.sonatype.aether.util.graph.transformer.JavaDependencyContextRefiner)1 JavaEffectiveScopeCalculator (org.sonatype.aether.util.graph.transformer.JavaEffectiveScopeCalculator)1