use of org.apache.maven.artifact.repository.MavenArtifactRepository in project pom-manipulation-ext by release-engineering.
the class MavenLocationExpanderTest method mirrorAdjustsLocationURLs.
@Test
public void mirrorAdjustsLocationURLs() throws Exception {
final Mirror mirror = new Mirror();
mirror.setId("test-mirror");
mirror.setMirrorOf("*");
mirror.setUrl("http://nowhere.com");
final ArtifactRepositoryLayout layout = new DefaultRepositoryLayout();
final ArtifactRepositoryPolicy snapshots = new ArtifactRepositoryPolicy(true, ArtifactRepositoryPolicy.UPDATE_POLICY_DAILY, ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN);
final ArtifactRepositoryPolicy releases = new ArtifactRepositoryPolicy(true, ArtifactRepositoryPolicy.UPDATE_POLICY_NEVER, ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN);
final File localRepo = File.createTempFile("local.repo.", ".dir");
localRepo.deleteOnExit();
final ArtifactRepository local = new MavenArtifactRepository("local", localRepo.toURI().toString(), layout, snapshots, releases);
final ArtifactRepository remote = new MavenArtifactRepository("remote", "http:///repo.maven.apache.org/maven2", layout, snapshots, releases);
final Settings settings = new Settings();
settings.addMirror(mirror);
final MavenLocationExpander ex = new MavenLocationExpander(Collections.<Location>emptyList(), Collections.<ArtifactRepository>singletonList(remote), local, new DefaultMirrorSelector(), settings, Collections.<String>emptyList());
final List<Location> result = ex.expand(MavenLocationExpander.EXPANSION_TARGET);
assertThat(result.size(), equalTo(2));
final Iterator<Location> iterator = result.iterator();
Location loc = iterator.next();
assertThat(loc.getName(), equalTo(local.getId()));
assertThat(loc.getUri(), equalTo(local.getUrl()));
loc = iterator.next();
assertThat(loc.getName(), equalTo(mirror.getId()));
assertThat(loc.getUri(), equalTo(mirror.getUrl()));
}
use of org.apache.maven.artifact.repository.MavenArtifactRepository in project pom-manipulation-ext by release-engineering.
the class VersioningCalculatorTest method setupSession.
private VersioningState setupSession(final Properties properties, final Map<ProjectRef, String[]> versionMap) throws Exception {
final ArtifactRepository ar = new MavenArtifactRepository("test", "http://repo.maven.apache.org/maven2", new DefaultRepositoryLayout(), new ArtifactRepositoryPolicy(), new ArtifactRepositoryPolicy());
final MavenExecutionRequest req = new DefaultMavenExecutionRequest().setUserProperties(properties).setRemoteRepositories(Arrays.asList(ar));
final PlexusContainer container = new DefaultPlexusContainer();
final MavenSession mavenSession = new MavenSession(container, null, req, new DefaultMavenExecutionResult());
session = new ManipulationSession();
session.setMavenSession(mavenSession);
final VersioningState state = new VersioningState(properties);
session.setState(state);
final Map<String, byte[]> dataMap = new HashMap<>();
if (versionMap != null && !versionMap.isEmpty()) {
for (final Map.Entry<ProjectRef, String[]> entry : versionMap.entrySet()) {
final String path = toMetadataPath(entry.getKey());
final byte[] data = setupMetadataVersions(entry.getValue());
dataMap.put(path, data);
}
}
final Location mdLoc = MavenLocationExpander.EXPANSION_TARGET;
final Transport mdTrans = new StubTransport(dataMap);
modder = new TestVersionCalculator(new ManipulationSession(), mdLoc, mdTrans, temp.newFolder("galley-cache"));
return state;
}
use of org.apache.maven.artifact.repository.MavenArtifactRepository in project maven-archetype by apache.
the class ArchetyperRoundtripWithProxyIT method createRepository.
private ArtifactRepository createRepository(String url, String repositoryId) {
String updatePolicyFlag = ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS;
String checksumPolicyFlag = ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN;
ArtifactRepositoryPolicy snapshotsPolicy = new ArtifactRepositoryPolicy(true, updatePolicyFlag, checksumPolicyFlag);
ArtifactRepositoryPolicy releasesPolicy = new ArtifactRepositoryPolicy(true, updatePolicyFlag, checksumPolicyFlag);
return new MavenArtifactRepository(repositoryId, url, new DefaultRepositoryLayout(), snapshotsPolicy, releasesPolicy);
}
use of org.apache.maven.artifact.repository.MavenArtifactRepository in project maven-archetype by apache.
the class InternalCatalogArchetypesVerificationTest method createRepository.
private ArtifactRepository createRepository(String url, String repositoryId) {
String updatePolicyFlag = ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS;
String checksumPolicyFlag = ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN;
ArtifactRepositoryPolicy snapshotsPolicy = new ArtifactRepositoryPolicy(true, updatePolicyFlag, checksumPolicyFlag);
ArtifactRepositoryPolicy releasesPolicy = new ArtifactRepositoryPolicy(true, updatePolicyFlag, checksumPolicyFlag);
return new MavenArtifactRepository(repositoryId, url, new DefaultRepositoryLayout(), snapshotsPolicy, releasesPolicy);
}
use of org.apache.maven.artifact.repository.MavenArtifactRepository in project maven-plugins by apache.
the class JiraUnicodeTestProjectStub method getRemoteArtifactRepositories.
/**
* {@inheritDoc}
*/
@Override
public List<ArtifactRepository> getRemoteArtifactRepositories() {
ArtifactRepositoryPolicy policy = new ArtifactRepositoryPolicy(true, ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS, ArtifactRepositoryPolicy.CHECKSUM_POLICY_IGNORE);
ArtifactRepository repository = new MavenArtifactRepository("central", "http://repo1.maven.org/maven2", new DefaultRepositoryLayout(), policy, policy);
return Collections.singletonList(repository);
}
Aggregations