Resource<?> jar = dir.getChild(dep.getArtifactId() + "-" + dep.getVersion() + "."
+ dep.getPackagingType());
if (jar.exists())
{
FileResource<?> jarFile = jar.reify(FileResource.class);
result.add(new DependencyResource(jarFile.getResourceFactory(), jarFile
.getUnderlyingResourceObject(), dep));
}
}
}
}
if (result.isEmpty())
{
MavenRepositorySystemSession session = setupRepoSession(system);
session.setIgnoreInvalidArtifactDescriptor(true);
session.setIgnoreMissingArtifactDescriptor(true);
VersionRangeResult versions = getVersions(dep, convertToMavenRepos(repositories));
VERSION: for (Version version : versions.getVersions())
{
ArtifactRepository ar = versions.getRepository(version);
DependencyBuilder currentVersion = DependencyBuilder.create(dep).setVersion(version.toString());
Artifact artifact = dependencyToMavenArtifact(currentVersion);
if (ar instanceof LocalRepository)
{
LocalArtifactRequest request = new LocalArtifactRequest(artifact, null, null);
LocalArtifactResult a = session.getLocalRepositoryManager().find(session, request);
File file = a.getFile();
DependencyResource resource = new DependencyResource(factory, file, currentVersion);
if (!result.contains(resource))
{
result.add(resource);
continue VERSION;
}
}
if (ar instanceof RemoteRepository)
{
ArtifactRequest request = new ArtifactRequest();
RemoteRepository remoteRepo = new RemoteRepository(ar.getId(), ar.getContentType(),
((RemoteRepository) ar).getUrl());
request.addRepository(remoteRepo);
request.setArtifact(artifact);
try
{
ArtifactResult a = system.resolveArtifact(session, request);
File file = a.getArtifact().getFile();
DependencyResource resource = new DependencyResource(factory, file, currentVersion);
if (!result.contains(resource))
{
result.add(resource);
continue VERSION;
}