001 package org.apache.maven.tools.plugin.annotations.datamodel;
002
003 /*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements. See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership. The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License. You may obtain a copy of the License at
011 *
012 * http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied. See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022 import org.apache.maven.plugins.annotations.InstantiationStrategy;
023 import org.apache.maven.plugins.annotations.InstanciationStrategy;
024 import org.apache.maven.plugins.annotations.LifecyclePhase;
025 import org.apache.maven.plugins.annotations.Mojo;
026 import org.apache.maven.plugins.annotations.ResolutionScope;
027
028 import java.lang.annotation.Annotation;
029
030 /**
031 * @author Olivier Lamy
032 * @since 3.0
033 */
034 @SuppressWarnings("deprecation")
035 public class MojoAnnotationContent
036 extends AnnotatedContent
037 implements Mojo
038 {
039 private String name;
040
041 private LifecyclePhase defaultPhase = LifecyclePhase.NONE;
042
043 private ResolutionScope requiresDependencyResolution = ResolutionScope.NONE;
044
045 private ResolutionScope requiresDependencyCollection = ResolutionScope.NONE;
046
047 private InstantiationStrategy instantiationStrategy = InstantiationStrategy.PER_LOOKUP;
048
049 private String executionStrategy = "once-per-session";
050
051 private boolean requiresProject = true;
052
053 private boolean requiresReports = false;
054
055 private boolean aggregator = false;
056
057 private boolean requiresDirectInvocation = false;
058
059 private boolean requiresOnline = false;
060
061 private boolean inheritByDefault = true;
062
063 private String configurator;
064
065 private boolean threadSafe = false;
066
067 public Class<? extends Annotation> annotationType()
068 {
069 return null;
070 }
071
072 public LifecyclePhase defaultPhase()
073 {
074 return defaultPhase;
075 }
076
077 public void defaultPhase( String phase )
078 {
079 this.defaultPhase = LifecyclePhase.valueOf( phase );
080 }
081
082 public ResolutionScope requiresDependencyResolution()
083 {
084 return requiresDependencyResolution;
085 }
086
087 public void requiresDependencyResolution( String requiresDependencyResolution )
088 {
089 this.requiresDependencyResolution = ResolutionScope.valueOf( requiresDependencyResolution );
090 }
091
092 public ResolutionScope requiresDependencyCollection()
093 {
094 return requiresDependencyCollection;
095 }
096
097 public void requiresDependencyCollection( String requiresDependencyCollection )
098 {
099 this.requiresDependencyCollection = ResolutionScope.valueOf( requiresDependencyCollection );
100 }
101
102 public InstantiationStrategy instantiationStrategy()
103 {
104 return instantiationStrategy;
105 }
106
107 /**
108 * The original spelling of the instantiationStrategy attribute.
109 * This returns the value under the correct name, there's no separate
110 * field.
111 *
112 * @return the instantiation strategy
113 * @see #instantiationStrategy()
114 */
115 @SuppressWarnings( "deprecation" )
116 public InstanciationStrategy instanciationStrategy()
117 {
118 if ( instantiationStrategy == null )
119 {
120 return null;
121 }
122 return InstanciationStrategy.valueOf( instanciationStrategy().name() );
123 }
124
125 public void instantiationStrategy( String instantiationStrategy )
126 {
127 this.instantiationStrategy = InstantiationStrategy.valueOf( instantiationStrategy );
128 }
129
130 public String executionStrategy()
131 {
132 return executionStrategy;
133 }
134
135 public void executionStrategy( String executionStrategy )
136 {
137 this.executionStrategy = executionStrategy;
138 }
139
140 public boolean requiresProject()
141 {
142 return requiresProject;
143 }
144
145 public void requiresProject( boolean requiresProject )
146 {
147 this.requiresProject = requiresProject;
148 }
149
150 public boolean requiresReports()
151 {
152 return requiresReports;
153 }
154
155 public void requiresReports( boolean requiresReports )
156 {
157 this.requiresReports = requiresReports;
158 }
159
160 public boolean aggregator()
161 {
162 return aggregator;
163 }
164
165 public void aggregator( boolean aggregator )
166 {
167 this.aggregator = aggregator;
168 }
169
170 public boolean requiresDirectInvocation()
171 {
172 return requiresDirectInvocation;
173 }
174
175 public void requiresDirectInvocation( boolean requiresDirectInvocation )
176 {
177 this.requiresDirectInvocation = requiresDirectInvocation;
178 }
179
180 public boolean requiresOnline()
181 {
182 return requiresOnline;
183 }
184
185 public void requiresOnline( boolean requiresOnline )
186 {
187 this.requiresOnline = requiresOnline;
188 }
189
190 public boolean inheritByDefault()
191 {
192 return inheritByDefault;
193 }
194
195 public void inheritByDefault( boolean inheritByDefault )
196 {
197 this.inheritByDefault = inheritByDefault;
198 }
199
200 public String configurator()
201 {
202 return configurator;
203 }
204
205 public void configurator( String configurator )
206 {
207 this.configurator = configurator;
208 }
209
210 public boolean threadSafe()
211 {
212 return threadSafe;
213 }
214
215 public void threadSafe( boolean threadSafe )
216 {
217 this.threadSafe = threadSafe;
218 }
219
220 public String name()
221 {
222 return this.name;
223 }
224
225 public void name( String name )
226 {
227 this.name = name;
228 }
229
230 @Override
231 public String toString()
232 {
233 final StringBuilder sb = new StringBuilder();
234 sb.append( "MojoAnnotationContent" );
235 sb.append( "{name='" ).append( name ).append( '\'' );
236 sb.append( ", defaultPhase=" ).append( defaultPhase );
237 sb.append( ", requiresDependencyResolution='" ).append( requiresDependencyResolution ).append( '\'' );
238 sb.append( ", requiresDependencyCollection='" ).append( requiresDependencyCollection ).append( '\'' );
239 sb.append( ", instantiationStrategy='" ).append( instantiationStrategy ).append( '\'' );
240 sb.append( ", executionStrategy='" ).append( executionStrategy ).append( '\'' );
241 sb.append( ", requiresProject=" ).append( requiresProject );
242 sb.append( ", requiresReports=" ).append( requiresReports );
243 sb.append( ", aggregator=" ).append( aggregator );
244 sb.append( ", requiresDirectInvocation=" ).append( requiresDirectInvocation );
245 sb.append( ", requiresOnline=" ).append( requiresOnline );
246 sb.append( ", inheritByDefault=" ).append( inheritByDefault );
247 sb.append( ", configurator='" ).append( configurator ).append( '\'' );
248 sb.append( ", threadSafe=" ).append( threadSafe );
249 sb.append( '}' );
250 return sb.toString();
251 }
252 }