Search in sources :

Example 1 with OptionalDependencySelector

use of org.eclipse.aether.util.graph.selector.OptionalDependencySelector in project karaf by apache.

the class Dependency31Helper 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()));
        // between aether-util 0.9.0.M1 and M2, JavaEffectiveScopeCalculator was removed
        // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=397241
        DependencyGraphTransformer transformer = new ChainedDependencyGraphTransformer(new ConflictMarker(), new ConflictResolver(new NearestVersionSelector(), new JavaScopeSelector(), new SimpleOptionalitySelector(), new JavaScopeDeriver()), 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 : MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) AndDependencySelector(org.eclipse.aether.util.graph.selector.AndDependencySelector) Dependency(org.eclipse.aether.graph.Dependency) OptionalDependencySelector(org.eclipse.aether.util.graph.selector.OptionalDependencySelector) DefaultRepositorySystemSession(org.eclipse.aether.DefaultRepositorySystemSession) ExclusionDependencySelector(org.eclipse.aether.util.graph.selector.ExclusionDependencySelector)

Example 2 with OptionalDependencySelector

use of org.eclipse.aether.util.graph.selector.OptionalDependencySelector in project fabric8 by jboss-fuse.

the class AetherBasedResolver method newRepositorySystemSession.

private static DefaultRepositorySystemSession newRepositorySystemSession() {
    DefaultRepositorySystemSession session = new DefaultRepositorySystemSession();
    DependencyTraverser depTraverser = new FatArtifactTraverser();
    session.setDependencyTraverser(depTraverser);
    DependencyManager depManager = new ClassicDependencyManager();
    session.setDependencyManager(depManager);
    DependencySelector depFilter = new AndDependencySelector(new ScopeDependencySelector("test", "provided"), new OptionalDependencySelector(), new ExclusionDependencySelector());
    session.setDependencySelector(depFilter);
    DependencyGraphTransformer transformer = new ConflictResolver(new NearestVersionSelector(), new JavaScopeSelector(), new SimpleOptionalitySelector(), new JavaScopeDeriver());
    new ChainedDependencyGraphTransformer(transformer, new JavaDependencyContextRefiner());
    session.setDependencyGraphTransformer(transformer);
    DefaultArtifactTypeRegistry stereotypes = new DefaultArtifactTypeRegistry();
    stereotypes.add(new DefaultArtifactType("pom"));
    stereotypes.add(new DefaultArtifactType("maven-plugin", "jar", "", "java"));
    stereotypes.add(new DefaultArtifactType("jar", "jar", "", "java"));
    stereotypes.add(new DefaultArtifactType("ejb", "jar", "", "java"));
    stereotypes.add(new DefaultArtifactType("ejb-client", "jar", "client", "java"));
    stereotypes.add(new DefaultArtifactType("test-jar", "jar", "tests", "java"));
    stereotypes.add(new DefaultArtifactType("javadoc", "jar", "javadoc", "java"));
    stereotypes.add(new DefaultArtifactType("java-source", "jar", "sources", "java", false, false));
    stereotypes.add(new DefaultArtifactType("war", "war", "", "java", false, true));
    stereotypes.add(new DefaultArtifactType("ear", "ear", "", "java", false, true));
    stereotypes.add(new DefaultArtifactType("rar", "rar", "", "java", false, true));
    stereotypes.add(new DefaultArtifactType("par", "par", "", "java", false, true));
    session.setArtifactTypeRegistry(stereotypes);
    session.setArtifactDescriptorPolicy(new SimpleArtifactDescriptorPolicy(true, true));
    Properties sysProps = (Properties) System.getProperties().clone();
    session.setSystemProperties(sysProps);
    session.setConfigProperties(sysProps);
    // set timeout smaller than 30 minutes by default
    session.setConfigProperty(ConfigurationProperties.REQUEST_TIMEOUT, TimeUnit.MINUTES.toMillis(5));
    return session;
}
Also used : JavaDependencyContextRefiner(org.eclipse.aether.util.graph.transformer.JavaDependencyContextRefiner) ConflictResolver(org.eclipse.aether.util.graph.transformer.ConflictResolver) ClassicDependencyManager(org.eclipse.aether.util.graph.manager.ClassicDependencyManager) DependencyManager(org.eclipse.aether.collection.DependencyManager) JavaScopeDeriver(org.eclipse.aether.util.graph.transformer.JavaScopeDeriver) AndDependencySelector(org.eclipse.aether.util.graph.selector.AndDependencySelector) DependencyTraverser(org.eclipse.aether.collection.DependencyTraverser) ConfigurationProperties(org.eclipse.aether.ConfigurationProperties) ArtifactProperties(org.eclipse.aether.artifact.ArtifactProperties) Properties(java.util.Properties) FatArtifactTraverser(org.eclipse.aether.util.graph.traverser.FatArtifactTraverser) ChainedDependencyGraphTransformer(org.eclipse.aether.util.graph.transformer.ChainedDependencyGraphTransformer) OptionalDependencySelector(org.eclipse.aether.util.graph.selector.OptionalDependencySelector) SimpleOptionalitySelector(org.eclipse.aether.util.graph.transformer.SimpleOptionalitySelector) NearestVersionSelector(org.eclipse.aether.util.graph.transformer.NearestVersionSelector) ClassicDependencyManager(org.eclipse.aether.util.graph.manager.ClassicDependencyManager) DefaultRepositorySystemSession(org.eclipse.aether.DefaultRepositorySystemSession) DefaultArtifactTypeRegistry(org.eclipse.aether.util.artifact.DefaultArtifactTypeRegistry) JavaScopeSelector(org.eclipse.aether.util.graph.transformer.JavaScopeSelector) AndDependencySelector(org.eclipse.aether.util.graph.selector.AndDependencySelector) ScopeDependencySelector(org.eclipse.aether.util.graph.selector.ScopeDependencySelector) OptionalDependencySelector(org.eclipse.aether.util.graph.selector.OptionalDependencySelector) ExclusionDependencySelector(org.eclipse.aether.util.graph.selector.ExclusionDependencySelector) DependencySelector(org.eclipse.aether.collection.DependencySelector) ChainedDependencyGraphTransformer(org.eclipse.aether.util.graph.transformer.ChainedDependencyGraphTransformer) DependencyGraphTransformer(org.eclipse.aether.collection.DependencyGraphTransformer) DefaultArtifactType(org.eclipse.aether.artifact.DefaultArtifactType) SimpleArtifactDescriptorPolicy(org.eclipse.aether.util.repository.SimpleArtifactDescriptorPolicy) ScopeDependencySelector(org.eclipse.aether.util.graph.selector.ScopeDependencySelector) ExclusionDependencySelector(org.eclipse.aether.util.graph.selector.ExclusionDependencySelector)

Aggregations

DefaultRepositorySystemSession (org.eclipse.aether.DefaultRepositorySystemSession)2 AndDependencySelector (org.eclipse.aether.util.graph.selector.AndDependencySelector)2 ExclusionDependencySelector (org.eclipse.aether.util.graph.selector.ExclusionDependencySelector)2 OptionalDependencySelector (org.eclipse.aether.util.graph.selector.OptionalDependencySelector)2 Properties (java.util.Properties)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 ConfigurationProperties (org.eclipse.aether.ConfigurationProperties)1 ArtifactProperties (org.eclipse.aether.artifact.ArtifactProperties)1 DefaultArtifactType (org.eclipse.aether.artifact.DefaultArtifactType)1 DependencyGraphTransformer (org.eclipse.aether.collection.DependencyGraphTransformer)1 DependencyManager (org.eclipse.aether.collection.DependencyManager)1 DependencySelector (org.eclipse.aether.collection.DependencySelector)1 DependencyTraverser (org.eclipse.aether.collection.DependencyTraverser)1 Dependency (org.eclipse.aether.graph.Dependency)1 DefaultArtifactTypeRegistry (org.eclipse.aether.util.artifact.DefaultArtifactTypeRegistry)1 ClassicDependencyManager (org.eclipse.aether.util.graph.manager.ClassicDependencyManager)1 ScopeDependencySelector (org.eclipse.aether.util.graph.selector.ScopeDependencySelector)1 ChainedDependencyGraphTransformer (org.eclipse.aether.util.graph.transformer.ChainedDependencyGraphTransformer)1 ConflictResolver (org.eclipse.aether.util.graph.transformer.ConflictResolver)1 JavaDependencyContextRefiner (org.eclipse.aether.util.graph.transformer.JavaDependencyContextRefiner)1