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