CollectRequest collectRequest = new CollectRequest(new Dependency(artifact, "compile"), null, projectRepos);
DefaultRepositorySystemSession session = new DefaultRepositorySystemSession(repoSession);
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 = repoSystem.collectDependencies(session, collectRequest);
return result.getRoot();