{
RepositorySystem system = container.getRepositorySystem();
Settings settings = container.getSettings();
DefaultRepositorySystemSession session = container.setupRepoSession(system, settings);
final String mavenCoords = toMavenCoords(addonId);
Artifact queryArtifact = new DefaultArtifact(mavenCoords);
session.setDependencyTraverser(new AddonDependencyTraverser());
session.setDependencySelector(new AddonDependencySelector());
Dependency dependency = new Dependency(queryArtifact, null);
List<RemoteRepository> repositories = MavenRepositories.getRemoteRepositories(container, settings);
CollectRequest collectRequest = new CollectRequest(dependency, repositories);
DependencyResult result;
try
{
result = system.resolveDependencies(session, new DependencyRequest(collectRequest, null));
}
catch (DependencyResolutionException e)
{
throw new RuntimeException(e);
}
Set<File> files = new HashSet<File>();
List<ArtifactResult> artifactResults = result.getArtifactResults();
for (ArtifactResult artifactResult : artifactResults)
{
Artifact artifact = artifactResult.getArtifact();
if (FORGE_ADDON_CLASSIFIER.equals(artifact.getClassifier())
&& !mavenCoords.equals(artifact.toString()))
{
continue;
}
files.add(artifact.getFile());
}
return files.toArray(new File[files.size()]);
}