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