Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
Dependency |
|
| 0.0;0 |
1 | /* | |
2 | =================== DO NOT EDIT THIS FILE ==================== | |
3 | Generated by Modello 1.0.1 on 2009-09-09 03:04:48, | |
4 | any modifications will be overwritten. | |
5 | ============================================================== | |
6 | */ | |
7 | ||
8 | package org.apache.maven.model; | |
9 | ||
10 | /** | |
11 | * | |
12 | * | |
13 | * The <code><dependency></code> element contains | |
14 | * information about a dependency | |
15 | * of the project. | |
16 | * | |
17 | * | |
18 | * | |
19 | * @version $Revision$ $Date$ | |
20 | */ | |
21 | 6 | public class Dependency |
22 | implements java.io.Serializable | |
23 | { | |
24 | ||
25 | //--------------------------/ | |
26 | //- Class/Member Variables -/ | |
27 | //--------------------------/ | |
28 | ||
29 | /** | |
30 | * | |
31 | * | |
32 | * The project group that produced the dependency, | |
33 | * e.g. | |
34 | * <code>org.apache.maven</code>. | |
35 | * | |
36 | * | |
37 | */ | |
38 | private String groupId; | |
39 | ||
40 | /** | |
41 | * | |
42 | * | |
43 | * The unique id for an artifact produced by the | |
44 | * project group, e.g. | |
45 | * <code>maven-artifact</code>. | |
46 | * | |
47 | * | |
48 | */ | |
49 | private String artifactId; | |
50 | ||
51 | /** | |
52 | * | |
53 | * | |
54 | * The version of the dependency, e.g. | |
55 | * <code>3.2.1</code>. In Maven 2, this can also be | |
56 | * specified as a range of versions. | |
57 | * | |
58 | * | |
59 | */ | |
60 | private String version; | |
61 | ||
62 | /** | |
63 | * | |
64 | * | |
65 | * The type of dependency. This defaults to | |
66 | * <code>jar</code>. While it | |
67 | * usually represents the extension on the filename | |
68 | * of the dependency, | |
69 | * that is not always the case. A type can be | |
70 | * mapped to a different | |
71 | * extension and a classifier. | |
72 | * The type often correspongs to the packaging | |
73 | * used, though this is also | |
74 | * not always the case. | |
75 | * Some examples are <code>jar</code>, | |
76 | * <code>war</code>, <code>ejb-client</code> | |
77 | * and <code>test-jar</code>. | |
78 | * New types can be defined by plugins that set | |
79 | * <code>extensions</code> to <code>true</code>, so | |
80 | * this is not a complete list. | |
81 | * | |
82 | * | |
83 | */ | |
84 | 6 | private String type = "jar"; |
85 | ||
86 | /** | |
87 | * | |
88 | * | |
89 | * The classifier of the dependency. This allows | |
90 | * distinguishing two artifacts | |
91 | * that belong to the same POM but were built | |
92 | * differently, and is appended to | |
93 | * the filename after the version. For example, | |
94 | * <code>jdk14</code> and <code>jdk15</code>. | |
95 | * | |
96 | * | |
97 | */ | |
98 | private String classifier; | |
99 | ||
100 | /** | |
101 | * | |
102 | * | |
103 | * The scope of the dependency - | |
104 | * <code>compile</code>, <code>runtime</code>, | |
105 | * <code>test</code>, <code>system</code>, and | |
106 | * <code>provided</code>. Used to | |
107 | * calculate the various classpaths used for | |
108 | * compilation, testing, and so on. | |
109 | * It also assists in determining which artifacts | |
110 | * to include in a distribution of | |
111 | * this project. For more information, see | |
112 | * <a | |
113 | * href="http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html">the | |
114 | * dependency mechanism</a>. | |
115 | * | |
116 | * | |
117 | */ | |
118 | private String scope; | |
119 | ||
120 | /** | |
121 | * | |
122 | * | |
123 | * FOR SYSTEM SCOPE ONLY. Note that use of this | |
124 | * property is <b>discouraged</b> | |
125 | * and may be replaced in later versions. This | |
126 | * specifies the path on the filesystem | |
127 | * for this dependency. | |
128 | * Requires an absolute path for the value, not | |
129 | * relative. | |
130 | * Use a property that gives the machine specific | |
131 | * absolute path, | |
132 | * e.g. <code>${java.home}</code>. | |
133 | * | |
134 | * | |
135 | */ | |
136 | private String systemPath; | |
137 | ||
138 | /** | |
139 | * Field exclusions. | |
140 | */ | |
141 | private java.util.List<Exclusion> exclusions; | |
142 | ||
143 | /** | |
144 | * Indicates the dependency is optional for use of this | |
145 | * library. While the | |
146 | * version of the dependency will be taken into | |
147 | * account for dependency calculation if the | |
148 | * library is used elsewhere, it will not be passed | |
149 | * on transitively. | |
150 | */ | |
151 | 6 | private boolean optional = false; |
152 | ||
153 | ||
154 | //-----------/ | |
155 | //- Methods -/ | |
156 | //-----------/ | |
157 | ||
158 | /** | |
159 | * Method addExclusion. | |
160 | * | |
161 | * @param exclusion | |
162 | */ | |
163 | public void addExclusion( Exclusion exclusion ) | |
164 | { | |
165 | 0 | if ( !(exclusion instanceof Exclusion) ) |
166 | { | |
167 | 0 | throw new ClassCastException( "Dependency.addExclusions(exclusion) parameter must be instanceof " + Exclusion.class.getName() ); |
168 | } | |
169 | 0 | getExclusions().add( exclusion ); |
170 | 0 | } //-- void addExclusion( Exclusion ) |
171 | ||
172 | /** | |
173 | * Get the unique id for an artifact produced by the project | |
174 | * group, e.g. | |
175 | * <code>maven-artifact</code>. | |
176 | * | |
177 | * @return String | |
178 | */ | |
179 | public String getArtifactId() | |
180 | { | |
181 | 0 | return this.artifactId; |
182 | } //-- String getArtifactId() | |
183 | ||
184 | /** | |
185 | * Get the classifier of the dependency. This allows | |
186 | * distinguishing two artifacts | |
187 | * that belong to the same POM but were built | |
188 | * differently, and is appended to | |
189 | * the filename after the version. For example, | |
190 | * <code>jdk14</code> and <code>jdk15</code>. | |
191 | * | |
192 | * @return String | |
193 | */ | |
194 | public String getClassifier() | |
195 | { | |
196 | 0 | return this.classifier; |
197 | } //-- String getClassifier() | |
198 | ||
199 | /** | |
200 | * Method getExclusions. | |
201 | * | |
202 | * @return List | |
203 | */ | |
204 | public java.util.List<Exclusion> getExclusions() | |
205 | { | |
206 | 0 | if ( this.exclusions == null ) |
207 | { | |
208 | 0 | this.exclusions = new java.util.ArrayList<Exclusion>(); |
209 | } | |
210 | ||
211 | 0 | return this.exclusions; |
212 | } //-- java.util.List<Exclusion> getExclusions() | |
213 | ||
214 | /** | |
215 | * Get the project group that produced the dependency, e.g. | |
216 | * <code>org.apache.maven</code>. | |
217 | * | |
218 | * @return String | |
219 | */ | |
220 | public String getGroupId() | |
221 | { | |
222 | 0 | return this.groupId; |
223 | } //-- String getGroupId() | |
224 | ||
225 | /** | |
226 | * Get the scope of the dependency - <code>compile</code>, | |
227 | * <code>runtime</code>, | |
228 | * <code>test</code>, <code>system</code>, and | |
229 | * <code>provided</code>. Used to | |
230 | * calculate the various classpaths used for | |
231 | * compilation, testing, and so on. | |
232 | * It also assists in determining which artifacts | |
233 | * to include in a distribution of | |
234 | * this project. For more information, see | |
235 | * <a | |
236 | * href="http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html">the | |
237 | * dependency mechanism</a>. | |
238 | * | |
239 | * @return String | |
240 | */ | |
241 | public String getScope() | |
242 | { | |
243 | 0 | return this.scope; |
244 | } //-- String getScope() | |
245 | ||
246 | /** | |
247 | * Get fOR SYSTEM SCOPE ONLY. Note that use of this property is | |
248 | * <b>discouraged</b> | |
249 | * and may be replaced in later versions. This | |
250 | * specifies the path on the filesystem | |
251 | * for this dependency. | |
252 | * Requires an absolute path for the value, not | |
253 | * relative. | |
254 | * Use a property that gives the machine specific | |
255 | * absolute path, | |
256 | * e.g. <code>${java.home}</code>. | |
257 | * | |
258 | * @return String | |
259 | */ | |
260 | public String getSystemPath() | |
261 | { | |
262 | 0 | return this.systemPath; |
263 | } //-- String getSystemPath() | |
264 | ||
265 | /** | |
266 | * Get the type of dependency. This defaults to | |
267 | * <code>jar</code>. While it | |
268 | * usually represents the extension on the filename | |
269 | * of the dependency, | |
270 | * that is not always the case. A type can be | |
271 | * mapped to a different | |
272 | * extension and a classifier. | |
273 | * The type often correspongs to the packaging | |
274 | * used, though this is also | |
275 | * not always the case. | |
276 | * Some examples are <code>jar</code>, | |
277 | * <code>war</code>, <code>ejb-client</code> | |
278 | * and <code>test-jar</code>. | |
279 | * New types can be defined by plugins that set | |
280 | * <code>extensions</code> to <code>true</code>, so | |
281 | * this is not a complete list. | |
282 | * | |
283 | * @return String | |
284 | */ | |
285 | public String getType() | |
286 | { | |
287 | 0 | return this.type; |
288 | } //-- String getType() | |
289 | ||
290 | /** | |
291 | * Get the version of the dependency, e.g. <code>3.2.1</code>. | |
292 | * In Maven 2, this can also be | |
293 | * specified as a range of versions. | |
294 | * | |
295 | * @return String | |
296 | */ | |
297 | public String getVersion() | |
298 | { | |
299 | 0 | return this.version; |
300 | } //-- String getVersion() | |
301 | ||
302 | /** | |
303 | * Get indicates the dependency is optional for use of this | |
304 | * library. While the | |
305 | * version of the dependency will be taken into | |
306 | * account for dependency calculation if the | |
307 | * library is used elsewhere, it will not be passed | |
308 | * on transitively. | |
309 | * | |
310 | * @return boolean | |
311 | */ | |
312 | public boolean isOptional() | |
313 | { | |
314 | 0 | return this.optional; |
315 | } //-- boolean isOptional() | |
316 | ||
317 | /** | |
318 | * Method removeExclusion. | |
319 | * | |
320 | * @param exclusion | |
321 | */ | |
322 | public void removeExclusion( Exclusion exclusion ) | |
323 | { | |
324 | 0 | if ( !(exclusion instanceof Exclusion) ) |
325 | { | |
326 | 0 | throw new ClassCastException( "Dependency.removeExclusions(exclusion) parameter must be instanceof " + Exclusion.class.getName() ); |
327 | } | |
328 | 0 | getExclusions().remove( exclusion ); |
329 | 0 | } //-- void removeExclusion( Exclusion ) |
330 | ||
331 | /** | |
332 | * Set the unique id for an artifact produced by the project | |
333 | * group, e.g. | |
334 | * <code>maven-artifact</code>. | |
335 | * | |
336 | * @param artifactId | |
337 | */ | |
338 | public void setArtifactId( String artifactId ) | |
339 | { | |
340 | 0 | this.artifactId = artifactId; |
341 | 0 | } //-- void setArtifactId( String ) |
342 | ||
343 | /** | |
344 | * Set the classifier of the dependency. This allows | |
345 | * distinguishing two artifacts | |
346 | * that belong to the same POM but were built | |
347 | * differently, and is appended to | |
348 | * the filename after the version. For example, | |
349 | * <code>jdk14</code> and <code>jdk15</code>. | |
350 | * | |
351 | * @param classifier | |
352 | */ | |
353 | public void setClassifier( String classifier ) | |
354 | { | |
355 | 0 | this.classifier = classifier; |
356 | 0 | } //-- void setClassifier( String ) |
357 | ||
358 | /** | |
359 | * Set lists a set of artifacts that should be excluded from | |
360 | * this dependency's | |
361 | * artifact list when it comes to calculating | |
362 | * transitive dependencies. | |
363 | * | |
364 | * @param exclusions | |
365 | */ | |
366 | public void setExclusions( java.util.List<Exclusion> exclusions ) | |
367 | { | |
368 | 0 | this.exclusions = exclusions; |
369 | 0 | } //-- void setExclusions( java.util.List ) |
370 | ||
371 | /** | |
372 | * Set the project group that produced the dependency, e.g. | |
373 | * <code>org.apache.maven</code>. | |
374 | * | |
375 | * @param groupId | |
376 | */ | |
377 | public void setGroupId( String groupId ) | |
378 | { | |
379 | 0 | this.groupId = groupId; |
380 | 0 | } //-- void setGroupId( String ) |
381 | ||
382 | /** | |
383 | * Set indicates the dependency is optional for use of this | |
384 | * library. While the | |
385 | * version of the dependency will be taken into | |
386 | * account for dependency calculation if the | |
387 | * library is used elsewhere, it will not be passed | |
388 | * on transitively. | |
389 | * | |
390 | * @param optional | |
391 | */ | |
392 | public void setOptional( boolean optional ) | |
393 | { | |
394 | 0 | this.optional = optional; |
395 | 0 | } //-- void setOptional( boolean ) |
396 | ||
397 | /** | |
398 | * Set the scope of the dependency - <code>compile</code>, | |
399 | * <code>runtime</code>, | |
400 | * <code>test</code>, <code>system</code>, and | |
401 | * <code>provided</code>. Used to | |
402 | * calculate the various classpaths used for | |
403 | * compilation, testing, and so on. | |
404 | * It also assists in determining which artifacts | |
405 | * to include in a distribution of | |
406 | * this project. For more information, see | |
407 | * <a | |
408 | * href="http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html">the | |
409 | * dependency mechanism</a>. | |
410 | * | |
411 | * @param scope | |
412 | */ | |
413 | public void setScope( String scope ) | |
414 | { | |
415 | 0 | this.scope = scope; |
416 | 0 | } //-- void setScope( String ) |
417 | ||
418 | /** | |
419 | * Set fOR SYSTEM SCOPE ONLY. Note that use of this property is | |
420 | * <b>discouraged</b> | |
421 | * and may be replaced in later versions. This | |
422 | * specifies the path on the filesystem | |
423 | * for this dependency. | |
424 | * Requires an absolute path for the value, not | |
425 | * relative. | |
426 | * Use a property that gives the machine specific | |
427 | * absolute path, | |
428 | * e.g. <code>${java.home}</code>. | |
429 | * | |
430 | * @param systemPath | |
431 | */ | |
432 | public void setSystemPath( String systemPath ) | |
433 | { | |
434 | 0 | this.systemPath = systemPath; |
435 | 0 | } //-- void setSystemPath( String ) |
436 | ||
437 | /** | |
438 | * Set the type of dependency. This defaults to | |
439 | * <code>jar</code>. While it | |
440 | * usually represents the extension on the filename | |
441 | * of the dependency, | |
442 | * that is not always the case. A type can be | |
443 | * mapped to a different | |
444 | * extension and a classifier. | |
445 | * The type often correspongs to the packaging | |
446 | * used, though this is also | |
447 | * not always the case. | |
448 | * Some examples are <code>jar</code>, | |
449 | * <code>war</code>, <code>ejb-client</code> | |
450 | * and <code>test-jar</code>. | |
451 | * New types can be defined by plugins that set | |
452 | * <code>extensions</code> to <code>true</code>, so | |
453 | * this is not a complete list. | |
454 | * | |
455 | * @param type | |
456 | */ | |
457 | public void setType( String type ) | |
458 | { | |
459 | 0 | this.type = type; |
460 | 0 | } //-- void setType( String ) |
461 | ||
462 | /** | |
463 | * Set the version of the dependency, e.g. <code>3.2.1</code>. | |
464 | * In Maven 2, this can also be | |
465 | * specified as a range of versions. | |
466 | * | |
467 | * @param version | |
468 | */ | |
469 | public void setVersion( String version ) | |
470 | { | |
471 | 0 | this.version = version; |
472 | 0 | } //-- void setVersion( String ) |
473 | ||
474 | ||
475 | ||
476 | /** | |
477 | * @see java.lang.Object#toString() | |
478 | */ | |
479 | public String toString() | |
480 | { | |
481 | 1 | return "Dependency {groupId=" + groupId + ", artifactId=" + artifactId + ", version=" + version + ", type=" + type + "}"; |
482 | } | |
483 | ||
484 | ||
485 | ||
486 | /** | |
487 | * @return the management key as <code>groupId:artifactId:type</code> | |
488 | */ | |
489 | public String getManagementKey() | |
490 | { | |
491 | 0 | return groupId + ":" + artifactId + ":" + type + ( classifier != null ? ":" + classifier : "" ); |
492 | } | |
493 | ||
494 | ||
495 | } |