use of org.sonatype.aether.repository.RemoteRepository in project sonatype-aether by sonatype.
the class GetDependencyTreeWithMirror method main.
public static void main(String[] args) throws Exception {
System.out.println("------------------------------------------------------------");
System.out.println(GetDependencyTreeWithMirror.class.getSimpleName());
RepositorySystem system = Booter.newRepositorySystem();
RepositorySystemSession session = Booter.newRepositorySystemSession(system);
Artifact artifact = new DefaultArtifact("org.apache.maven:maven-aether-provider:3.0.2");
RemoteRepository central = new RemoteRepository("central", "default", "http://repo1.maven.org/maven2/");
DefaultMirrorSelector dms = (DefaultMirrorSelector) session.getMirrorSelector();
dms.add("mirror", "http://repo1.maven.org/maven2/", "default", true, "central", "*");
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRoot(new Dependency(artifact, ""));
collectRequest.addRepository(central);
CollectResult collectResult = system.collectDependencies(session, collectRequest);
collectResult.getRoot().accept(new ConsoleDependencyGraphDumper());
}
use of org.sonatype.aether.repository.RemoteRepository in project sonatype-aether by sonatype.
the class GetDirectDependencies method main.
public static void main(String[] args) throws Exception {
System.out.println("------------------------------------------------------------");
System.out.println(GetDirectDependencies.class.getSimpleName());
RepositorySystem system = Booter.newRepositorySystem();
RepositorySystemSession session = Booter.newRepositorySystemSession(system);
Artifact artifact = new DefaultArtifact("org.sonatype.aether:aether-impl:1.9");
RemoteRepository repo = Booter.newCentralRepository();
ArtifactDescriptorRequest descriptorRequest = new ArtifactDescriptorRequest();
descriptorRequest.setArtifact(artifact);
descriptorRequest.addRepository(repo);
ArtifactDescriptorResult descriptorResult = system.readArtifactDescriptor(session, descriptorRequest);
for (Dependency dependency : descriptorResult.getDependencies()) {
System.out.println(dependency);
}
}
use of org.sonatype.aether.repository.RemoteRepository in project sonatype-aether by sonatype.
the class ResolveArtifact method main.
public static void main(String[] args) throws Exception {
System.out.println("------------------------------------------------------------");
System.out.println(ResolveArtifact.class.getSimpleName());
RepositorySystem system = Booter.newRepositorySystem();
RepositorySystemSession session = Booter.newRepositorySystemSession(system);
Artifact artifact = new DefaultArtifact("org.sonatype.aether:aether-util:1.9");
RemoteRepository repo = Booter.newCentralRepository();
ArtifactRequest artifactRequest = new ArtifactRequest();
artifactRequest.setArtifact(artifact);
artifactRequest.addRepository(repo);
ArtifactResult artifactResult = system.resolveArtifact(session, artifactRequest);
artifact = artifactResult.getArtifact();
System.out.println(artifact + " resolved to " + artifact.getFile());
}
use of org.sonatype.aether.repository.RemoteRepository in project sonatype-aether by sonatype.
the class Aether method deploy.
public void deploy(Artifact artifact, Artifact pom, String remoteRepository) throws DeploymentException {
RepositorySystemSession session = newSession();
RemoteRepository nexus = new RemoteRepository("nexus", "default", remoteRepository);
Authentication authentication = new Authentication("admin", "admin123");
nexus.setAuthentication(authentication);
DeployRequest deployRequest = new DeployRequest();
deployRequest.addArtifact(artifact).addArtifact(pom);
deployRequest.setRepository(nexus);
repositorySystem.deploy(session, deployRequest);
}
use of org.sonatype.aether.repository.RemoteRepository in project zeppelin by apache.
the class SparkDependencyContext method fetchArtifactWithDep.
private List<ArtifactResult> fetchArtifactWithDep(Dependency dep) throws DependencyResolutionException, ArtifactResolutionException {
Artifact artifact = new DefaultArtifact(SparkDependencyResolver.inferScalaVersion(dep.getGroupArtifactVersion()));
DependencyFilter classpathFlter = DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE);
PatternExclusionsDependencyFilter exclusionFilter = new PatternExclusionsDependencyFilter(SparkDependencyResolver.inferScalaVersion(dep.getExclusions()));
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRoot(new org.sonatype.aether.graph.Dependency(artifact, JavaScopes.COMPILE));
collectRequest.addRepository(mavenCentral);
collectRequest.addRepository(mavenLocal);
for (RemoteRepository repo : additionalRepos) {
collectRequest.addRepository(repo);
}
for (Repository repo : repositories) {
RemoteRepository rr = new RemoteRepository(repo.getId(), "default", repo.getUrl());
rr.setPolicy(repo.isSnapshot(), null);
Authentication auth = repo.getAuthentication();
if (auth != null) {
rr.setAuthentication(auth);
}
collectRequest.addRepository(rr);
}
DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, DependencyFilterUtils.andFilter(exclusionFilter, classpathFlter));
return system.resolveDependencies(session, dependencyRequest).getArtifactResults();
}
Aggregations