Search in sources :

Example 6 with MavenArtifactRepository

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()));
}
Also used : ArtifactRepositoryLayout(org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout) DefaultRepositoryLayout(org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout) ArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository) MavenArtifactRepository(org.apache.maven.artifact.repository.MavenArtifactRepository) DefaultMirrorSelector(org.apache.maven.repository.DefaultMirrorSelector) ArtifactRepositoryPolicy(org.apache.maven.artifact.repository.ArtifactRepositoryPolicy) MavenArtifactRepository(org.apache.maven.artifact.repository.MavenArtifactRepository) Mirror(org.apache.maven.settings.Mirror) File(java.io.File) Settings(org.apache.maven.settings.Settings) Location(org.commonjava.maven.galley.model.Location) Test(org.junit.Test)

Example 7 with MavenArtifactRepository

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;
}
Also used : DefaultPlexusContainer(org.codehaus.plexus.DefaultPlexusContainer) PlexusContainer(org.codehaus.plexus.PlexusContainer) HashMap(java.util.HashMap) DefaultMavenExecutionResult(org.apache.maven.execution.DefaultMavenExecutionResult) MavenExecutionRequest(org.apache.maven.execution.MavenExecutionRequest) DefaultMavenExecutionRequest(org.apache.maven.execution.DefaultMavenExecutionRequest) DefaultMavenExecutionRequest(org.apache.maven.execution.DefaultMavenExecutionRequest) DefaultRepositoryLayout(org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout) StubTransport(org.commonjava.maven.ext.core.fixture.StubTransport) ArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository) MavenArtifactRepository(org.apache.maven.artifact.repository.MavenArtifactRepository) MavenSession(org.apache.maven.execution.MavenSession) DefaultPlexusContainer(org.codehaus.plexus.DefaultPlexusContainer) ArtifactRepositoryPolicy(org.apache.maven.artifact.repository.ArtifactRepositoryPolicy) MavenArtifactRepository(org.apache.maven.artifact.repository.MavenArtifactRepository) ManipulationSession(org.commonjava.maven.ext.core.ManipulationSession) VersioningState(org.commonjava.maven.ext.core.state.VersioningState) SimpleProjectRef(org.commonjava.maven.atlas.ident.ref.SimpleProjectRef) ProjectRef(org.commonjava.maven.atlas.ident.ref.ProjectRef) Transport(org.commonjava.maven.galley.spi.transport.Transport) StubTransport(org.commonjava.maven.ext.core.fixture.StubTransport) HashMap(java.util.HashMap) Map(java.util.Map) Location(org.commonjava.maven.galley.model.Location)

Example 8 with MavenArtifactRepository

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);
}
Also used : ArtifactRepositoryPolicy(org.apache.maven.artifact.repository.ArtifactRepositoryPolicy) DefaultRepositoryLayout(org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout) MavenArtifactRepository(org.apache.maven.artifact.repository.MavenArtifactRepository)

Example 9 with MavenArtifactRepository

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);
}
Also used : ArtifactRepositoryPolicy(org.apache.maven.artifact.repository.ArtifactRepositoryPolicy) DefaultRepositoryLayout(org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout) MavenArtifactRepository(org.apache.maven.artifact.repository.MavenArtifactRepository)

Example 10 with MavenArtifactRepository

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);
}
Also used : ArtifactRepositoryPolicy(org.apache.maven.artifact.repository.ArtifactRepositoryPolicy) DefaultRepositoryLayout(org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout) MavenArtifactRepository(org.apache.maven.artifact.repository.MavenArtifactRepository) ArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository) MavenArtifactRepository(org.apache.maven.artifact.repository.MavenArtifactRepository)

Aggregations

MavenArtifactRepository (org.apache.maven.artifact.repository.MavenArtifactRepository)26 ArtifactRepositoryPolicy (org.apache.maven.artifact.repository.ArtifactRepositoryPolicy)18 DefaultRepositoryLayout (org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout)17 ArtifactRepository (org.apache.maven.artifact.repository.ArtifactRepository)14 File (java.io.File)6 ArtifactRepositoryLayout (org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout)6 MavenSession (org.apache.maven.execution.MavenSession)4 Settings (org.apache.maven.settings.Settings)4 Location (org.commonjava.maven.galley.model.Location)3 ArrayList (java.util.ArrayList)2 Matcher (java.util.regex.Matcher)2 Artifact (org.apache.maven.artifact.Artifact)2 ArtifactFactory (org.apache.maven.artifact.factory.ArtifactFactory)2 DefaultMavenExecutionRequest (org.apache.maven.execution.DefaultMavenExecutionRequest)2 DefaultMavenExecutionResult (org.apache.maven.execution.DefaultMavenExecutionResult)2 MavenExecutionRequest (org.apache.maven.execution.MavenExecutionRequest)2 MojoFailureException (org.apache.maven.plugin.MojoFailureException)2 DefaultMirrorSelector (org.apache.maven.repository.DefaultMirrorSelector)2 Mirror (org.apache.maven.settings.Mirror)2 Profile (org.apache.maven.settings.Profile)2