use of org.apache.maven.artifact.repository.MavenArtifactRepository 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.MavenArtifactRepository in project maven-dependency-plugin by apache.
the class GetMojo method parseRepository.
ArtifactRepository parseRepository(String repo, ArtifactRepositoryPolicy policy) throws MojoFailureException {
// if it's a simple url
String id = "temp";
ArtifactRepositoryLayout layout = getLayout("default");
String url = repo;
// if it's an extended repo URL of the form id::layout::url
if (repo.contains("::")) {
Matcher matcher = ALT_REPO_SYNTAX_PATTERN.matcher(repo);
if (!matcher.matches()) {
throw new MojoFailureException(repo, "Invalid syntax for repository: " + repo, "Invalid syntax for repository. Use \"id::layout::url\" or \"URL\".");
}
id = matcher.group(1).trim();
if (!StringUtils.isEmpty(matcher.group(2))) {
layout = getLayout(matcher.group(2).trim());
}
url = matcher.group(3).trim();
}
return new MavenArtifactRepository(id, url, layout, policy, policy);
}
use of org.apache.maven.artifact.repository.MavenArtifactRepository 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.MavenArtifactRepository 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.MavenArtifactRepository 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