1 package com.atlassian.maven.plugins.amps;
2
3 import java.util.List;
4
5 import org.apache.maven.execution.MavenSession;
6 import org.apache.maven.plugin.AbstractMojo;
7 import org.apache.maven.plugin.PluginManager;
8 import org.apache.maven.project.MavenProject;
9 import org.jfrog.maven.annomojo.annotations.MojoComponent;
10 import org.jfrog.maven.annomojo.annotations.MojoParameter;
11
12 public abstract class AbstractAmpsMojo extends AbstractMojo
13 {
14
15
16
17 @MojoParameter (expression = "${project}", required = true, readonly = true)
18 private MavenProject project;
19
20
21
22
23 @MojoParameter (expression = "${reactorProjects}", required = true, readonly = true)
24 private List<MavenProject> reactor;
25
26
27
28
29 @MojoParameter (expression = "${session}", required = true, readonly = true)
30 private MavenSession session;
31
32
33
34
35 @MojoComponent
36 private PluginManager pluginManager;
37
38
39
40
41 @MojoParameter (expression = "${plugin.artifactId}", required = true, readonly = true)
42 private String pluginArtifactId;
43
44
45
46
47 @MojoParameter (expression = "${plugin.version}", required = true, readonly = true)
48 private String pluginVersion;
49
50
51
52
53 private MavenContext mavenContext;
54
55
56
57
58 private MavenGoals mavenGoals;
59
60 protected MavenContext getMavenContext()
61 {
62 if (mavenContext == null)
63 {
64 mavenContext = new MavenContext(project, reactor, session, pluginManager, getLog());
65 }
66 return mavenContext;
67 }
68
69 protected MavenGoals getMavenGoals()
70 {
71 if (mavenGoals == null)
72 {
73 mavenGoals = new MavenGoals(getMavenContext());
74 }
75 return mavenGoals;
76 }
77
78 protected PluginInformation getPluginInformation()
79 {
80 final String productId = pluginArtifactId.replaceAll("maven-(.*)-plugin", "$1");
81 return new PluginInformation(productId, pluginVersion);
82 }
83 }