1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.tools.plugin.extractor.annotations.datamodel;
20
21 import java.lang.annotation.Annotation;
22 import java.util.Objects;
23
24 import org.apache.maven.plugins.annotations.InstantiationStrategy;
25 import org.apache.maven.plugins.annotations.LifecyclePhase;
26 import org.apache.maven.plugins.annotations.Mojo;
27 import org.apache.maven.plugins.annotations.ResolutionScope;
28
29
30
31
32
33 public class MojoAnnotationContent extends AnnotatedContent implements Mojo {
34 private String name;
35
36 private LifecyclePhase defaultPhase = LifecyclePhase.NONE;
37
38 private ResolutionScope requiresDependencyResolution = ResolutionScope.NONE;
39
40 private ResolutionScope requiresDependencyCollection = ResolutionScope.NONE;
41
42 private InstantiationStrategy instantiationStrategy = InstantiationStrategy.PER_LOOKUP;
43
44 private String executionStrategy = "once-per-session";
45
46 private boolean requiresProject = true;
47
48 private boolean requiresReports = false;
49
50 private boolean aggregator = false;
51
52 private boolean requiresDirectInvocation = false;
53
54 private boolean requiresOnline = false;
55
56 private boolean inheritByDefault = true;
57
58 private String configurator;
59
60 private boolean threadSafe = false;
61
62 @Override
63 public Class<? extends Annotation> annotationType() {
64 return null;
65 }
66
67 @Override
68 public LifecyclePhase defaultPhase() {
69 return defaultPhase;
70 }
71
72 public void defaultPhase(String phase) {
73 if (phase != null && !phase.isEmpty()) {
74 for (LifecyclePhase p : LifecyclePhase.values()) {
75 if (Objects.equals(phase, p.id()) || Objects.equals(phase, p.name())) {
76 this.defaultPhase = p;
77 return;
78 }
79 }
80 throw new IllegalArgumentException("Could not find a matching phase for " + phase);
81 } else {
82 this.defaultPhase = null;
83 }
84 }
85
86 @Override
87 public ResolutionScope requiresDependencyResolution() {
88 return requiresDependencyResolution;
89 }
90
91 public void requiresDependencyResolution(String requiresDependencyResolution) {
92 this.requiresDependencyResolution = ResolutionScope.valueOf(requiresDependencyResolution);
93 }
94
95 public void dependencyResolutionRequired(String dependencyResolutionRequired) {
96 this.requiresDependencyResolution = ResolutionScope.valueOf(dependencyResolutionRequired);
97 }
98
99 @Override
100 public ResolutionScope requiresDependencyCollection() {
101 return requiresDependencyCollection;
102 }
103
104 public void requiresDependencyCollection(String requiresDependencyCollection) {
105 this.requiresDependencyCollection = ResolutionScope.valueOf(requiresDependencyCollection);
106 }
107
108 @Override
109 public InstantiationStrategy instantiationStrategy() {
110 return instantiationStrategy;
111 }
112
113 public void instantiationStrategy(String instantiationStrategy) {
114 this.instantiationStrategy = InstantiationStrategy.valueOf(instantiationStrategy);
115 }
116
117 @Override
118 public String executionStrategy() {
119 return executionStrategy;
120 }
121
122 public void executionStrategy(String executionStrategy) {
123 this.executionStrategy = executionStrategy;
124 }
125
126 @Override
127 public boolean requiresProject() {
128 return requiresProject;
129 }
130
131 public void requiresProject(boolean requiresProject) {
132 this.requiresProject = requiresProject;
133 }
134
135 public void projectRequired(boolean requiresProject) {
136 this.requiresProject = requiresProject;
137 }
138
139 @Override
140 public boolean requiresReports() {
141 return requiresReports;
142 }
143
144 public void requiresReports(boolean requiresReports) {
145 this.requiresReports = requiresReports;
146 }
147
148 @Override
149 public boolean aggregator() {
150 return aggregator;
151 }
152
153 public void aggregator(boolean aggregator) {
154 this.aggregator = aggregator;
155 }
156
157 @Override
158 public boolean requiresDirectInvocation() {
159 return requiresDirectInvocation;
160 }
161
162 public void requiresDirectInvocation(boolean requiresDirectInvocation) {
163 this.requiresDirectInvocation = requiresDirectInvocation;
164 }
165
166 @Override
167 public boolean requiresOnline() {
168 return requiresOnline;
169 }
170
171 public void requiresOnline(boolean requiresOnline) {
172 this.requiresOnline = requiresOnline;
173 }
174
175 @Override
176 public boolean inheritByDefault() {
177 return inheritByDefault;
178 }
179
180 public void inheritByDefault(boolean inheritByDefault) {
181 this.inheritByDefault = inheritByDefault;
182 }
183
184 @Override
185 public String configurator() {
186 return configurator;
187 }
188
189 public void configurator(String configurator) {
190 this.configurator = configurator;
191 }
192
193 @Override
194 public boolean threadSafe() {
195 return threadSafe;
196 }
197
198 public void threadSafe(boolean threadSafe) {
199 this.threadSafe = threadSafe;
200 }
201
202 @Override
203 public String name() {
204 return this.name;
205 }
206
207 public void name(String name) {
208 this.name = name;
209 }
210
211 @Override
212 public String toString() {
213 final StringBuilder sb = new StringBuilder();
214 sb.append("MojoAnnotationContent");
215 sb.append("{name='").append(name).append('\'');
216 sb.append(", defaultPhase=").append(defaultPhase);
217 sb.append(", requiresDependencyResolution='")
218 .append(requiresDependencyResolution)
219 .append('\'');
220 sb.append(", requiresDependencyCollection='")
221 .append(requiresDependencyCollection)
222 .append('\'');
223 sb.append(", instantiationStrategy='").append(instantiationStrategy).append('\'');
224 sb.append(", executionStrategy='").append(executionStrategy).append('\'');
225 sb.append(", requiresProject=").append(requiresProject);
226 sb.append(", requiresReports=").append(requiresReports);
227 sb.append(", aggregator=").append(aggregator);
228 sb.append(", requiresDirectInvocation=").append(requiresDirectInvocation);
229 sb.append(", requiresOnline=").append(requiresOnline);
230 sb.append(", inheritByDefault=").append(inheritByDefault);
231 sb.append(", configurator='").append(configurator).append('\'');
232 sb.append(", threadSafe=").append(threadSafe);
233 sb.append('}');
234 return sb.toString();
235 }
236 }