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);
}
}
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;
}
Aggregations