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