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