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

com.itemis.maven.aether.ArtifactInstaller 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 javax.inject.Inject;
import javax.inject.Singleton;

import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.artifact.Artifact;
import org.eclipse.aether.impl.Installer;
import org.eclipse.aether.installation.InstallRequest;
import org.eclipse.aether.installation.InstallResult;
import org.eclipse.aether.installation.InstallationException;

/**
 * Installs artifacts into the local Maven repository.
 *
 * @author Stanley Hillner
 * @since 1.0.0
 */
@Singleton
public class ArtifactInstaller {
  @Inject
  private RepositorySystemSession repoSession;

  @Inject
  private Installer installer;

  /**
   * Installs the given artifacts into the local Maven repository.
   * 
   * @param artifacts the artifacts to install.
   * @return the artifacts that have been installed successfully.
   * @throws InstallationException if anything goes wrong during the installation process.
   */
  public Collection installArtifacts(Collection artifacts) throws InstallationException {
    InstallRequest request = new InstallRequest();
    request.setArtifacts(artifacts);
    InstallResult result = this.installer.install(this.repoSession, request);
    return result.getArtifacts();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy