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;
}
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());
}));
}
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);
}
}
Aggregations