All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.itemis.maven.aether.ArtifactDeployer Maven / Gradle / Ivy

Go to download

This plugin provides a generic alternative to the error-prone default release plugin provided by Maven. It is designed to require a minimal effort of work for releasing modules and being extensible to integrate in every project setup.

There is a newer version: 3.2.0
Show newest version
package com.itemis.maven.aether;

import java.util.Collection;
import java.util.Set;

import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;

import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.artifact.Artifact;
import org.eclipse.aether.deployment.DeployRequest;
import org.eclipse.aether.deployment.DeployResult;
import org.eclipse.aether.deployment.DeploymentException;
import org.eclipse.aether.impl.Deployer;
import org.eclipse.aether.repository.RemoteRepository;

import com.itemis.maven.plugins.unleash.ReleaseMetadata;

/**
 * Deploys artifacts into the remote Maven repositories.
 *
 * @author Stanley Hillner
 * @since 1.0.0
 */
@Singleton
public class ArtifactDeployer {
  @Inject
  private Deployer deployer;
  @Inject
  private RepositorySystemSession repoSession;
  @Inject
  private ReleaseMetadata metadata;
  @Inject
  @Named("additionalDeployemntRepositories")
  private Set additonalDeploymentRepositories;

  /**
   * Deploys the given artifacts to the configured remote Maven repositories.
   *
   * @param artifacts the artifacts to deploy.
   * @return the artifacts that have been deployed successfully.
   * @throws DeploymentException if anything goes wrong during the deployment process.
   */
  public Collection deployArtifacts(Collection artifacts) throws DeploymentException {
    Collection result = deploy(artifacts, this.metadata.getDeploymentRepository());
    for (RemoteRepository repo : this.additonalDeploymentRepositories) {
      deploy(artifacts, repo);
    }
    return result;
  }

  private Collection deploy(Collection artifacts, RemoteRepository repo)
      throws DeploymentException {
    DeployRequest request = new DeployRequest();
    request.setArtifacts(artifacts);
    request.setRepository(repo);
    DeployResult result = this.deployer.deploy(this.repoSession, request);
    return result.getArtifacts();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy