View Javadoc

1   /*
2    * $Id$
3    */
4   
5   package org.apache.maven.plugin.tools.model;
6   
7     //---------------------------------/
8    //- Imported classes and packages -/
9   //---------------------------------/
10  
11  import java.util.Date;
12  
13  /**
14   * Mojo descriptor definition.
15   * 
16   * @version $Revision$ $Date$
17   */
18  public class Mojo implements java.io.Serializable {
19  
20  
21        //--------------------------/
22       //- Class/Member Variables -/
23      //--------------------------/
24  
25      /**
26       * Field goal
27       */
28      private String goal;
29  
30      /**
31       * Field phase
32       */
33      private String phase;
34  
35      /**
36       * Field aggregator
37       */
38      private boolean aggregator = false;
39  
40      /**
41       * Field requiresDependencyResolution
42       */
43      private String requiresDependencyResolution;
44  
45      /**
46       * Field requiresProject
47       */
48      private boolean requiresProject = false;
49  
50      /**
51       * Field requiresReports
52       */
53      private boolean requiresReports = false;
54  
55      /**
56       * Field requiresOnline
57       */
58      private boolean requiresOnline = false;
59  
60      /**
61       * Field inheritByDefault
62       */
63      private boolean inheritByDefault = false;
64  
65      /**
66       * Field requiresDirectInvocation
67       */
68      private boolean requiresDirectInvocation = false;
69  
70      /**
71       * Field execution
72       */
73      private LifecycleExecution execution;
74  
75      /**
76       * Field components
77       */
78      private java.util.List components;
79  
80      /**
81       * Field parameters
82       */
83      private java.util.List parameters;
84  
85      /**
86       * Field description
87       */
88      private String description;
89  
90      /**
91       * Field deprecation
92       */
93      private String deprecation;
94  
95      /**
96       * Field call
97       */
98      private String call;
99  
100 
101       //-----------/
102      //- Methods -/
103     //-----------/
104 
105     /**
106      * Method addComponent
107      * 
108      * @param component
109      */
110     public void addComponent(Component component)
111     {
112         if ( !(component instanceof Component) )
113         {
114             throw new ClassCastException( "Mojo.addComponents(component) parameter must be instanceof " + Component.class.getName() );
115         }
116         getComponents().add( component );
117     } //-- void addComponent(Component) 
118 
119     /**
120      * Method addParameter
121      * 
122      * @param parameter
123      */
124     public void addParameter(Parameter parameter)
125     {
126         if ( !(parameter instanceof Parameter) )
127         {
128             throw new ClassCastException( "Mojo.addParameters(parameter) parameter must be instanceof " + Parameter.class.getName() );
129         }
130         getParameters().add( parameter );
131     } //-- void addParameter(Parameter) 
132 
133     /**
134      * Get The target/method within the script to call when this
135      * mojo executes.
136      */
137     public String getCall()
138     {
139         return this.call;
140     } //-- String getCall() 
141 
142     /**
143      * Method getComponents
144      */
145     public java.util.List getComponents()
146     {
147         if ( this.components == null )
148         {
149             this.components = new java.util.ArrayList();
150         }
151         
152         return this.components;
153     } //-- java.util.List getComponents() 
154 
155     /**
156      * Get A deprecation message for this mojo parameter.
157      */
158     public String getDeprecation()
159     {
160         return this.deprecation;
161     } //-- String getDeprecation() 
162 
163     /**
164      * Get The description for this parameter.
165      */
166     public String getDescription()
167     {
168         return this.description;
169     } //-- String getDescription() 
170 
171     /**
172      * Get Information about a sub-execution of the Maven lifecycle
173      * which should be processed.
174      */
175     public LifecycleExecution getExecution()
176     {
177         return this.execution;
178     } //-- LifecycleExecution getExecution() 
179 
180     /**
181      * Get The name of the goal used to invoke this mojo.
182      */
183     public String getGoal()
184     {
185         return this.goal;
186     } //-- String getGoal() 
187 
188     /**
189      * Method getParameters
190      */
191     public java.util.List getParameters()
192     {
193         if ( this.parameters == null )
194         {
195             this.parameters = new java.util.ArrayList();
196         }
197         
198         return this.parameters;
199     } //-- java.util.List getParameters() 
200 
201     /**
202      * Get The phase to which this mojo should be bound by default.
203      */
204     public String getPhase()
205     {
206         return this.phase;
207     } //-- String getPhase() 
208 
209     /**
210      * Get The scope of dependencies that this mojo requires to
211      * have resolved.
212      */
213     public String getRequiresDependencyResolution()
214     {
215         return this.requiresDependencyResolution;
216     } //-- String getRequiresDependencyResolution() 
217 
218     /**
219      * Get Whether this mojo operates as an aggregator when the
220      * reactor is run. That is, only runs once.
221      *           
222      */
223     public boolean isAggregator()
224     {
225         return this.aggregator;
226     } //-- boolean isAggregator() 
227 
228     /**
229      * Get Whether this mojo's configuration should propagate down
230      * the POM inheritance chain by default.
231      *           
232      */
233     public boolean isInheritByDefault()
234     {
235         return this.inheritByDefault;
236     } //-- boolean isInheritByDefault() 
237 
238     /**
239      * Get If true, this mojo can only be directly invoked (eg.
240      * specified directly on the command line).
241      *           
242      */
243     public boolean isRequiresDirectInvocation()
244     {
245         return this.requiresDirectInvocation;
246     } //-- boolean isRequiresDirectInvocation() 
247 
248     /**
249      * Get Whether this mojo requires online mode to operate
250      * normally.
251      */
252     public boolean isRequiresOnline()
253     {
254         return this.requiresOnline;
255     } //-- boolean isRequiresOnline() 
256 
257     /**
258      * Get Whether this mojo requires a project instance in order
259      * to execute.
260      */
261     public boolean isRequiresProject()
262     {
263         return this.requiresProject;
264     } //-- boolean isRequiresProject() 
265 
266     /**
267      * Get Whether this mojo requires a reports section in the POM.
268      */
269     public boolean isRequiresReports()
270     {
271         return this.requiresReports;
272     } //-- boolean isRequiresReports() 
273 
274     /**
275      * Method removeComponent
276      * 
277      * @param component
278      */
279     public void removeComponent(Component component)
280     {
281         if ( !(component instanceof Component) )
282         {
283             throw new ClassCastException( "Mojo.removeComponents(component) parameter must be instanceof " + Component.class.getName() );
284         }
285         getComponents().remove( component );
286     } //-- void removeComponent(Component) 
287 
288     /**
289      * Method removeParameter
290      * 
291      * @param parameter
292      */
293     public void removeParameter(Parameter parameter)
294     {
295         if ( !(parameter instanceof Parameter) )
296         {
297             throw new ClassCastException( "Mojo.removeParameters(parameter) parameter must be instanceof " + Parameter.class.getName() );
298         }
299         getParameters().remove( parameter );
300     } //-- void removeParameter(Parameter) 
301 
302     /**
303      * Set Whether this mojo operates as an aggregator when the
304      * reactor is run. That is, only runs once.
305      *           
306      * 
307      * @param aggregator
308      */
309     public void setAggregator(boolean aggregator)
310     {
311         this.aggregator = aggregator;
312     } //-- void setAggregator(boolean) 
313 
314     /**
315      * Set The target/method within the script to call when this
316      * mojo executes.
317      * 
318      * @param call
319      */
320     public void setCall(String call)
321     {
322         this.call = call;
323     } //-- void setCall(String) 
324 
325     /**
326      * Set List of plexus components required by this mojo.
327      * 
328      * @param components
329      */
330     public void setComponents(java.util.List components)
331     {
332         this.components = components;
333     } //-- void setComponents(java.util.List) 
334 
335     /**
336      * Set A deprecation message for this mojo parameter.
337      * 
338      * @param deprecation
339      */
340     public void setDeprecation(String deprecation)
341     {
342         this.deprecation = deprecation;
343     } //-- void setDeprecation(String) 
344 
345     /**
346      * Set The description for this parameter.
347      * 
348      * @param description
349      */
350     public void setDescription(String description)
351     {
352         this.description = description;
353     } //-- void setDescription(String) 
354 
355     /**
356      * Set Information about a sub-execution of the Maven lifecycle
357      * which should be processed.
358      * 
359      * @param execution
360      */
361     public void setExecution(LifecycleExecution execution)
362     {
363         this.execution = execution;
364     } //-- void setExecution(LifecycleExecution) 
365 
366     /**
367      * Set The name of the goal used to invoke this mojo.
368      * 
369      * @param goal
370      */
371     public void setGoal(String goal)
372     {
373         this.goal = goal;
374     } //-- void setGoal(String) 
375 
376     /**
377      * Set Whether this mojo's configuration should propagate down
378      * the POM inheritance chain by default.
379      *           
380      * 
381      * @param inheritByDefault
382      */
383     public void setInheritByDefault(boolean inheritByDefault)
384     {
385         this.inheritByDefault = inheritByDefault;
386     } //-- void setInheritByDefault(boolean) 
387 
388     /**
389      * Set List of parameters used by this mojo.
390      * 
391      * @param parameters
392      */
393     public void setParameters(java.util.List parameters)
394     {
395         this.parameters = parameters;
396     } //-- void setParameters(java.util.List) 
397 
398     /**
399      * Set The phase to which this mojo should be bound by default.
400      * 
401      * @param phase
402      */
403     public void setPhase(String phase)
404     {
405         this.phase = phase;
406     } //-- void setPhase(String) 
407 
408     /**
409      * Set The scope of dependencies that this mojo requires to
410      * have resolved.
411      * 
412      * @param requiresDependencyResolution
413      */
414     public void setRequiresDependencyResolution(String requiresDependencyResolution)
415     {
416         this.requiresDependencyResolution = requiresDependencyResolution;
417     } //-- void setRequiresDependencyResolution(String) 
418 
419     /**
420      * Set If true, this mojo can only be directly invoked (eg.
421      * specified directly on the command line).
422      *           
423      * 
424      * @param requiresDirectInvocation
425      */
426     public void setRequiresDirectInvocation(boolean requiresDirectInvocation)
427     {
428         this.requiresDirectInvocation = requiresDirectInvocation;
429     } //-- void setRequiresDirectInvocation(boolean) 
430 
431     /**
432      * Set Whether this mojo requires online mode to operate
433      * normally.
434      * 
435      * @param requiresOnline
436      */
437     public void setRequiresOnline(boolean requiresOnline)
438     {
439         this.requiresOnline = requiresOnline;
440     } //-- void setRequiresOnline(boolean) 
441 
442     /**
443      * Set Whether this mojo requires a project instance in order
444      * to execute.
445      * 
446      * @param requiresProject
447      */
448     public void setRequiresProject(boolean requiresProject)
449     {
450         this.requiresProject = requiresProject;
451     } //-- void setRequiresProject(boolean) 
452 
453     /**
454      * Set Whether this mojo requires a reports section in the POM.
455      * 
456      * @param requiresReports
457      */
458     public void setRequiresReports(boolean requiresReports)
459     {
460         this.requiresReports = requiresReports;
461     } //-- void setRequiresReports(boolean) 
462 
463 
464     private String modelEncoding = "UTF-8";
465 
466     public void setModelEncoding( String modelEncoding )
467     {
468         this.modelEncoding = modelEncoding;
469     }
470 
471     public String getModelEncoding()
472     {
473         return modelEncoding;
474     }}