Search in sources :

Example 1 with RepositoryPolicy

use of org.eclipse.aether.repository.RepositoryPolicy in project fabric8 by jboss-fuse.

the class AetherBasedResolver method addRepo.

private void addRepo(List<RemoteRepository> list, MavenRepositoryURL repo) {
    String releasesUpdatePolicy = repo.getReleasesUpdatePolicy();
    if (releasesUpdatePolicy == null || releasesUpdatePolicy.isEmpty()) {
        releasesUpdatePolicy = new RepositoryPolicy().getUpdatePolicy();
    }
    String releasesChecksumPolicy = repo.getReleasesChecksumPolicy();
    if (releasesChecksumPolicy == null || releasesChecksumPolicy.isEmpty()) {
        releasesChecksumPolicy = new RepositoryPolicy().getChecksumPolicy();
    }
    String snapshotsUpdatePolicy = repo.getSnapshotsUpdatePolicy();
    if (snapshotsUpdatePolicy == null || snapshotsUpdatePolicy.isEmpty()) {
        snapshotsUpdatePolicy = new RepositoryPolicy().getUpdatePolicy();
    }
    String snapshotsChecksumPolicy = repo.getSnapshotsChecksumPolicy();
    if (snapshotsChecksumPolicy == null || snapshotsChecksumPolicy.isEmpty()) {
        snapshotsChecksumPolicy = new RepositoryPolicy().getChecksumPolicy();
    }
    RemoteRepository.Builder builder = new RemoteRepository.Builder(repo.getId(), REPO_TYPE, repo.getURL().toExternalForm());
    RepositoryPolicy releasePolicy = new RepositoryPolicy(repo.isReleasesEnabled(), releasesUpdatePolicy, releasesChecksumPolicy);
    builder.setReleasePolicy(releasePolicy);
    RepositoryPolicy snapshotPolicy = new RepositoryPolicy(repo.isSnapshotsEnabled(), snapshotsUpdatePolicy, snapshotsChecksumPolicy);
    builder.setSnapshotPolicy(snapshotPolicy);
    Authentication authentication = getAuthentication(repo.getId());
    if (authentication != null) {
        builder.setAuthentication(authentication);
    }
    list.add(builder.build());
}
Also used : RepositoryPolicy(org.eclipse.aether.repository.RepositoryPolicy) Authentication(org.eclipse.aether.repository.Authentication) AuthenticationBuilder(org.eclipse.aether.util.repository.AuthenticationBuilder) RemoteRepository(org.eclipse.aether.repository.RemoteRepository)

Example 2 with RepositoryPolicy

use of org.eclipse.aether.repository.RepositoryPolicy in project wildfly-swarm by wildfly-swarm.

the class MavenArtifactResolvingHelperTest method propagateRepositoryPolicies.

@Test
public // SWARM-1173: swarm-plugin trying to download SNAPSHOTs from Maven Central
void propagateRepositoryPolicies() {
    RepositorySystemSession sessionMock = Mockito.mock(RepositorySystemSession.class);
    MirrorSelector mirrorSelectorMock = Mockito.mock(MirrorSelector.class);
    Mockito.when(sessionMock.getMirrorSelector()).thenReturn(mirrorSelectorMock);
    ProxySelector proxySelectorMock = Mockito.mock(ProxySelector.class);
    Mockito.when(sessionMock.getProxySelector()).thenReturn(proxySelectorMock);
    MavenArtifactResolvingHelper artifactResolverHelper = new MavenArtifactResolvingHelper(null, null, sessionMock, null);
    ArtifactRepositoryPolicy testSnapshotPolicy = new ArtifactRepositoryPolicy(false, "hourly", "warn");
    ArtifactRepositoryPolicy testReleasesPolicy = new ArtifactRepositoryPolicy(true, "never", "warn");
    ArtifactRepository testingRepo = new MavenArtifactRepository("testing-repo", "http://testing-repo.org", new DefaultRepositoryLayout(), testSnapshotPolicy, testReleasesPolicy);
    artifactResolverHelper.remoteRepository(testingRepo);
    List<RemoteRepository> remoteRepos = artifactResolverHelper.getRemoteRepositories();
    Assert.assertTrue("Remote repositories " + remoteRepos + " do not contain expected testing repo " + testingRepo, remoteRepos.stream().anyMatch(remoteRepo -> {
        RepositoryPolicy snapshotsPolicy = remoteRepo.getPolicy(true);
        RepositoryPolicy releasesPolicy = remoteRepo.getPolicy(false);
        return remoteRepo.getId().equals(testingRepo.getId()) && !snapshotsPolicy.isEnabled() && snapshotsPolicy.getUpdatePolicy().equals(testSnapshotPolicy.getUpdatePolicy()) && snapshotsPolicy.getChecksumPolicy().equals(testSnapshotPolicy.getChecksumPolicy()) && releasesPolicy.isEnabled() && releasesPolicy.getUpdatePolicy().equals(testReleasesPolicy.getUpdatePolicy()) && releasesPolicy.getChecksumPolicy().equals(testReleasesPolicy.getChecksumPolicy());
    }));
}
Also used : ProxySelector(org.eclipse.aether.repository.ProxySelector) RepositoryPolicy(org.eclipse.aether.repository.RepositoryPolicy) DefaultRepositoryLayout(org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout) ProxySelector(org.eclipse.aether.repository.ProxySelector) Test(org.junit.Test) RepositorySystemSession(org.eclipse.aether.RepositorySystemSession) ArtifactRepositoryPolicy(org.apache.maven.artifact.repository.ArtifactRepositoryPolicy) RemoteRepository(org.eclipse.aether.repository.RemoteRepository) Mockito(org.mockito.Mockito) List(java.util.List) MirrorSelector(org.eclipse.aether.repository.MirrorSelector) ArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository) Assert(org.junit.Assert) MavenArtifactRepository(org.apache.maven.artifact.repository.MavenArtifactRepository) RepositorySystemSession(org.eclipse.aether.RepositorySystemSession) MirrorSelector(org.eclipse.aether.repository.MirrorSelector) ArtifactRepositoryPolicy(org.apache.maven.artifact.repository.ArtifactRepositoryPolicy) RepositoryPolicy(org.eclipse.aether.repository.RepositoryPolicy) ArtifactRepositoryPolicy(org.apache.maven.artifact.repository.ArtifactRepositoryPolicy) DefaultRepositoryLayout(org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout) MavenArtifactRepository(org.apache.maven.artifact.repository.MavenArtifactRepository) ArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository) MavenArtifactRepository(org.apache.maven.artifact.repository.MavenArtifactRepository) RemoteRepository(org.eclipse.aether.repository.RemoteRepository) Test(org.junit.Test)

Example 3 with RepositoryPolicy

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

the class MavenResolverGrapeEngineFactory 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 4 with RepositoryPolicy

use of org.eclipse.aether.repository.RepositoryPolicy in project zeppelin by apache.

the class AbstractDependencyResolver method addRepo.

public void addRepo(String id, String url, boolean snapshot) {
    synchronized (repos) {
        delRepo(id);
        RepositoryPolicy policy = new RepositoryPolicy(true, RepositoryPolicy.UPDATE_POLICY_DAILY, RepositoryPolicy.CHECKSUM_POLICY_WARN);
        RemoteRepository.Builder rr = new RemoteRepository.Builder(id, "default", url);
        if (snapshot) {
            rr.setSnapshotPolicy(policy);
        } else {
            rr.setPolicy(policy);
        }
        if (proxy != null) {
            rr.setProxy(proxy);
        }
        repos.add(rr.build());
    }
}
Also used : RepositoryPolicy(org.eclipse.aether.repository.RepositoryPolicy) AuthenticationBuilder(org.eclipse.aether.util.repository.AuthenticationBuilder) RemoteRepository(org.eclipse.aether.repository.RemoteRepository)

Example 5 with RepositoryPolicy

use of org.eclipse.aether.repository.RepositoryPolicy in project zeppelin by apache.

the class AbstractDependencyResolver method addRepo.

public void addRepo(String id, String url, boolean snapshot, Authentication auth, Proxy proxy) {
    synchronized (repos) {
        delRepo(id);
        RepositoryPolicy policy = new RepositoryPolicy(true, RepositoryPolicy.UPDATE_POLICY_DAILY, RepositoryPolicy.CHECKSUM_POLICY_WARN);
        RemoteRepository.Builder rr = new RemoteRepository.Builder(id, "default", url).setAuthentication(auth).setProxy(proxy);
        if (snapshot) {
            rr.setSnapshotPolicy(policy);
        } else {
            rr.setPolicy(policy);
        }
        repos.add(rr.build());
    }
}
Also used : RepositoryPolicy(org.eclipse.aether.repository.RepositoryPolicy) AuthenticationBuilder(org.eclipse.aether.util.repository.AuthenticationBuilder) RemoteRepository(org.eclipse.aether.repository.RemoteRepository)

Aggregations

RepositoryPolicy (org.eclipse.aether.repository.RepositoryPolicy)12 RemoteRepository (org.eclipse.aether.repository.RemoteRepository)11 AuthenticationBuilder (org.eclipse.aether.util.repository.AuthenticationBuilder)6 Authentication (org.eclipse.aether.repository.Authentication)4 Field (java.lang.reflect.Field)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 ArtifactRepositoryPolicy (org.apache.maven.artifact.repository.ArtifactRepositoryPolicy)2 Proxy (org.eclipse.aether.repository.Proxy)2 Test (org.junit.Test)2 HashMap (java.util.HashMap)1 Properties (java.util.Properties)1 ArtifactRepository (org.apache.maven.artifact.repository.ArtifactRepository)1 MavenArtifactRepository (org.apache.maven.artifact.repository.MavenArtifactRepository)1 DefaultRepositoryLayout (org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout)1 DeploymentRepository (org.apache.maven.model.DeploymentRepository)1 DistributionManagement (org.apache.maven.model.DistributionManagement)1 MavenProject (org.apache.maven.project.MavenProject)1 Server (org.apache.maven.settings.Server)1 RepositorySystemSession (org.eclipse.aether.RepositorySystemSession)1