Search in sources :

Example 16 with RepositorySystem

use of org.eclipse.aether.RepositorySystem in project camel by apache.

the class BOMResolver method retrieveUpstreamBOMVersions.

private void retrieveUpstreamBOMVersions() throws Exception {
    RepositorySystem system = newRepositorySystem();
    DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
    LocalRepository localRepo = new LocalRepository(LOCAL_REPO);
    session.setLocalRepositoryManager(system.newLocalRepositoryManager(session, localRepo));
    String camelVersion = DependencyResolver.resolveCamelParentProperty("${project.version}");
    List<Artifact> neededArtifacts = new LinkedList<>();
    neededArtifacts.add(new DefaultArtifact("org.apache.camel:camel:pom:" + camelVersion).setFile(camelRoot("pom.xml")));
    neededArtifacts.add(new DefaultArtifact("org.apache.camel:camel-parent:pom:" + camelVersion).setFile(camelRoot("parent/pom.xml")));
    neededArtifacts.add(new DefaultArtifact("org.apache.camel:spring-boot:pom:" + camelVersion).setFile(camelRoot("platforms/spring-boot/pom.xml")));
    neededArtifacts.add(new DefaultArtifact("org.apache.camel:camel-spring-boot-dm:pom:" + camelVersion).setFile(camelRoot("platforms/spring-boot/spring-boot-dm/pom.xml")));
    neededArtifacts.add(new DefaultArtifact("org.apache.camel:camel-spring-boot-dependencies:pom:" + camelVersion).setFile(camelRoot("platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml")));
    Artifact camelSpringBootParent = new DefaultArtifact("org.apache.camel:camel-starter-parent:pom:" + camelVersion).setFile(camelRoot("platforms/spring-boot/spring-boot-dm/camel-starter-parent/pom.xml"));
    neededArtifacts.add(camelSpringBootParent);
    RemoteRepository localRepoDist = new RemoteRepository.Builder("org.apache.camel.itest.springboot", "default", new File(LOCAL_REPO).toURI().toString()).build();
    for (Artifact artifact : neededArtifacts) {
        DeployRequest deployRequest = new DeployRequest();
        deployRequest.addArtifact(artifact);
        deployRequest.setRepository(localRepoDist);
        system.deploy(session, deployRequest);
    }
    RemoteRepository mavenCentral = new RemoteRepository.Builder("central", "default", "http://repo1.maven.org/maven2/").build();
    ArtifactDescriptorRequest dReq = new ArtifactDescriptorRequest(camelSpringBootParent, Arrays.asList(localRepoDist, mavenCentral), null);
    ArtifactDescriptorResult dRes = system.readArtifactDescriptor(session, dReq);
    this.versions = new TreeMap<>();
    for (Dependency dependency : dRes.getManagedDependencies()) {
        Artifact a = dependency.getArtifact();
        String key = a.getGroupId() + ":" + a.getArtifactId();
        versions.put(key, dependency.getArtifact().getVersion());
    }
}
Also used : DeployRequest(org.eclipse.aether.deployment.DeployRequest) LocalRepository(org.eclipse.aether.repository.LocalRepository) RemoteRepository(org.eclipse.aether.repository.RemoteRepository) Dependency(org.eclipse.aether.graph.Dependency) LinkedList(java.util.LinkedList) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact) Artifact(org.eclipse.aether.artifact.Artifact) RepositorySystem(org.eclipse.aether.RepositorySystem) DefaultRepositorySystemSession(org.eclipse.aether.DefaultRepositorySystemSession) File(java.io.File) ArtifactDescriptorResult(org.eclipse.aether.resolution.ArtifactDescriptorResult) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact) ArtifactDescriptorRequest(org.eclipse.aether.resolution.ArtifactDescriptorRequest)

Example 17 with RepositorySystem

use of org.eclipse.aether.RepositorySystem in project spring-boot by spring-projects.

the class AetherGrapeEngineFactory method create.

public static AetherGrapeEngine create(GroovyClassLoader classLoader, List<RepositoryConfiguration> repositoryConfigurations, DependencyResolutionContext dependencyResolutionContext) {
    RepositorySystem repositorySystem = createServiceLocator().getService(RepositorySystem.class);
    DefaultRepositorySystemSession repositorySystemSession = MavenRepositorySystemUtils.newSession();
    ServiceLoader<RepositorySystemSessionAutoConfiguration> autoConfigurations = ServiceLoader.load(RepositorySystemSessionAutoConfiguration.class);
    for (RepositorySystemSessionAutoConfiguration autoConfiguration : autoConfigurations) {
        autoConfiguration.apply(repositorySystemSession, repositorySystem);
    }
    new DefaultRepositorySystemSessionAutoConfiguration().apply(repositorySystemSession, repositorySystem);
    return new AetherGrapeEngine(classLoader, repositorySystem, repositorySystemSession, createRepositories(repositoryConfigurations), dependencyResolutionContext);
}
Also used : DefaultRepositorySystem(org.eclipse.aether.internal.impl.DefaultRepositorySystem) RepositorySystem(org.eclipse.aether.RepositorySystem) DefaultRepositorySystemSession(org.eclipse.aether.DefaultRepositorySystemSession)

Example 18 with RepositorySystem

use of org.eclipse.aether.RepositorySystem in project pinpoint by naver.

the class DependencyResolver method get.

public static DependencyResolver get(String... repositoryUrls) {
    RepositorySystem system = newRepositorySystem();
    RepositorySystemSession session = newRepositorySystemSession(system);
    List<RemoteRepository> repositories = newRepositories(repositoryUrls);
    return new DependencyResolver(system, session, repositories);
}
Also used : RepositorySystem(org.eclipse.aether.RepositorySystem) RepositorySystemSession(org.eclipse.aether.RepositorySystemSession) DefaultRepositorySystemSession(org.eclipse.aether.DefaultRepositorySystemSession) RemoteRepository(org.eclipse.aether.repository.RemoteRepository)

Example 19 with RepositorySystem

use of org.eclipse.aether.RepositorySystem 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());
}
Also used : RepositorySystem(org.eclipse.aether.RepositorySystem) RepositorySystemSession(org.eclipse.aether.RepositorySystemSession) DefaultRepositorySystemSession(org.eclipse.aether.DefaultRepositorySystemSession) ArtifactRequest(org.eclipse.aether.resolution.ArtifactRequest) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact) Artifact(org.eclipse.aether.artifact.Artifact) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact) ArtifactResult(org.eclipse.aether.resolution.ArtifactResult)

Example 20 with RepositorySystem

use of org.eclipse.aether.RepositorySystem 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);
    }
}
Also used : RepositorySystem(org.eclipse.aether.RepositorySystem) RepositorySystemSession(org.eclipse.aether.RepositorySystemSession) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) RemoteRepository(org.eclipse.aether.repository.RemoteRepository) ComponentLookupException(org.codehaus.plexus.component.repository.exception.ComponentLookupException)

Aggregations

RepositorySystem (org.eclipse.aether.RepositorySystem)27 DefaultRepositorySystemSession (org.eclipse.aether.DefaultRepositorySystemSession)18 RepositorySystemSession (org.eclipse.aether.RepositorySystemSession)12 RemoteRepository (org.eclipse.aether.repository.RemoteRepository)9 Artifact (org.eclipse.aether.artifact.Artifact)8 DefaultArtifact (org.eclipse.aether.artifact.DefaultArtifact)8 ArtifactResult (org.eclipse.aether.resolution.ArtifactResult)7 DefaultServiceLocator (org.eclipse.aether.impl.DefaultServiceLocator)6 File (java.io.File)5 ArrayList (java.util.ArrayList)5 LocalRepository (org.eclipse.aether.repository.LocalRepository)5 ArtifactRequest (org.eclipse.aether.resolution.ArtifactRequest)4 IOException (java.io.IOException)3 CollectRequest (org.eclipse.aether.collection.CollectRequest)3 Dependency (org.eclipse.aether.graph.Dependency)3 ArtifactResolutionException (org.eclipse.aether.resolution.ArtifactResolutionException)3 DependencyRequest (org.eclipse.aether.resolution.DependencyRequest)3 URL (java.net.URL)2 Path (java.nio.file.Path)2 List (java.util.List)2