1
2
3
4
5
6
7
8 package org.apache.maven.model;
9
10
11
12
13
14
15
16
17
18
19
20 @SuppressWarnings( "all" )
21 public class Plugin
22 extends ConfigurationContainer
23 implements java.io.Serializable, java.lang.Cloneable
24 {
25
26
27
28
29
30
31
32
33 private String groupId = "org.apache.maven.plugins";
34
35
36
37
38 private String artifactId;
39
40
41
42
43
44 private String version;
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60 private String extensions;
61
62
63
64
65 private java.util.List<PluginExecution> executions;
66
67
68
69
70 private java.util.List<Dependency> dependencies;
71
72
73
74
75
76
77
78
79 private Object goals;
80
81
82
83
84
85
86
87
88
89
90
91 public void addDependency( Dependency dependency )
92 {
93 getDependencies().add( dependency );
94 }
95
96
97
98
99
100
101 public void addExecution( PluginExecution pluginExecution )
102 {
103 getExecutions().add( pluginExecution );
104 }
105
106
107
108
109
110
111 public Plugin clone()
112 {
113 try
114 {
115 Plugin copy = (Plugin) super.clone();
116
117 if ( this.executions != null )
118 {
119 copy.executions = new java.util.ArrayList<PluginExecution>();
120 for ( PluginExecution item : this.executions )
121 {
122 copy.executions.add( ( (PluginExecution) item).clone() );
123 }
124 }
125
126 if ( this.dependencies != null )
127 {
128 copy.dependencies = new java.util.ArrayList<Dependency>();
129 for ( Dependency item : this.dependencies )
130 {
131 copy.dependencies.add( ( (Dependency) item).clone() );
132 }
133 }
134
135 if ( this.goals != null )
136 {
137 copy.goals = new org.codehaus.plexus.util.xml.Xpp3Dom( (org.codehaus.plexus.util.xml.Xpp3Dom) this.goals );
138 }
139
140 return copy;
141 }
142 catch ( java.lang.Exception ex )
143 {
144 throw (java.lang.RuntimeException) new java.lang.UnsupportedOperationException( getClass().getName()
145 + " does not support clone()" ).initCause( ex );
146 }
147 }
148
149
150
151
152
153
154 public String getArtifactId()
155 {
156 return this.artifactId;
157 }
158
159
160
161
162
163
164 public java.util.List<Dependency> getDependencies()
165 {
166 if ( this.dependencies == null )
167 {
168 this.dependencies = new java.util.ArrayList<Dependency>();
169 }
170
171 return this.dependencies;
172 }
173
174
175
176
177
178
179 public java.util.List<PluginExecution> getExecutions()
180 {
181 if ( this.executions == null )
182 {
183 this.executions = new java.util.ArrayList<PluginExecution>();
184 }
185
186 return this.executions;
187 }
188
189
190
191
192
193
194
195
196
197
198
199
200
201 public String getExtensions()
202 {
203 return this.extensions;
204 }
205
206
207
208
209
210
211 public Object getGoals()
212 {
213 return this.goals;
214 }
215
216
217
218
219
220
221 public String getGroupId()
222 {
223 return this.groupId;
224 }
225
226
227
228
229
230
231
232 public String getVersion()
233 {
234 return this.version;
235 }
236
237
238
239
240
241
242 public void removeDependency( Dependency dependency )
243 {
244 getDependencies().remove( dependency );
245 }
246
247
248
249
250
251
252 public void removeExecution( PluginExecution pluginExecution )
253 {
254 getExecutions().remove( pluginExecution );
255 }
256
257
258
259
260
261
262 public void setArtifactId( String artifactId )
263 {
264 this.artifactId = artifactId;
265 }
266
267
268
269
270
271
272
273
274 public void setDependencies( java.util.List<Dependency> dependencies )
275 {
276 this.dependencies = dependencies;
277 }
278
279
280
281
282
283
284
285
286
287 public void setExecutions( java.util.List<PluginExecution> executions )
288 {
289 this.executions = executions;
290 }
291
292
293
294
295
296
297
298
299
300
301
302
303
304 public void setExtensions( String extensions )
305 {
306 this.extensions = extensions;
307 }
308
309
310
311
312
313
314 public void setGoals( Object goals )
315 {
316 this.goals = goals;
317 }
318
319
320
321
322
323
324 public void setGroupId( String groupId )
325 {
326 this.groupId = groupId;
327 }
328
329
330
331
332
333
334
335 public void setVersion( String version )
336 {
337 this.version = version;
338 }
339
340
341
342 public boolean isExtensions()
343 {
344 return ( extensions != null ) ? Boolean.parseBoolean( extensions ) : false;
345 }
346
347 public void setExtensions( boolean extensions )
348 {
349 this.extensions = String.valueOf( extensions );
350 }
351
352 private java.util.Map<String, PluginExecution> executionMap = null;
353
354
355
356
357 public void flushExecutionMap()
358 {
359 this.executionMap = null;
360 }
361
362
363
364
365
366 public java.util.Map<String, PluginExecution> getExecutionsAsMap()
367 {
368 if ( executionMap == null )
369 {
370 executionMap = new java.util.LinkedHashMap<String, PluginExecution>();
371 if ( getExecutions() != null )
372 {
373 for ( java.util.Iterator<PluginExecution> i = getExecutions().iterator(); i.hasNext(); )
374 {
375 PluginExecution exec = (PluginExecution) i.next();
376
377 if ( executionMap.containsKey( exec.getId() ) )
378 {
379 throw new IllegalStateException( "You cannot have two plugin executions with the same (or missing) <id/> elements.\nOffending execution\n\nId: \'" + exec.getId() + "\'\nPlugin:\'" + getKey() + "\'\n\n" );
380 }
381
382 executionMap.put( exec.getId(), exec );
383 }
384 }
385 }
386
387 return executionMap;
388 }
389
390
391
392
393
394
395 public String getId()
396 {
397 StringBuilder id = new StringBuilder( 128 );
398
399 id.append( ( getGroupId() == null ) ? "[unknown-group-id]" : getGroupId() );
400 id.append( ":" );
401 id.append( ( getArtifactId() == null ) ? "[unknown-artifact-id]" : getArtifactId() );
402 id.append( ":" );
403 id.append( ( getVersion() == null ) ? "[unknown-version]" : getVersion() );
404
405 return id.toString();
406 }
407
408
409 private String key = null;
410
411
412
413 public String getKey()
414 {
415 if ( key == null )
416 {
417 key = constructKey( groupId, artifactId );
418 }
419 return key;
420 }
421
422
423
424
425
426
427 public static String constructKey( String groupId, String artifactId )
428 {
429 return groupId + ":" + artifactId;
430 }
431
432
433
434
435 public boolean equals( Object other )
436 {
437 if ( other instanceof Plugin )
438 {
439 Plugin otherPlugin = (Plugin) other;
440
441 return getKey().equals( otherPlugin.getKey() );
442 }
443
444 return false;
445 }
446
447
448
449
450 public int hashCode()
451 {
452 return getKey().hashCode();
453 }
454
455
456
457
458 public String toString()
459 {
460 return "Plugin [" + getKey() + "]";
461 }
462
463
464 }