Search in sources :

Example 16 with RemoteRepository

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

the class AetherGrapeEngineFactory method createRepositories.

private static List<RemoteRepository> createRepositories(List<RepositoryConfiguration> repositoryConfigurations) {
    List<RemoteRepository> repositories = new ArrayList<>(repositoryConfigurations.size());
    for (RepositoryConfiguration repositoryConfiguration : repositoryConfigurations) {
        RemoteRepository.Builder builder = new RemoteRepository.Builder(repositoryConfiguration.getName(), "default", repositoryConfiguration.getUri().toASCIIString());
        if (!repositoryConfiguration.getSnapshotsEnabled()) {
            builder.setSnapshotPolicy(new RepositoryPolicy(false, RepositoryPolicy.UPDATE_POLICY_NEVER, RepositoryPolicy.CHECKSUM_POLICY_IGNORE));
        }
        repositories.add(builder.build());
    }
    return repositories;
}
Also used : RepositoryPolicy(org.eclipse.aether.repository.RepositoryPolicy) ArrayList(java.util.ArrayList) RemoteRepository(org.eclipse.aether.repository.RemoteRepository)

Example 17 with RemoteRepository

use of org.eclipse.aether.repository.RemoteRepository 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 18 with RemoteRepository

use of org.eclipse.aether.repository.RemoteRepository in project intellij-community by JetBrains.

the class Maven3ServerEmbedderImpl method resolve.

private Artifact resolve(@NotNull final Artifact artifact, @NotNull final List<ArtifactRepository> repos) throws ArtifactResolutionException, ArtifactNotFoundException, RemoteException, org.eclipse.aether.resolution.ArtifactResolutionException {
    final String mavenVersion = getMavenVersion();
    // see https://youtrack.jetbrains.com/issue/IDEA-140208 for details
    if (USE_MVN2_COMPATIBLE_DEPENDENCY_RESOLVING || StringUtil.compareVersionNumbers(mavenVersion, "3.2.5") < 0) {
        MavenExecutionRequest request = new DefaultMavenExecutionRequest();
        request.setRemoteRepositories(repos);
        try {
            getComponent(MavenExecutionRequestPopulator.class).populateFromSettings(request, myMavenSettings);
            getComponent(MavenExecutionRequestPopulator.class).populateDefaults(request);
        } catch (MavenExecutionRequestPopulationException e) {
            throw new RuntimeException(e);
        }
        getComponent(ArtifactResolver.class).resolve(artifact, request.getRemoteRepositories(), myLocalRepository);
        return artifact;
    } else {
        final MavenExecutionRequest request = createRequest(null, Collections.<String>emptyList(), Collections.<String>emptyList(), Collections.<String>emptyList());
        for (ArtifactRepository artifactRepository : repos) {
            request.addRemoteRepository(artifactRepository);
        }
        DefaultMaven maven = (DefaultMaven) getComponent(Maven.class);
        RepositorySystemSession repositorySystemSession = maven.newRepositorySession(request);
        final org.eclipse.aether.impl.ArtifactResolver artifactResolver = getComponent(org.eclipse.aether.impl.ArtifactResolver.class);
        final MyLoggerFactory loggerFactory = new MyLoggerFactory();
        if (artifactResolver instanceof DefaultArtifactResolver) {
            ((DefaultArtifactResolver) artifactResolver).setLoggerFactory(loggerFactory);
        }
        final org.eclipse.aether.RepositorySystem repositorySystem = getComponent(org.eclipse.aether.RepositorySystem.class);
        if (repositorySystem instanceof DefaultRepositorySystem) {
            ((DefaultRepositorySystem) repositorySystem).setLoggerFactory(loggerFactory);
        }
        List<RemoteRepository> repositories = RepositoryUtils.toRepos(request.getRemoteRepositories());
        repositories = repositorySystem.newResolutionRepositories(repositorySystemSession, repositories);
        final ArtifactResult artifactResult = repositorySystem.resolveArtifact(repositorySystemSession, new ArtifactRequest(RepositoryUtils.toArtifact(artifact), repositories, null));
        return RepositoryUtils.toArtifact(artifactResult.getArtifact());
    }
}
Also used : RepositorySystemSession(org.eclipse.aether.RepositorySystemSession) DefaultRepositorySystemSession(org.eclipse.aether.DefaultRepositorySystemSession) DefaultRepositorySystem(org.eclipse.aether.internal.impl.DefaultRepositorySystem) ArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository) RemoteRepository(org.eclipse.aether.repository.RemoteRepository) ArtifactResolver(org.apache.maven.artifact.resolver.ArtifactResolver) DefaultArtifactResolver(org.eclipse.aether.internal.impl.DefaultArtifactResolver) ArtifactResult(org.eclipse.aether.resolution.ArtifactResult) ArtifactRequest(org.eclipse.aether.resolution.ArtifactRequest) DefaultArtifactResolver(org.eclipse.aether.internal.impl.DefaultArtifactResolver)

Example 19 with RemoteRepository

use of org.eclipse.aether.repository.RemoteRepository in project bnd by bndtools.

the class BaselineMojo method getRepositories.

private List<RemoteRepository> getRepositories(Artifact artifact) {
    List<RemoteRepository> aetherRepos = RepositoryUtils.toRepos(project.getRemoteArtifactRepositories());
    if (includeDistributionManagement) {
        RemoteRepository releaseDistroRepo;
        if (artifact.isSnapshot()) {
            MavenProject tmpClone = project.clone();
            org.apache.maven.artifact.Artifact tmpArtifact = project.getArtifact();
            tmpClone.setArtifact(tmpArtifact);
            releaseDistroRepo = RepositoryUtils.toRepo(tmpClone.getDistributionManagementArtifactRepository());
        } else {
            releaseDistroRepo = RepositoryUtils.toRepo(project.getDistributionManagementArtifactRepository());
        }
        // Don't fail on projects without distributionManagement
        if (releaseDistroRepo != null) {
            aetherRepos.add(0, releaseDistroRepo);
        }
    }
    return aetherRepos;
}
Also used : MavenProject(org.apache.maven.project.MavenProject) RemoteRepository(org.eclipse.aether.repository.RemoteRepository)

Example 20 with RemoteRepository

use of org.eclipse.aether.repository.RemoteRepository in project bnd by bndtools.

the class DependencyResolver method resolve.

public Map<File, ArtifactResult> resolve() throws MojoExecutionException {
    if (resolvedDependencies != null) {
        return resolvedDependencies;
    }
    DependencyResolutionRequest request = new DefaultDependencyResolutionRequest(project, session);
    request.setResolutionFilter(new DependencyFilter() {

        @Override
        public boolean accept(DependencyNode node, List<DependencyNode> parents) {
            if (node.getDependency() != null) {
                return scopes.contains(node.getDependency().getScope());
            }
            return false;
        }
    });
    DependencyResolutionResult result;
    try {
        result = resolver.resolve(request);
    } catch (DependencyResolutionException e) {
        throw new MojoExecutionException(e.getMessage(), e);
    }
    Map<File, ArtifactResult> dependencies = new HashMap<>();
    DependencyNode dependencyGraph = result.getDependencyGraph();
    if (dependencyGraph != null && !dependencyGraph.getChildren().isEmpty()) {
        List<RemoteRepository> remoteRepositories = new ArrayList<>(project.getRemoteProjectRepositories());
        ArtifactRepository deployRepo = project.getDistributionManagementArtifactRepository();
        if (deployRepo != null) {
            remoteRepositories.add(RepositoryUtils.toRepo(deployRepo));
        }
        discoverArtifacts(dependencies, dependencyGraph.getChildren(), project.getArtifact().getId(), remoteRepositories);
    }
    return resolvedDependencies = dependencies;
}
Also used : DependencyResolutionResult(org.apache.maven.project.DependencyResolutionResult) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) DependencyFilter(org.eclipse.aether.graph.DependencyFilter) RemoteRepository(org.eclipse.aether.repository.RemoteRepository) ArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository) DefaultDependencyResolutionRequest(org.apache.maven.project.DefaultDependencyResolutionRequest) ArtifactResult(org.eclipse.aether.resolution.ArtifactResult) DependencyResolutionRequest(org.apache.maven.project.DependencyResolutionRequest) DefaultDependencyResolutionRequest(org.apache.maven.project.DefaultDependencyResolutionRequest) DependencyNode(org.eclipse.aether.graph.DependencyNode) DependencyResolutionException(org.apache.maven.project.DependencyResolutionException) File(java.io.File)

Aggregations

RemoteRepository (org.eclipse.aether.repository.RemoteRepository)21 DefaultRepositorySystemSession (org.eclipse.aether.DefaultRepositorySystemSession)7 ArtifactResult (org.eclipse.aether.resolution.ArtifactResult)7 File (java.io.File)5 Artifact (org.eclipse.aether.artifact.Artifact)5 DefaultArtifact (org.eclipse.aether.artifact.DefaultArtifact)5 ArtifactRequest (org.eclipse.aether.resolution.ArtifactRequest)5 ArtifactResolutionException (org.eclipse.aether.resolution.ArtifactResolutionException)5 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)4 RepositorySystemSession (org.eclipse.aether.RepositorySystemSession)4 ArrayList (java.util.ArrayList)3 ArtifactRepository (org.apache.maven.artifact.repository.ArtifactRepository)3 RepositorySystem (org.eclipse.aether.RepositorySystem)3 Dependency (org.eclipse.aether.graph.Dependency)3 IOException (java.io.IOException)2 Path (java.nio.file.Path)2 Metadata (org.apache.maven.artifact.repository.metadata.Metadata)2 Versioning (org.apache.maven.artifact.repository.metadata.Versioning)2 DefaultArtifactResolver (org.eclipse.aether.internal.impl.DefaultArtifactResolver)2 DefaultRepositorySystem (org.eclipse.aether.internal.impl.DefaultRepositorySystem)2