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

com.itemis.maven.plugins.unleash.steps.actions.DeployArtifacts 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: 2.10.0
Show newest version
package com.itemis.maven.plugins.unleash.steps.actions;

import java.util.Collection;
import java.util.List;

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

import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.project.MavenProject;
import org.eclipse.aether.artifact.Artifact;
import org.eclipse.aether.deployment.DeploymentException;

import com.itemis.maven.aether.ArtifactDeployer;
import com.itemis.maven.plugins.cdi.CDIMojoProcessingStep;
import com.itemis.maven.plugins.cdi.ExecutionContext;
import com.itemis.maven.plugins.cdi.annotations.ProcessingStep;
import com.itemis.maven.plugins.cdi.logging.Logger;
import com.itemis.maven.plugins.unleash.ReleaseMetadata;

/**
 * Deploys all release artifacts to the remote repository without invoking a Maven build process. Since this step cannot
 * be rolled back it is recommended to execute this step at the very last position of the processing workflow.
 *
 * @author Stanley Hillner
 * @since 1.0.0
 */
@ProcessingStep(id = "deployArtifacts", description = "Deploys the release artifacts to the remote repository. It is recommended to execute this step at the very last position of the workflow since it cannot be rolled back.", requiresOnline = true)
public class DeployArtifacts implements CDIMojoProcessingStep {
  @Inject
  private Logger log;
  @Inject
  @Named("reactorProjects")
  private List reactorProjects;
  @Inject
  private ArtifactDeployer deployer;
  @Inject
  private ReleaseMetadata metadata;

  @Override
  public void execute(ExecutionContext context) throws MojoExecutionException, MojoFailureException {
    this.log.info("Deploying the release artifacts into the distribution repository");

    try {
      Collection deployedArtifacts = this.deployer.deployArtifacts(this.metadata.getReleaseArtifacts());
      if (!deployedArtifacts.isEmpty()) {
        this.log.debug("\tDeployed the following release artifacts to the remote repository:");
        for (Artifact a : deployedArtifacts) {
          this.log.debug("\t\t" + a);
        }
      }
    } catch (DeploymentException e) {
      throw new MojoFailureException("Unable to deploy artifacts into remote repository.", e);
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy