Search in sources :

Example 1 with DeployRequest

use of org.sonatype.aether.deployment.DeployRequest in project sonatype-aether by sonatype.

the class Aether method deploy.

public void deploy(Artifact artifact, Artifact pom, String remoteRepository) throws DeploymentException {
    RepositorySystemSession session = newSession();
    RemoteRepository nexus = new RemoteRepository("nexus", "default", remoteRepository);
    Authentication authentication = new Authentication("admin", "admin123");
    nexus.setAuthentication(authentication);
    DeployRequest deployRequest = new DeployRequest();
    deployRequest.addArtifact(artifact).addArtifact(pom);
    deployRequest.setRepository(nexus);
    repositorySystem.deploy(session, deployRequest);
}
Also used : MavenRepositorySystemSession(org.apache.maven.repository.internal.MavenRepositorySystemSession) RepositorySystemSession(org.sonatype.aether.RepositorySystemSession) Authentication(org.sonatype.aether.repository.Authentication) DeployRequest(org.sonatype.aether.deployment.DeployRequest) RemoteRepository(org.sonatype.aether.repository.RemoteRepository)

Example 2 with DeployRequest

use of org.sonatype.aether.deployment.DeployRequest in project sonatype-aether by sonatype.

the class DeployArtifacts method main.

public static void main(String[] args) throws Exception {
    System.out.println("------------------------------------------------------------");
    System.out.println(DeployArtifacts.class.getSimpleName());
    RepositorySystem system = Booter.newRepositorySystem();
    RepositorySystemSession session = Booter.newRepositorySystemSession(system);
    Artifact jarArtifact = new DefaultArtifact("test", "demo", "", "jar", "0.1-SNAPSHOT");
    jarArtifact = jarArtifact.setFile(new File("demo.jar"));
    Artifact pomArtifact = new SubArtifact(jarArtifact, "", "pom");
    pomArtifact = pomArtifact.setFile(new File("pom.xml"));
    RemoteRepository distRepo = new RemoteRepository("demo", "default", new File("target/dist-repo").toURI().toString());
    DeployRequest deployRequest = new DeployRequest();
    deployRequest.addArtifact(jarArtifact).addArtifact(pomArtifact);
    deployRequest.setRepository(distRepo);
    system.deploy(session, deployRequest);
}
Also used : RepositorySystem(org.sonatype.aether.RepositorySystem) RepositorySystemSession(org.sonatype.aether.RepositorySystemSession) SubArtifact(org.sonatype.aether.util.artifact.SubArtifact) DeployRequest(org.sonatype.aether.deployment.DeployRequest) RemoteRepository(org.sonatype.aether.repository.RemoteRepository) File(java.io.File) Artifact(org.sonatype.aether.artifact.Artifact) DefaultArtifact(org.sonatype.aether.util.artifact.DefaultArtifact) SubArtifact(org.sonatype.aether.util.artifact.SubArtifact) DefaultArtifact(org.sonatype.aether.util.artifact.DefaultArtifact)

Example 3 with DeployRequest

use of org.sonatype.aether.deployment.DeployRequest in project gradle by gradle.

the class MavenDeployAction method publishArtifacts.

@Override
protected void publishArtifacts(Collection<Artifact> artifacts, RepositorySystem repositorySystem, RepositorySystemSession session) throws DeploymentException {
    RemoteRepository gradleRepo = remoteRepository;
    if (artifacts.iterator().next().isSnapshot() && remoteSnapshotRepository != null) {
        gradleRepo = remoteSnapshotRepository;
    }
    if (gradleRepo == null) {
        throw new GradleException("Must specify a repository for deployment");
    }
    org.sonatype.aether.repository.RemoteRepository aetherRepo = createRepository(gradleRepo);
    DeployRequest request = new DeployRequest();
    request.setRepository(aetherRepo);
    for (Artifact artifact : artifacts) {
        request.addArtifact(artifact);
    }
    LOGGER.info("Deploying to {}", gradleRepo.getUrl());
    repositorySystem.deploy(session, request);
}
Also used : GradleException(org.gradle.api.GradleException) DeployRequest(org.sonatype.aether.deployment.DeployRequest) RemoteRepository(org.apache.maven.artifact.ant.RemoteRepository) Artifact(org.sonatype.aether.artifact.Artifact)

Example 4 with DeployRequest

use of org.sonatype.aether.deployment.DeployRequest in project sonatype-aether by sonatype.

the class DefaultDeployerTest method setup.

@Before
public void setup() throws IOException {
    artifact = new DefaultArtifact("gid", "aid", "jar", "ver");
    artifact = artifact.setFile(TestFileUtils.createTempFile("artifact"));
    metadata = new DefaultMetadata("gid", "aid", "ver", "type", Nature.RELEASE_OR_SNAPSHOT, TestFileUtils.createTempFile("metadata"));
    session = new TestRepositorySystemSession();
    manager = new StubRemoteRepositoryManager();
    deployer = new DefaultDeployer();
    deployer.setRemoteRepositoryManager(manager);
    deployer.setRepositoryEventDispatcher(new StubRepositoryEventDispatcher());
    UpdateCheckManager updateCheckManager = new StaticUpdateCheckManager(true);
    deployer.setUpdateCheckManager(updateCheckManager);
    deployer.setFileProcessor(TestFileProcessor.INSTANCE);
    deployer.setSyncContextFactory(new StubSyncContextFactory());
    request = new DeployRequest();
    request.setRepository(new RemoteRepository("id", "default", "file:///"));
    connector = new RecordingRepositoryConnector();
    manager.setConnector(connector);
    listener = new RecordingRepositoryListener();
    session.setRepositoryListener(listener);
}
Also used : DeployRequest(org.sonatype.aether.deployment.DeployRequest) DefaultMetadata(org.sonatype.aether.util.metadata.DefaultMetadata) UpdateCheckManager(org.sonatype.aether.impl.UpdateCheckManager) RemoteRepository(org.sonatype.aether.repository.RemoteRepository) TestRepositorySystemSession(org.sonatype.aether.test.impl.TestRepositorySystemSession) RecordingRepositoryListener(org.sonatype.aether.test.impl.RecordingRepositoryListener) DefaultArtifact(org.sonatype.aether.util.artifact.DefaultArtifact) Before(org.junit.Before)

Aggregations

DeployRequest (org.sonatype.aether.deployment.DeployRequest)4 RemoteRepository (org.sonatype.aether.repository.RemoteRepository)3 RepositorySystemSession (org.sonatype.aether.RepositorySystemSession)2 Artifact (org.sonatype.aether.artifact.Artifact)2 DefaultArtifact (org.sonatype.aether.util.artifact.DefaultArtifact)2 File (java.io.File)1 RemoteRepository (org.apache.maven.artifact.ant.RemoteRepository)1 MavenRepositorySystemSession (org.apache.maven.repository.internal.MavenRepositorySystemSession)1 GradleException (org.gradle.api.GradleException)1 Before (org.junit.Before)1 RepositorySystem (org.sonatype.aether.RepositorySystem)1 UpdateCheckManager (org.sonatype.aether.impl.UpdateCheckManager)1 Authentication (org.sonatype.aether.repository.Authentication)1 RecordingRepositoryListener (org.sonatype.aether.test.impl.RecordingRepositoryListener)1 TestRepositorySystemSession (org.sonatype.aether.test.impl.TestRepositorySystemSession)1 SubArtifact (org.sonatype.aether.util.artifact.SubArtifact)1 DefaultMetadata (org.sonatype.aether.util.metadata.DefaultMetadata)1