use of org.eclipse.aether.repository.RepositoryPolicy in project drools by kiegroup.
the class MavenRepository method getRemoteRepositoryFromDistributionManagement.
protected RemoteRepository getRemoteRepositoryFromDistributionManagement(File pomfile) {
MavenProject mavenProject = parseMavenPom(pomfile);
DistributionManagement distMan = mavenProject.getDistributionManagement();
if (distMan == null) {
return null;
}
DeploymentRepository deployRepo = distMan.getSnapshotRepository() != null && mavenProject.getVersion().endsWith("SNAPSHOT") ? distMan.getSnapshotRepository() : distMan.getRepository();
if (deployRepo == null) {
return null;
}
RemoteRepository.Builder remoteRepoBuilder = new RemoteRepository.Builder(deployRepo.getId(), deployRepo.getLayout(), deployRepo.getUrl()).setSnapshotPolicy(new RepositoryPolicy(true, RepositoryPolicy.UPDATE_POLICY_DAILY, RepositoryPolicy.CHECKSUM_POLICY_WARN)).setReleasePolicy(new RepositoryPolicy(true, RepositoryPolicy.UPDATE_POLICY_ALWAYS, RepositoryPolicy.CHECKSUM_POLICY_WARN));
Server server = MavenSettings.getSettings().getServer(deployRepo.getId());
if (server != null) {
MavenEmbedder embedder = MavenProjectLoader.newMavenEmbedder(false);
try {
Authentication authentication = embedder.getMavenSession().getRepositorySession().getAuthenticationSelector().getAuthentication(remoteRepoBuilder.build());
remoteRepoBuilder.setAuthentication(authentication);
} finally {
embedder.dispose();
}
}
return remoteRepoBuilder.build();
}
use of org.eclipse.aether.repository.RepositoryPolicy in project buck by facebook.
the class AetherUtil method toRemoteRepository.
public static RemoteRepository toRemoteRepository(String repoUrl, Optional<String> username, Optional<String> password) {
RemoteRepository.Builder repo = new RemoteRepository.Builder(null, "default", repoUrl).setPolicy(new RepositoryPolicy(true, null, CHECKSUM_POLICY_FAIL));
if (username.isPresent() && password.isPresent()) {
Authentication authentication = new AuthenticationBuilder().addUsername(username.get()).addPassword(password.get()).build();
repo.setAuthentication(authentication);
}
return repo.build();
}
use of org.eclipse.aether.repository.RepositoryPolicy 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;
}
use of org.eclipse.aether.repository.RepositoryPolicy in project spring-cloud-deployer by spring-cloud.
the class MavenResourceTests method checkRepositoryPolicies.
@Test
public void checkRepositoryPolicies() {
MavenProperties mavenProperties = new MavenProperties();
Map<String, MavenProperties.RemoteRepository> remoteRepositoryMap = new HashMap<>();
MavenProperties.RemoteRepository remoteRepo1 = new MavenProperties.RemoteRepository("https://repo.spring.io/libs-snapshot-local");
MavenProperties.RemoteRepository.RepositoryPolicy snapshotPolicy = new MavenProperties.RemoteRepository.RepositoryPolicy();
snapshotPolicy.setEnabled(true);
snapshotPolicy.setUpdatePolicy("always");
snapshotPolicy.setChecksumPolicy("warn");
remoteRepo1.setSnapshotPolicy(snapshotPolicy);
MavenProperties.RemoteRepository.RepositoryPolicy releasePolicy = new MavenProperties.RemoteRepository.RepositoryPolicy();
releasePolicy.setEnabled(true);
releasePolicy.setUpdatePolicy("interval");
releasePolicy.setChecksumPolicy("ignore");
remoteRepo1.setReleasePolicy(releasePolicy);
remoteRepositoryMap.put("repo1", remoteRepo1);
MavenProperties.RemoteRepository remoteRepo2 = new MavenProperties.RemoteRepository("https://repo.spring.io/libs-milestone-local");
MavenProperties.RemoteRepository.RepositoryPolicy policy = new MavenProperties.RemoteRepository.RepositoryPolicy();
policy.setEnabled(true);
policy.setUpdatePolicy("daily");
policy.setChecksumPolicy("fail");
remoteRepo2.setPolicy(policy);
remoteRepositoryMap.put("repo2", remoteRepo2);
mavenProperties.setRemoteRepositories(remoteRepositoryMap);
MavenArtifactResolver artifactResolver = new MavenArtifactResolver(mavenProperties);
Field remoteRepositories = ReflectionUtils.findField(MavenArtifactResolver.class, "remoteRepositories");
ReflectionUtils.makeAccessible(remoteRepositories);
List<RemoteRepository> remoteRepositoryList = (List<RemoteRepository>) ReflectionUtils.getField(remoteRepositories, artifactResolver);
for (RemoteRepository remoteRepository : remoteRepositoryList) {
assertEquals(2, remoteRepositoryList.size());
assertEquals(true, remoteRepositoryList.get(0).getId().equals("repo1") || remoteRepositoryList.get(0).getId().equals("repo2"));
assertEquals(true, remoteRepositoryList.get(1).getId().equals("repo2") || remoteRepositoryList.get(1).getId().equals("repo1"));
if (remoteRepository.getId().equals("repo1")) {
RepositoryPolicy snapshotPolicy1 = remoteRepository.getPolicy(true);
assertEquals(true, snapshotPolicy1.isEnabled());
assertEquals("always", snapshotPolicy1.getUpdatePolicy());
assertEquals("warn", snapshotPolicy1.getChecksumPolicy());
RepositoryPolicy releasePolicy1 = remoteRepository.getPolicy(false);
assertEquals(true, releasePolicy1.isEnabled());
assertEquals("interval", releasePolicy1.getUpdatePolicy());
assertEquals("ignore", releasePolicy1.getChecksumPolicy());
} else if (remoteRepository.getId().equals("repo2")) {
RepositoryPolicy snapshotPolicy2 = remoteRepository.getPolicy(true);
assertEquals(true, snapshotPolicy2.isEnabled());
assertEquals("daily", snapshotPolicy2.getUpdatePolicy());
assertEquals("fail", snapshotPolicy2.getChecksumPolicy());
RepositoryPolicy releasePolicy2 = remoteRepository.getPolicy(false);
assertEquals(true, releasePolicy2.isEnabled());
assertEquals("daily", releasePolicy2.getUpdatePolicy());
assertEquals("fail", releasePolicy2.getChecksumPolicy());
}
}
MavenResource resource = MavenResource.parse("org.springframework.cloud.task.app:timestamp-task:jar:1.0.0.BUILD-SNAPSHOT", mavenProperties);
assertEquals(resource.exists(), true);
}
use of org.eclipse.aether.repository.RepositoryPolicy in project wildfly-swarm by wildfly-swarm.
the class MavenArtifactResolvingHelper method buildRemoteRepository.
private RemoteRepository buildRemoteRepository(final String id, final String url, final Authentication auth, final ArtifactRepositoryPolicy releasesPolicy, final ArtifactRepositoryPolicy snapshotsPolicy) {
RemoteRepository.Builder builder = new RemoteRepository.Builder(id, "default", url);
if (auth != null && auth.getUsername() != null && auth.getPassword() != null) {
builder.setAuthentication(new AuthenticationBuilder().addUsername(auth.getUsername()).addPassword(auth.getPassword()).build());
}
builder.setSnapshotPolicy(new RepositoryPolicy(snapshotsPolicy.isEnabled(), snapshotsPolicy.getUpdatePolicy(), snapshotsPolicy.getChecksumPolicy()));
builder.setReleasePolicy(new RepositoryPolicy(releasesPolicy.isEnabled(), releasesPolicy.getUpdatePolicy(), releasesPolicy.getChecksumPolicy()));
RemoteRepository repository = builder.build();
final RemoteRepository mirror = session.getMirrorSelector().getMirror(repository);
if (mirror != null) {
final org.eclipse.aether.repository.Authentication mirrorAuth = session.getAuthenticationSelector().getAuthentication(mirror);
RemoteRepository.Builder mirrorBuilder = new RemoteRepository.Builder(mirror).setId(repository.getId()).setSnapshotPolicy(new RepositoryPolicy(snapshotsPolicy.isEnabled(), snapshotsPolicy.getUpdatePolicy(), snapshotsPolicy.getChecksumPolicy())).setReleasePolicy(new RepositoryPolicy(releasesPolicy.isEnabled(), releasesPolicy.getUpdatePolicy(), releasesPolicy.getChecksumPolicy()));
if (mirrorAuth != null) {
mirrorBuilder.setAuthentication(mirrorAuth);
}
repository = mirrorBuilder.build();
}
Proxy proxy = session.getProxySelector().getProxy(repository);
if (proxy != null) {
repository = new RemoteRepository.Builder(repository).setProxy(proxy).build();
}
return repository;
}
Aggregations