io.tesla.maven.plugins.Deploy Maven / Gradle / Ivy
The newest version!
package io.tesla.maven.plugins;
import io.tesla.maven.plugins.util.AetherUtils;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
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.DeployRequest;
import org.eclipse.aether.deployment.DeploymentException;
import org.eclipse.aether.repository.Authentication;
import org.eclipse.aether.repository.RemoteRepository;
import org.eclipse.aether.util.repository.AuthenticationBuilder;
/**
* @goal deploy
* @phase deploy
* @author jvanzyl
*/
public class Deploy extends Install {
// deploy at the end to prevent corruption
// polyglot conversion to detect the project type and convert on the way out the door
// how to help people fork projects and deploy elsewhere: the alt deployment repo may have issues
// - a standard property to replace in a conventional way?
@Override
public void executeMojo() throws MojoExecutionException, MojoFailureException {
}
public void deploy(Artifact pom, String remoteRepositoryUrl) throws DeploymentException {
Artifact artifact = AetherUtils.toArtifact(project.getArtifact());
String packaging = project.getPackaging();
File pomFile = project.getFile();
List attachedArtifacts = new ArrayList();
for (org.apache.maven.artifact.Artifact attachedArtifact : project.getAttachedArtifacts()) {
attachedArtifacts.add(AetherUtils.toArtifact(attachedArtifact));
}
RemoteRepository remoteRepository = new RemoteRepository.Builder("nexus", "default", remoteRepositoryUrl).build();
Authentication authentication = new AuthenticationBuilder().addUsername("admin").addPassword("admin123").build();
DeployRequest deployRequest = new DeployRequest();
deployRequest.addArtifact(artifact).addArtifact(pom);
deployRequest.setRepository(remoteRepository);
repositorySystem.deploy(repositorySystemSession, deployRequest);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy