Search in sources :

Example 1 with ProxySelector

use of org.eclipse.aether.repository.ProxySelector in project spring-cloud-function by spring-cloud.

the class DependencyResolutionModule method createSession.

private DefaultRepositorySystemSession createSession(Properties properties) throws NoLocalRepositoryManagerException {
    DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
    LocalRepository repository = localRepository(properties);
    session.setLocalRepositoryManager(localRepositoryManagerFactory.newInstance(session, repository));
    applySettings(session);
    ProxySelector existing = session.getProxySelector();
    if (existing == null || !(existing instanceof CompositeProxySelector)) {
        JreProxySelector fallback = new JreProxySelector();
        ProxySelector selector = existing == null ? fallback : new CompositeProxySelector(Arrays.asList(existing, fallback));
        session.setProxySelector(selector);
    }
    return session;
}
Also used : JreProxySelector(org.eclipse.aether.util.repository.JreProxySelector) ProxySelector(org.eclipse.aether.repository.ProxySelector) DefaultRepositorySystemSession(org.eclipse.aether.DefaultRepositorySystemSession) LocalRepository(org.eclipse.aether.repository.LocalRepository) JreProxySelector(org.eclipse.aether.util.repository.JreProxySelector)

Example 2 with ProxySelector

use of org.eclipse.aether.repository.ProxySelector 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 ProxySelector

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

the class DefaultRepositorySystemSessionAutoConfiguration method apply.

@Override
public void apply(DefaultRepositorySystemSession session, RepositorySystem repositorySystem) {
    if (session.getLocalRepositoryManager() == null) {
        LocalRepository localRepository = new LocalRepository(getM2RepoDirectory());
        LocalRepositoryManager localRepositoryManager = repositorySystem.newLocalRepositoryManager(session, localRepository);
        session.setLocalRepositoryManager(localRepositoryManager);
    }
    ProxySelector existing = session.getProxySelector();
    if (!(existing instanceof CompositeProxySelector)) {
        JreProxySelector fallback = new JreProxySelector();
        ProxySelector selector = (existing != null) ? new CompositeProxySelector(Arrays.asList(existing, fallback)) : fallback;
        session.setProxySelector(selector);
    }
}
Also used : ProxySelector(org.eclipse.aether.repository.ProxySelector) JreProxySelector(org.eclipse.aether.util.repository.JreProxySelector) LocalRepositoryManager(org.eclipse.aether.repository.LocalRepositoryManager) LocalRepository(org.eclipse.aether.repository.LocalRepository) JreProxySelector(org.eclipse.aether.util.repository.JreProxySelector)

Aggregations

ProxySelector (org.eclipse.aether.repository.ProxySelector)3 LocalRepository (org.eclipse.aether.repository.LocalRepository)2 JreProxySelector (org.eclipse.aether.util.repository.JreProxySelector)2 List (java.util.List)1 ArtifactRepository (org.apache.maven.artifact.repository.ArtifactRepository)1 ArtifactRepositoryPolicy (org.apache.maven.artifact.repository.ArtifactRepositoryPolicy)1 MavenArtifactRepository (org.apache.maven.artifact.repository.MavenArtifactRepository)1 DefaultRepositoryLayout (org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout)1 DefaultRepositorySystemSession (org.eclipse.aether.DefaultRepositorySystemSession)1 RepositorySystemSession (org.eclipse.aether.RepositorySystemSession)1 LocalRepositoryManager (org.eclipse.aether.repository.LocalRepositoryManager)1 MirrorSelector (org.eclipse.aether.repository.MirrorSelector)1 RemoteRepository (org.eclipse.aether.repository.RemoteRepository)1 RepositoryPolicy (org.eclipse.aether.repository.RepositoryPolicy)1 Assert (org.junit.Assert)1 Test (org.junit.Test)1 Mockito (org.mockito.Mockito)1