1 package org.openecomp.sdc.onboarding.util;
4 import java.io.IOException;
5 import org.apache.maven.execution.MavenSession;
6 import org.apache.maven.plugin.AbstractMojo;
7 import org.apache.maven.plugin.MojoExecutionException;
8 import org.apache.maven.plugin.MojoFailureException;
9 import org.apache.maven.plugins.annotations.Component;
10 import org.apache.maven.plugins.annotations.LifecyclePhase;
11 import org.apache.maven.plugins.annotations.Mojo;
12 import org.apache.maven.plugins.annotations.Parameter;
13 import org.apache.maven.plugins.annotations.ResolutionScope;
14 import org.apache.maven.project.MavenProject;
15 import org.apache.maven.project.MavenProjectHelper;
17 @Mojo(name = "calibrate-artifact-helper", threadSafe = true, defaultPhase = LifecyclePhase.INSTALL,
18 requiresDependencyResolution = ResolutionScope.TEST)
19 public class CalibrateArtifactPlugin extends AbstractMojo {
21 private static final String ARTIFACT_COPY_PATH = "artifactPathToCopy";
23 @Parameter(defaultValue = "${session}")
24 private MavenSession session;
25 @Parameter(defaultValue = "${project}", readonly = true)
26 private MavenProject project;
28 private MavenProjectHelper projectHelper;
30 private String groupId;
32 private String artifactId;
34 private String version;
36 private String excludePackaging;
38 private ArtifactHelper artifactHelper;
41 public void execute() throws MojoExecutionException, MojoFailureException {
42 if (project.getPackaging().equals(excludePackaging)) {
45 if (project.getProperties().containsKey(ARTIFACT_COPY_PATH)
46 && project.getProperties().getProperty(ARTIFACT_COPY_PATH) != null) {
47 File f = new File(project.getProperties().getProperty(ARTIFACT_COPY_PATH));
49 project.getArtifact().setFile(f);
53 artifactHelper.shutDown(project);
54 } catch (IOException | ClassNotFoundException e) {
55 throw new MojoExecutionException("Unexpected Error Occured during shutdown activities", e);