{
try
{
RepositorySystem system = container.getRepositorySystem();
Settings settings = container.getSettings();
MavenRepositorySystemSession session = container.setupRepoSession(system, settings);
session.setTransferListener(new LogTransferListener());
session.setDependencyTraverser(new DependencyTraverser()
{
@Override
public boolean traverseDependency(org.sonatype.aether.graph.Dependency dependency)
{
boolean isForgeAddon = DependencyNodeUtil.FORGE_ADDON_CLASSIFIER.equals(dependency.getArtifact()
.getClassifier());
// We don't want to traverse non-addons optional dependencies
if (!isForgeAddon && dependency.isOptional())
{
return false;
}
boolean result;
if (query.getScopeType() != null)
{
result = query.getScopeType().equals(dependency.getScope());
}
else
{
result = !"test".equals(dependency.getScope());
}
return result;
}
@Override
public DependencyTraverser deriveChildTraverser(DependencyCollectionContext context)
{
return this;
}
});
session.setDependencySelector(new AddonDependencySelector());
final CoordinateBuilder coord = CoordinateBuilder.create(query.getCoordinate());
Artifact queryArtifact = coordinateToMavenArtifact(coord);
CollectRequest collectRequest = new CollectRequest(new org.sonatype.aether.graph.Dependency(queryArtifact,
null), container.getEnabledRepositoriesFromProfile(settings));