use of org.apache.maven.artifact.repository.ArtifactRepositoryPolicy in project fabric8 by jboss-fuse.
the class DeployToProfileMojo method addNeededRemoteRepository.
@SuppressWarnings("unchecked")
private void addNeededRemoteRepository() {
// TODO: Remove this code when we use releases from Maven Central
// included jboss-fs repo which is required until we use an Apache version of Karaf
boolean found = false;
if (remoteRepositories != null) {
for (Object obj : remoteRepositories) {
if (obj instanceof ArtifactRepository) {
ArtifactRepository repo = (ArtifactRepository) obj;
if (repo.getUrl().contains("repository.jboss.org/nexus/content/groups/fs-public")) {
found = true;
getLog().debug("Found existing (" + repo.getId() + ") remote repository: " + repo.getUrl());
break;
}
}
}
}
if (!found) {
ArtifactRepository fsPublic = new MavenArtifactRepository();
fsPublic.setId("jboss-public-fs");
fsPublic.setUrl("http://repository.jboss.org/nexus/content/groups/fs-public/");
fsPublic.setLayout(new DefaultRepositoryLayout());
fsPublic.setReleaseUpdatePolicy(new ArtifactRepositoryPolicy(true, "never", "warn"));
fsPublic.setSnapshotUpdatePolicy(new ArtifactRepositoryPolicy(false, "never", "ignore"));
if (remoteRepositories == null) {
remoteRepositories = new ArrayList();
}
remoteRepositories.add(fsPublic);
getLog().info("Adding needed remote repository: http://repository.jboss.org/nexus/content/groups/fs-public/");
}
}
use of org.apache.maven.artifact.repository.ArtifactRepositoryPolicy in project maven-dependency-plugin by apache.
the class TestGetMojo method testParseRepository.
/**
* Test parsing of the remote repositories parameter
*
* @throws Exception in case of errors
*/
public void testParseRepository() throws Exception {
ArtifactRepository repo;
ArtifactRepositoryPolicy policy = null;
repo = mojo.parseRepository("central::default::http://repo1.maven.apache.org/maven2", policy);
assertEquals("central", repo.getId());
assertEquals(DefaultRepositoryLayout.class, repo.getLayout().getClass());
assertEquals("http://repo1.maven.apache.org/maven2", repo.getUrl());
try {
repo = mojo.parseRepository("central::legacy::http://repo1.maven.apache.org/maven2", policy);
fail("Exception expected: legacy repository not supported anymore");
} catch (MojoFailureException e) {
}
repo = mojo.parseRepository("central::::http://repo1.maven.apache.org/maven2", policy);
assertEquals("central", repo.getId());
assertEquals(DefaultRepositoryLayout.class, repo.getLayout().getClass());
assertEquals("http://repo1.maven.apache.org/maven2", repo.getUrl());
repo = mojo.parseRepository("http://repo1.maven.apache.org/maven2", policy);
assertEquals("temp", repo.getId());
assertEquals(DefaultRepositoryLayout.class, repo.getLayout().getClass());
assertEquals("http://repo1.maven.apache.org/maven2", repo.getUrl());
try {
mojo.parseRepository("::::http://repo1.maven.apache.org/maven2", policy);
fail("Exception expected");
} catch (MojoFailureException e) {
// expected
}
try {
mojo.parseRepository("central::http://repo1.maven.apache.org/maven2", policy);
fail("Exception expected");
} catch (MojoFailureException e) {
// expected
}
}
use of org.apache.maven.artifact.repository.ArtifactRepositoryPolicy in project spring-cloud-function by spring-cloud.
the class DependencyResolutionModule method repo.
private ArtifactRepository repo(String id, String url, boolean releases, boolean snapshots) {
MavenArtifactRepository repository = new MavenArtifactRepository();
repository.setLayout(new DefaultRepositoryLayout());
repository.setId(id);
repository.setUrl(url);
ArtifactRepositoryPolicy enabled = new ArtifactRepositoryPolicy();
enabled.setEnabled(true);
ArtifactRepositoryPolicy disabled = new ArtifactRepositoryPolicy();
disabled.setEnabled(false);
repository.setReleaseUpdatePolicy(releases ? enabled : disabled);
repository.setSnapshotUpdatePolicy(snapshots ? enabled : disabled);
return repository;
}
use of org.apache.maven.artifact.repository.ArtifactRepositoryPolicy 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.apache.maven.artifact.repository.ArtifactRepositoryPolicy in project pom-manipulation-ext by release-engineering.
the class MavenLocationExpander method addSettingsProfileRepositoriesTo.
private void addSettingsProfileRepositoriesTo(final Set<Location> locs, final Settings settings, final List<String> activeProfiles, final MirrorSelector mirrorSelector) throws MalformedURLException {
if (settings != null) {
final Map<String, Profile> profiles = settings.getProfilesAsMap();
if (profiles != null && activeProfiles != null && !activeProfiles.isEmpty()) {
final LinkedHashSet<String> active = new LinkedHashSet<>(activeProfiles);
final List<String> settingsActiveProfiles = settings.getActiveProfiles();
if (settingsActiveProfiles != null && !settingsActiveProfiles.isEmpty()) {
active.addAll(settingsActiveProfiles);
}
for (final String profileId : active) {
final Profile profile = profiles.get(profileId);
if (profile != null) {
final List<Repository> repositories = profile.getRepositories();
if (repositories != null) {
final List<Mirror> mirrors = settings.getMirrors();
final ArtifactRepositoryLayout layout = new DefaultRepositoryLayout();
for (final Repository repo : repositories) {
String id = repo.getId();
String url = repo.getUrl();
if (mirrors != null) {
final ArtifactRepositoryPolicy snapshots = convertPolicy(repo.getSnapshots());
final ArtifactRepositoryPolicy releases = convertPolicy(repo.getReleases());
final MavenArtifactRepository arepo = new MavenArtifactRepository(id, url, layout, snapshots, releases);
final Mirror mirror = mirrorSelector == null ? null : mirrorSelector.getMirror(arepo, mirrors);
if (mirror != null) {
id = mirror.getId();
url = mirror.getUrl();
}
SimpleHttpLocation addition = new SimpleHttpLocation(id, url, snapshots.isEnabled(), releases.isEnabled(), true, false, null);
addition.setAttribute(Location.CONNECTION_TIMEOUT_SECONDS, 60);
locs.add(addition);
}
}
}
}
}
}
}
}
Aggregations