use of org.eclipse.aether.RepositorySystemSession in project druid by druid-io.
the class PullDependencies method createTeslaAether.
private DefaultTeslaAether createTeslaAether(List<Repository> remoteRepositories) {
if (!useProxy) {
return new DefaultTeslaAether(localRepository, remoteRepositories.toArray(new Repository[0]));
}
if (!StringUtils.toLowerCase(proxyType).equals(Proxy.TYPE_HTTP) && !StringUtils.toLowerCase(proxyType).equals(Proxy.TYPE_HTTPS)) {
throw new IllegalArgumentException("invalid proxy type: " + proxyType);
}
RepositorySystemSession repositorySystemSession = new RepositorySystemSessionProvider(new File(localRepository)).get();
List<RemoteRepository> rl = remoteRepositories.stream().map(r -> {
RemoteRepository.Builder builder = new RemoteRepository.Builder(r.getId(), "default", r.getUrl());
if (r.getUsername() != null && r.getPassword() != null) {
Authentication auth = new AuthenticationBuilder().addUsername(r.getUsername()).addPassword(r.getPassword()).build();
builder.setAuthentication(auth);
}
final Authentication proxyAuth;
if (Strings.isNullOrEmpty(proxyUsername)) {
proxyAuth = null;
} else {
proxyAuth = new AuthenticationBuilder().addUsername(proxyUsername).addPassword(proxyPassword).build();
}
builder.setProxy(new Proxy(proxyType, proxyHost, proxyPort, proxyAuth));
return builder.build();
}).collect(Collectors.toList());
return new DefaultTeslaAether(rl, repositorySystemSession);
}
use of org.eclipse.aether.RepositorySystemSession in project BIMserver by opensourceBIM.
the class RemotePluginRepository method main.
public static void main(String[] args) throws ArtifactResolutionException {
System.out.println("------------------------------------------------------------");
System.out.println(RemotePluginRepository.class.getSimpleName());
RepositorySystem system = newRepositorySystem();
RepositorySystemSession session = newRepositorySystemSession(system);
Artifact artifact = new DefaultArtifact("org.eclipse.aether:aether-util:1.0.0.v20140518");
ArtifactRequest artifactRequest = new ArtifactRequest();
artifactRequest.setArtifact(artifact);
artifactRequest.setRepositories(newRepositories(system, session));
ArtifactResult artifactResult = system.resolveArtifact(session, artifactRequest);
artifact = artifactResult.getArtifact();
System.out.println(artifact + " resolved to " + artifact.getFile());
}
use of org.eclipse.aether.RepositorySystemSession in project karaf by apache.
the class DependencyHelperFactory method createDependencyHelper.
/**
* Create a new {@link DependencyHelper} based on what has been found in
* {@link org.codehaus.plexus.PlexusContainer}.
*
* @param container The Maven Plexus container to use.
* @param mavenProject The Maven project to use.
* @param mavenSession The Maven session.
* @param cacheSize Size of the artifact/file LRU cache
* @param log The log to use for the messages.
*
* @return The {@link DependencyHelper} depending of the Maven version used.
*
* @throws MojoExecutionException If the plugin execution fails.
*/
public static DependencyHelper createDependencyHelper(PlexusContainer container, MavenProject mavenProject, MavenSession mavenSession, int cacheSize, Log log) throws MojoExecutionException {
try {
final RepositorySystem system = container.lookup(RepositorySystem.class);
final RepositorySystemSession session = mavenSession.getRepositorySession();
final List<RemoteRepository> repositories = mavenProject.getRemoteProjectRepositories();
return new Dependency31Helper(repositories, session, system, cacheSize);
} catch (ComponentLookupException e) {
throw new MojoExecutionException(e.getMessage(), e);
}
}
Aggregations