use of org.sonatype.aether.repository.RemoteRepository in project zeppelin by apache.
the class SparkDependencyResolver method getArtifactsWithDep.
/**
* @param dependency
* @param excludes list of pattern can either be of the form groupId:artifactId
* @return
* @throws Exception
*/
@Override
public List<ArtifactResult> getArtifactsWithDep(String dependency, Collection<String> excludes) throws Exception {
Artifact artifact = new DefaultArtifact(inferScalaVersion(dependency));
DependencyFilter classpathFilter = DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE);
PatternExclusionsDependencyFilter exclusionFilter = new PatternExclusionsDependencyFilter(inferScalaVersion(excludes));
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRoot(new Dependency(artifact, JavaScopes.COMPILE));
synchronized (repos) {
for (RemoteRepository repo : repos) {
collectRequest.addRepository(repo);
}
}
DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, DependencyFilterUtils.andFilter(exclusionFilter, classpathFilter));
return system.resolveDependencies(session, dependencyRequest).getArtifactResults();
}
use of org.sonatype.aether.repository.RemoteRepository in project storm by apache.
the class DependencyResolverMain method main.
public static void main(String[] args) {
if (args.length < 1) {
throw new IllegalArgumentException("artifacts must be presented.");
}
String artifactsArg = args[0];
// DO NOT CHANGE THIS TO SYSOUT
System.err.println("DependencyResolver input - artifacts: " + artifactsArg);
List<Dependency> dependencies = parseArtifactArgs(artifactsArg);
List<RemoteRepository> repositories;
if (args.length > 1) {
String remoteRepositoryArg = args[1];
// DO NOT CHANGE THIS TO SYSOUT
System.err.println("DependencyResolver input - repositories: " + remoteRepositoryArg);
repositories = parseRemoteRepositoryArgs(remoteRepositoryArg);
} else {
repositories = Collections.emptyList();
}
try {
String localMavenRepoPath = getOrDefaultLocalMavenRepositoryPath("local-repo");
DependencyResolver resolver = new DependencyResolver(localMavenRepoPath, repositories);
List<ArtifactResult> artifactResults = resolver.resolve(dependencies);
Iterable<ArtifactResult> missingArtifacts = filterMissingArtifacts(artifactResults);
if (missingArtifacts.iterator().hasNext()) {
printMissingArtifactsToSysErr(missingArtifacts);
throw new RuntimeException("Some artifacts are not resolved");
}
System.out.println(JSONValue.toJSONString(transformArtifactResultToArtifactToPaths(artifactResults)));
System.out.flush();
} catch (Throwable e) {
throw new RuntimeException(e);
}
}
use of org.sonatype.aether.repository.RemoteRepository in project sonatype-aether by sonatype.
the class DefaultMirrorSelector method getMirror.
public RemoteRepository getMirror(RemoteRepository repository) {
MirrorDef mirror = findMirror(repository);
if (mirror == null) {
return null;
}
RemoteRepository repo = new RemoteRepository();
repo.setRepositoryManager(mirror.repositoryManager);
repo.setId(mirror.id);
repo.setUrl(mirror.url);
if (mirror.type != null && mirror.type.length() > 0) {
repo.setContentType(mirror.type);
} else {
repo.setContentType(repository.getContentType());
}
repo.setPolicy(true, repository.getPolicy(true));
repo.setPolicy(false, repository.getPolicy(false));
repo.setMirroredRepositories(Collections.singletonList(repository));
return repo;
}
use of org.sonatype.aether.repository.RemoteRepository in project sonatype-aether by sonatype.
the class DefaultRepositorySystemSessionTest method testDefaultAuthenticationSelectorUsesExistingAuth.
@Test
public void testDefaultAuthenticationSelectorUsesExistingAuth() {
DefaultRepositorySystemSession session = new DefaultRepositorySystemSession();
RemoteRepository repo = new RemoteRepository("id", "default", "void");
assertSame(null, session.getAuthenticationSelector().getAuthentication(repo));
repo.setAuthentication(new Authentication("user", "pass"));
assertSame(repo.getAuthentication(), session.getAuthenticationSelector().getAuthentication(repo));
}
use of org.sonatype.aether.repository.RemoteRepository in project sonatype-aether by sonatype.
the class DefaultRemoteRepositoryManager method aggregateRepositories.
public List<RemoteRepository> aggregateRepositories(RepositorySystemSession session, List<RemoteRepository> dominantRepositories, List<RemoteRepository> recessiveRepositories, boolean recessiveIsRaw) {
if (recessiveRepositories.isEmpty()) {
return dominantRepositories;
}
MirrorSelector mirrorSelector = session.getMirrorSelector();
AuthenticationSelector authSelector = session.getAuthenticationSelector();
ProxySelector proxySelector = session.getProxySelector();
List<RemoteRepository> result = new ArrayList<RemoteRepository>(dominantRepositories);
next: for (RemoteRepository recessiveRepository : recessiveRepositories) {
RemoteRepository repository = recessiveRepository;
if (recessiveIsRaw) {
RemoteRepository mirrorRepository = mirrorSelector.getMirror(recessiveRepository);
if (mirrorRepository == null) {
repository = recessiveRepository;
} else {
logger.debug("Using mirror " + mirrorRepository.getId() + " (" + mirrorRepository.getUrl() + ") for " + recessiveRepository.getId() + " (" + recessiveRepository.getUrl() + ").");
repository = mirrorRepository;
}
}
String key = getKey(repository);
for (ListIterator<RemoteRepository> it = result.listIterator(); it.hasNext(); ) {
RemoteRepository dominantRepository = it.next();
if (key.equals(getKey(dominantRepository))) {
if (!dominantRepository.getMirroredRepositories().isEmpty() && !repository.getMirroredRepositories().isEmpty()) {
RemoteRepository mergedRepository = mergeMirrors(session, dominantRepository, repository);
if (mergedRepository != dominantRepository) {
it.set(mergedRepository);
}
}
continue next;
}
}
if (recessiveIsRaw) {
Authentication auth = authSelector.getAuthentication(repository);
if (auth != null) {
repository.setAuthentication(auth);
}
Proxy proxy = proxySelector.getProxy(repository);
if (proxy != null) {
repository.setProxy(proxy);
}
}
result.add(repository);
}
return result;
}
Aggregations