View Javadoc
1   // =================== DO NOT EDIT THIS FILE ====================
2   // Generated by Modello 1.8.1,
3   // any modifications will be overwritten.
4   // ==============================================================
5   
6   package org.apache.maven.model;
7   
8   /**
9    * 
10   *         
11   *         The <code>&lt;dependency&gt;</code> element contains
12   * information about a dependency
13   *         of the project.
14   *         
15   *       
16   * 
17   * @version $Revision$ $Date$
18   */
19  @SuppressWarnings( "all" )
20  public class Dependency
21      implements java.io.Serializable, java.lang.Cloneable, org.apache.maven.model.InputLocationTracker
22  {
23  
24        //--------------------------/
25       //- Class/Member Variables -/
26      //--------------------------/
27  
28      /**
29       * 
30       *             
31       *             The project group that produced the dependency,
32       * e.g.
33       *             <code>org.apache.maven</code>.
34       *             
35       *           
36       */
37      private String groupId;
38  
39      /**
40       * 
41       *             
42       *             The unique id for an artifact produced by the
43       * project group, e.g.
44       *             <code>maven-artifact</code>.
45       *             
46       *           
47       */
48      private String artifactId;
49  
50      /**
51       * 
52       *             
53       *             The version of the dependency, e.g.
54       * <code>3.2.1</code>. In Maven 2, this can also be
55       *             specified as a range of versions.
56       *             
57       *           
58       */
59      private String version;
60  
61      /**
62       * 
63       *             
64       *             The type of dependency. While it
65       *             usually represents the extension on the filename
66       * of the dependency,
67       *             that is not always the case. A type can be
68       * mapped to a different
69       *             extension and a classifier.
70       *             The type often corresponds to the packaging
71       * used, though this is also
72       *             not always the case.
73       *             Some examples are <code>jar</code>,
74       * <code>war</code>, <code>ejb-client</code>
75       *             and <code>test-jar</code>: see <a
76       * href="../maven-core/artifact-handlers.html">default
77       *             artifact handlers</a> for a list.
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      private String type = "jar";
85  
86      /**
87       * 
88       *             
89       *             The classifier of the dependency. It is appended
90       * to
91       *             the filename after the version. This allows:
92       *             <ul>
93       *             <li>refering to attached artifact, for example
94       * <code>sources</code> and <code>javadoc</code>:
95       *             see <a
96       * href="../maven-core/artifact-handlers.html">default artifact
97       * handlers</a> for a list,</li>
98       *             <li>distinguishing two artifacts
99       *             that belong to the same POM but were built
100      * differently.
101      *             For example, <code>jdk14</code> and
102      * <code>jdk15</code>.</li>
103      *             </ul>
104      *             
105      *           
106      */
107     private String classifier;
108 
109     /**
110      * 
111      *             
112      *             The scope of the dependency -
113      * <code>compile</code>, <code>runtime</code>,
114      *             <code>test</code>, <code>system</code>, and
115      * <code>provided</code>. Used to
116      *             calculate the various classpaths used for
117      * compilation, testing, and so on.
118      *             It also assists in determining which artifacts
119      * to include in a distribution of
120      *             this project. For more information, see
121      *             <a
122      * href="http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html">the
123      *             dependency mechanism</a>.
124      *             
125      *           
126      */
127     private String scope;
128 
129     /**
130      * 
131      *             
132      *             FOR SYSTEM SCOPE ONLY. Note that use of this
133      * property is <b>discouraged</b>
134      *             and may be replaced in later versions. This
135      * specifies the path on the filesystem
136      *             for this dependency.
137      *             Requires an absolute path for the value, not
138      * relative.
139      *             Use a property that gives the machine specific
140      * absolute path,
141      *             e.g. <code>${java.home}</code>.
142      *             
143      *           
144      */
145     private String systemPath;
146 
147     /**
148      * Field exclusions.
149      */
150     private java.util.List<Exclusion> exclusions;
151 
152     /**
153      * 
154      *             
155      *             Indicates the dependency is optional for use of
156      * this library. While the
157      *             version of the dependency will be taken into
158      * account for dependency calculation if the
159      *             library is used elsewhere, it will not be passed
160      * on transitively. Note: While the type
161      *             of this field is <code>String</code> for
162      * technical reasons, the semantic type is actually
163      *             <code>Boolean</code>. Default value is
164      * <code>false</code>.
165      *             
166      *           
167      */
168     private String optional;
169 
170     /**
171      * Field locations.
172      */
173     private java.util.Map<Object, InputLocation> locations;
174 
175 
176       //-----------/
177      //- Methods -/
178     //-----------/
179 
180     /**
181      * Method addExclusion.
182      * 
183      * @param exclusion
184      */
185     public void addExclusion( Exclusion exclusion )
186     {
187         getExclusions().add( exclusion );
188     } //-- void addExclusion( Exclusion )
189 
190     /**
191      * Method clone.
192      * 
193      * @return Dependency
194      */
195     public Dependency clone()
196     {
197         try
198         {
199             Dependency copy = (Dependency) super.clone();
200 
201             if ( this.exclusions != null )
202             {
203                 copy.exclusions = new java.util.ArrayList<Exclusion>();
204                 for ( Exclusion item : this.exclusions )
205                 {
206                     copy.exclusions.add( ( (Exclusion) item).clone() );
207                 }
208             }
209 
210             if ( copy.locations != null )
211             {
212                 copy.locations = new java.util.LinkedHashMap( copy.locations );
213             }
214 
215             return copy;
216         }
217         catch ( java.lang.Exception ex )
218         {
219             throw (java.lang.RuntimeException) new java.lang.UnsupportedOperationException( getClass().getName()
220                 + " does not support clone()" ).initCause( ex );
221         }
222     } //-- Dependency clone()
223 
224     /**
225      * Get the unique id for an artifact produced by the project
226      * group, e.g.
227      *             <code>maven-artifact</code>.
228      * 
229      * @return String
230      */
231     public String getArtifactId()
232     {
233         return this.artifactId;
234     } //-- String getArtifactId()
235 
236     /**
237      * Get the classifier of the dependency. It is appended to
238      *             the filename after the version. This allows:
239      *             <ul>
240      *             <li>refering to attached artifact, for example
241      * <code>sources</code> and <code>javadoc</code>:
242      *             see <a
243      * href="../maven-core/artifact-handlers.html">default artifact
244      * handlers</a> for a list,</li>
245      *             <li>distinguishing two artifacts
246      *             that belong to the same POM but were built
247      * differently.
248      *             For example, <code>jdk14</code> and
249      * <code>jdk15</code>.</li>
250      *             </ul>
251      * 
252      * @return String
253      */
254     public String getClassifier()
255     {
256         return this.classifier;
257     } //-- String getClassifier()
258 
259     /**
260      * Method getExclusions.
261      * 
262      * @return List
263      */
264     public java.util.List<Exclusion> getExclusions()
265     {
266         if ( this.exclusions == null )
267         {
268             this.exclusions = new java.util.ArrayList<Exclusion>();
269         }
270 
271         return this.exclusions;
272     } //-- java.util.List<Exclusion> getExclusions()
273 
274     /**
275      * Get the project group that produced the dependency, e.g.
276      *             <code>org.apache.maven</code>.
277      * 
278      * @return String
279      */
280     public String getGroupId()
281     {
282         return this.groupId;
283     } //-- String getGroupId()
284 
285     /**
286      * 
287      * 
288      * @param key
289      * @return InputLocation
290      */
291     public InputLocation getLocation( Object key )
292     {
293         return ( locations != null ) ? locations.get( key ) : null;
294     } //-- InputLocation getLocation( Object )
295 
296     /**
297      * Get indicates the dependency is optional for use of this
298      * library. While the
299      *             version of the dependency will be taken into
300      * account for dependency calculation if the
301      *             library is used elsewhere, it will not be passed
302      * on transitively. Note: While the type
303      *             of this field is <code>String</code> for
304      * technical reasons, the semantic type is actually
305      *             <code>Boolean</code>. Default value is
306      * <code>false</code>.
307      * 
308      * @return String
309      */
310     public String getOptional()
311     {
312         return this.optional;
313     } //-- String getOptional()
314 
315     /**
316      * Get the scope of the dependency - <code>compile</code>,
317      * <code>runtime</code>,
318      *             <code>test</code>, <code>system</code>, and
319      * <code>provided</code>. Used to
320      *             calculate the various classpaths used for
321      * compilation, testing, and so on.
322      *             It also assists in determining which artifacts
323      * to include in a distribution of
324      *             this project. For more information, see
325      *             <a
326      * href="http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html">the
327      *             dependency mechanism</a>.
328      * 
329      * @return String
330      */
331     public String getScope()
332     {
333         return this.scope;
334     } //-- String getScope()
335 
336     /**
337      * Get fOR SYSTEM SCOPE ONLY. Note that use of this property is
338      * <b>discouraged</b>
339      *             and may be replaced in later versions. This
340      * specifies the path on the filesystem
341      *             for this dependency.
342      *             Requires an absolute path for the value, not
343      * relative.
344      *             Use a property that gives the machine specific
345      * absolute path,
346      *             e.g. <code>${java.home}</code>.
347      * 
348      * @return String
349      */
350     public String getSystemPath()
351     {
352         return this.systemPath;
353     } //-- String getSystemPath()
354 
355     /**
356      * Get the type of dependency. While it
357      *             usually represents the extension on the filename
358      * of the dependency,
359      *             that is not always the case. A type can be
360      * mapped to a different
361      *             extension and a classifier.
362      *             The type often corresponds to the packaging
363      * used, though this is also
364      *             not always the case.
365      *             Some examples are <code>jar</code>,
366      * <code>war</code>, <code>ejb-client</code>
367      *             and <code>test-jar</code>: see <a
368      * href="../maven-core/artifact-handlers.html">default
369      *             artifact handlers</a> for a list.
370      *             New types can be defined by plugins that set
371      *             <code>extensions</code> to <code>true</code>, so
372      * this is not a complete list.
373      * 
374      * @return String
375      */
376     public String getType()
377     {
378         return this.type;
379     } //-- String getType()
380 
381     /**
382      * Get the version of the dependency, e.g. <code>3.2.1</code>.
383      * In Maven 2, this can also be
384      *             specified as a range of versions.
385      * 
386      * @return String
387      */
388     public String getVersion()
389     {
390         return this.version;
391     } //-- String getVersion()
392 
393     /**
394      * Method removeExclusion.
395      * 
396      * @param exclusion
397      */
398     public void removeExclusion( Exclusion exclusion )
399     {
400         getExclusions().remove( exclusion );
401     } //-- void removeExclusion( Exclusion )
402 
403     /**
404      * Set the unique id for an artifact produced by the project
405      * group, e.g.
406      *             <code>maven-artifact</code>.
407      * 
408      * @param artifactId
409      */
410     public void setArtifactId( String artifactId )
411     {
412         this.artifactId = artifactId;
413     } //-- void setArtifactId( String )
414 
415     /**
416      * Set the classifier of the dependency. It is appended to
417      *             the filename after the version. This allows:
418      *             <ul>
419      *             <li>refering to attached artifact, for example
420      * <code>sources</code> and <code>javadoc</code>:
421      *             see <a
422      * href="../maven-core/artifact-handlers.html">default artifact
423      * handlers</a> for a list,</li>
424      *             <li>distinguishing two artifacts
425      *             that belong to the same POM but were built
426      * differently.
427      *             For example, <code>jdk14</code> and
428      * <code>jdk15</code>.</li>
429      *             </ul>
430      * 
431      * @param classifier
432      */
433     public void setClassifier( String classifier )
434     {
435         this.classifier = classifier;
436     } //-- void setClassifier( String )
437 
438     /**
439      * Set lists a set of artifacts that should be excluded from
440      * this dependency's
441      *             artifact list when it comes to calculating
442      * transitive dependencies.
443      * 
444      * @param exclusions
445      */
446     public void setExclusions( java.util.List<Exclusion> exclusions )
447     {
448         this.exclusions = exclusions;
449     } //-- void setExclusions( java.util.List )
450 
451     /**
452      * Set the project group that produced the dependency, e.g.
453      *             <code>org.apache.maven</code>.
454      * 
455      * @param groupId
456      */
457     public void setGroupId( String groupId )
458     {
459         this.groupId = groupId;
460     } //-- void setGroupId( String )
461 
462     /**
463      * 
464      * 
465      * @param key
466      * @param location
467      */
468     public void setLocation( Object key, InputLocation location )
469     {
470         if ( location != null )
471         {
472             if ( this.locations == null )
473             {
474                 this.locations = new java.util.LinkedHashMap<Object, InputLocation>();
475             }
476             this.locations.put( key, location );
477         }
478     } //-- void setLocation( Object, InputLocation )
479 
480     /**
481      * Set indicates the dependency is optional for use of this
482      * library. While the
483      *             version of the dependency will be taken into
484      * account for dependency calculation if the
485      *             library is used elsewhere, it will not be passed
486      * on transitively. Note: While the type
487      *             of this field is <code>String</code> for
488      * technical reasons, the semantic type is actually
489      *             <code>Boolean</code>. Default value is
490      * <code>false</code>.
491      * 
492      * @param optional
493      */
494     public void setOptional( String optional )
495     {
496         this.optional = optional;
497     } //-- void setOptional( String )
498 
499     /**
500      * Set the scope of the dependency - <code>compile</code>,
501      * <code>runtime</code>,
502      *             <code>test</code>, <code>system</code>, and
503      * <code>provided</code>. Used to
504      *             calculate the various classpaths used for
505      * compilation, testing, and so on.
506      *             It also assists in determining which artifacts
507      * to include in a distribution of
508      *             this project. For more information, see
509      *             <a
510      * href="http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html">the
511      *             dependency mechanism</a>.
512      * 
513      * @param scope
514      */
515     public void setScope( String scope )
516     {
517         this.scope = scope;
518     } //-- void setScope( String )
519 
520     /**
521      * Set fOR SYSTEM SCOPE ONLY. Note that use of this property is
522      * <b>discouraged</b>
523      *             and may be replaced in later versions. This
524      * specifies the path on the filesystem
525      *             for this dependency.
526      *             Requires an absolute path for the value, not
527      * relative.
528      *             Use a property that gives the machine specific
529      * absolute path,
530      *             e.g. <code>${java.home}</code>.
531      * 
532      * @param systemPath
533      */
534     public void setSystemPath( String systemPath )
535     {
536         this.systemPath = systemPath;
537     } //-- void setSystemPath( String )
538 
539     /**
540      * Set the type of dependency. While it
541      *             usually represents the extension on the filename
542      * of the dependency,
543      *             that is not always the case. A type can be
544      * mapped to a different
545      *             extension and a classifier.
546      *             The type often corresponds to the packaging
547      * used, though this is also
548      *             not always the case.
549      *             Some examples are <code>jar</code>,
550      * <code>war</code>, <code>ejb-client</code>
551      *             and <code>test-jar</code>: see <a
552      * href="../maven-core/artifact-handlers.html">default
553      *             artifact handlers</a> for a list.
554      *             New types can be defined by plugins that set
555      *             <code>extensions</code> to <code>true</code>, so
556      * this is not a complete list.
557      * 
558      * @param type
559      */
560     public void setType( String type )
561     {
562         this.type = type;
563     } //-- void setType( String )
564 
565     /**
566      * Set the version of the dependency, e.g. <code>3.2.1</code>.
567      * In Maven 2, this can also be
568      *             specified as a range of versions.
569      * 
570      * @param version
571      */
572     public void setVersion( String version )
573     {
574         this.version = version;
575     } //-- void setVersion( String )
576 
577     
578             
579     public boolean isOptional()
580     {
581         return ( optional != null ) ? Boolean.parseBoolean( optional ) : false;
582     }
583 
584     public void setOptional( boolean optional )
585     {
586         this.optional = String.valueOf( optional );
587     }
588 
589     /**
590      * @see java.lang.Object#toString()
591      */
592     public String toString()
593     {
594         return "Dependency {groupId=" + groupId + ", artifactId=" + artifactId + ", version=" + version + ", type=" + type + "}";
595     }
596             
597           
598     
599             
600     /**
601      * @return the management key as <code>groupId:artifactId:type</code>
602      */
603     public String getManagementKey()
604     {
605         return groupId + ":" + artifactId + ":" + type + ( classifier != null ? ":" + classifier : "" );
606     }
607             
608           
609 }