001 /* 002 =================== DO NOT EDIT THIS FILE ==================== 003 Generated by Modello 1.4.1 on 2013-02-24 03:31:02, 004 any modifications will be overwritten. 005 ============================================================== 006 */ 007 008 package org.apache.maven.model; 009 010 /** 011 * 012 * 013 * The <code><dependency></code> element contains 014 * information about a dependency 015 * of the project. 016 * 017 * 018 * 019 * @version $Revision$ $Date$ 020 */ 021 @SuppressWarnings( "all" ) 022 public class Dependency 023 implements java.io.Serializable, java.lang.Cloneable, org.apache.maven.model.InputLocationTracker 024 { 025 026 //--------------------------/ 027 //- Class/Member Variables -/ 028 //--------------------------/ 029 030 /** 031 * 032 * 033 * The project group that produced the dependency, 034 * e.g. 035 * <code>org.apache.maven</code>. 036 * 037 * 038 */ 039 private String groupId; 040 041 /** 042 * 043 * 044 * The unique id for an artifact produced by the 045 * project group, e.g. 046 * <code>maven-artifact</code>. 047 * 048 * 049 */ 050 private String artifactId; 051 052 /** 053 * 054 * 055 * The version of the dependency, e.g. 056 * <code>3.2.1</code>. In Maven 2, this can also be 057 * specified as a range of versions. 058 * 059 * 060 */ 061 private String version; 062 063 /** 064 * 065 * 066 * The type of dependency. This defaults to 067 * <code>jar</code>. While it 068 * usually represents the extension on the filename 069 * of the dependency, 070 * that is not always the case. A type can be 071 * mapped to a different 072 * extension and a classifier. 073 * The type often correspongs to the packaging 074 * used, though this is also 075 * not always the case. 076 * Some examples are <code>jar</code>, 077 * <code>war</code>, <code>ejb-client</code> 078 * and <code>test-jar</code>. 079 * New types can be defined by plugins that set 080 * <code>extensions</code> to <code>true</code>, so 081 * this is not a complete list. 082 * 083 * 084 */ 085 private String type = "jar"; 086 087 /** 088 * 089 * 090 * The classifier of the dependency. This allows 091 * distinguishing two artifacts 092 * that belong to the same POM but were built 093 * differently, and is appended to 094 * the filename after the version. For example, 095 * <code>jdk14</code> and <code>jdk15</code>. 096 * 097 * 098 */ 099 private String classifier; 100 101 /** 102 * 103 * 104 * The scope of the dependency - 105 * <code>compile</code>, <code>runtime</code>, 106 * <code>test</code>, <code>system</code>, and 107 * <code>provided</code>. Used to 108 * calculate the various classpaths used for 109 * compilation, testing, and so on. 110 * It also assists in determining which artifacts 111 * to include in a distribution of 112 * this project. For more information, see 113 * <a 114 * href="http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html">the 115 * dependency mechanism</a>. 116 * 117 * 118 */ 119 private String scope; 120 121 /** 122 * 123 * 124 * FOR SYSTEM SCOPE ONLY. Note that use of this 125 * property is <b>discouraged</b> 126 * and may be replaced in later versions. This 127 * specifies the path on the filesystem 128 * for this dependency. 129 * Requires an absolute path for the value, not 130 * relative. 131 * Use a property that gives the machine specific 132 * absolute path, 133 * e.g. <code>${java.home}</code>. 134 * 135 * 136 */ 137 private String systemPath; 138 139 /** 140 * Field exclusions. 141 */ 142 private java.util.List<Exclusion> exclusions; 143 144 /** 145 * 146 * 147 * Indicates the dependency is optional for use of 148 * this library. While the 149 * version of the dependency will be taken into 150 * account for dependency calculation if the 151 * library is used elsewhere, it will not be passed 152 * on transitively. Note: While the type 153 * of this field is <code>String</code> for 154 * technical reasons, the semantic type is actually 155 * <code>Boolean</code>. Default value is 156 * <code>false</code>. 157 * 158 * 159 */ 160 private String optional; 161 162 /** 163 * Field locations. 164 */ 165 private java.util.Map<Object, InputLocation> locations; 166 167 168 //-----------/ 169 //- Methods -/ 170 //-----------/ 171 172 /** 173 * Method addExclusion. 174 * 175 * @param exclusion 176 */ 177 public void addExclusion( Exclusion exclusion ) 178 { 179 getExclusions().add( exclusion ); 180 } //-- void addExclusion( Exclusion ) 181 182 /** 183 * Method clone. 184 * 185 * @return Dependency 186 */ 187 public Dependency clone() 188 { 189 try 190 { 191 Dependency copy = (Dependency) super.clone(); 192 193 if ( this.exclusions != null ) 194 { 195 copy.exclusions = new java.util.ArrayList<Exclusion>(); 196 for ( Exclusion item : this.exclusions ) 197 { 198 copy.exclusions.add( ( (Exclusion) item).clone() ); 199 } 200 } 201 202 if ( copy.locations != null ) 203 { 204 copy.locations = new java.util.LinkedHashMap( copy.locations ); 205 } 206 207 return copy; 208 } 209 catch ( java.lang.Exception ex ) 210 { 211 throw (java.lang.RuntimeException) new java.lang.UnsupportedOperationException( getClass().getName() 212 + " does not support clone()" ).initCause( ex ); 213 } 214 } //-- Dependency clone() 215 216 /** 217 * Get the unique id for an artifact produced by the project 218 * group, e.g. 219 * <code>maven-artifact</code>. 220 * 221 * @return String 222 */ 223 public String getArtifactId() 224 { 225 return this.artifactId; 226 } //-- String getArtifactId() 227 228 /** 229 * Get the classifier of the dependency. This allows 230 * distinguishing two artifacts 231 * that belong to the same POM but were built 232 * differently, and is appended to 233 * the filename after the version. For example, 234 * <code>jdk14</code> and <code>jdk15</code>. 235 * 236 * @return String 237 */ 238 public String getClassifier() 239 { 240 return this.classifier; 241 } //-- String getClassifier() 242 243 /** 244 * Method getExclusions. 245 * 246 * @return List 247 */ 248 public java.util.List<Exclusion> getExclusions() 249 { 250 if ( this.exclusions == null ) 251 { 252 this.exclusions = new java.util.ArrayList<Exclusion>(); 253 } 254 255 return this.exclusions; 256 } //-- java.util.List<Exclusion> getExclusions() 257 258 /** 259 * Get the project group that produced the dependency, e.g. 260 * <code>org.apache.maven</code>. 261 * 262 * @return String 263 */ 264 public String getGroupId() 265 { 266 return this.groupId; 267 } //-- String getGroupId() 268 269 /** 270 * 271 * 272 * @param key 273 * @return InputLocation 274 */ 275 public InputLocation getLocation( Object key ) 276 { 277 return ( locations != null ) ? locations.get( key ) : null; 278 } //-- InputLocation getLocation( Object ) 279 280 /** 281 * Get indicates the dependency is optional for use of this 282 * library. While the 283 * version of the dependency will be taken into 284 * account for dependency calculation if the 285 * library is used elsewhere, it will not be passed 286 * on transitively. Note: While the type 287 * of this field is <code>String</code> for 288 * technical reasons, the semantic type is actually 289 * <code>Boolean</code>. Default value is 290 * <code>false</code>. 291 * 292 * @return String 293 */ 294 public String getOptional() 295 { 296 return this.optional; 297 } //-- String getOptional() 298 299 /** 300 * Get the scope of the dependency - <code>compile</code>, 301 * <code>runtime</code>, 302 * <code>test</code>, <code>system</code>, and 303 * <code>provided</code>. Used to 304 * calculate the various classpaths used for 305 * compilation, testing, and so on. 306 * It also assists in determining which artifacts 307 * to include in a distribution of 308 * this project. For more information, see 309 * <a 310 * href="http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html">the 311 * dependency mechanism</a>. 312 * 313 * @return String 314 */ 315 public String getScope() 316 { 317 return this.scope; 318 } //-- String getScope() 319 320 /** 321 * Get fOR SYSTEM SCOPE ONLY. Note that use of this property is 322 * <b>discouraged</b> 323 * and may be replaced in later versions. This 324 * specifies the path on the filesystem 325 * for this dependency. 326 * Requires an absolute path for the value, not 327 * relative. 328 * Use a property that gives the machine specific 329 * absolute path, 330 * e.g. <code>${java.home}</code>. 331 * 332 * @return String 333 */ 334 public String getSystemPath() 335 { 336 return this.systemPath; 337 } //-- String getSystemPath() 338 339 /** 340 * Get the type of dependency. This defaults to 341 * <code>jar</code>. While it 342 * usually represents the extension on the filename 343 * of the dependency, 344 * that is not always the case. A type can be 345 * mapped to a different 346 * extension and a classifier. 347 * The type often correspongs to the packaging 348 * used, though this is also 349 * not always the case. 350 * Some examples are <code>jar</code>, 351 * <code>war</code>, <code>ejb-client</code> 352 * and <code>test-jar</code>. 353 * New types can be defined by plugins that set 354 * <code>extensions</code> to <code>true</code>, so 355 * this is not a complete list. 356 * 357 * @return String 358 */ 359 public String getType() 360 { 361 return this.type; 362 } //-- String getType() 363 364 /** 365 * Get the version of the dependency, e.g. <code>3.2.1</code>. 366 * In Maven 2, this can also be 367 * specified as a range of versions. 368 * 369 * @return String 370 */ 371 public String getVersion() 372 { 373 return this.version; 374 } //-- String getVersion() 375 376 /** 377 * Method removeExclusion. 378 * 379 * @param exclusion 380 */ 381 public void removeExclusion( Exclusion exclusion ) 382 { 383 getExclusions().remove( exclusion ); 384 } //-- void removeExclusion( Exclusion ) 385 386 /** 387 * Set the unique id for an artifact produced by the project 388 * group, e.g. 389 * <code>maven-artifact</code>. 390 * 391 * @param artifactId 392 */ 393 public void setArtifactId( String artifactId ) 394 { 395 this.artifactId = artifactId; 396 } //-- void setArtifactId( String ) 397 398 /** 399 * Set the classifier of the dependency. This allows 400 * distinguishing two artifacts 401 * that belong to the same POM but were built 402 * differently, and is appended to 403 * the filename after the version. For example, 404 * <code>jdk14</code> and <code>jdk15</code>. 405 * 406 * @param classifier 407 */ 408 public void setClassifier( String classifier ) 409 { 410 this.classifier = classifier; 411 } //-- void setClassifier( String ) 412 413 /** 414 * Set lists a set of artifacts that should be excluded from 415 * this dependency's 416 * artifact list when it comes to calculating 417 * transitive dependencies. 418 * 419 * @param exclusions 420 */ 421 public void setExclusions( java.util.List<Exclusion> exclusions ) 422 { 423 this.exclusions = exclusions; 424 } //-- void setExclusions( java.util.List ) 425 426 /** 427 * Set the project group that produced the dependency, e.g. 428 * <code>org.apache.maven</code>. 429 * 430 * @param groupId 431 */ 432 public void setGroupId( String groupId ) 433 { 434 this.groupId = groupId; 435 } //-- void setGroupId( String ) 436 437 /** 438 * 439 * 440 * @param key 441 * @param location 442 */ 443 public void setLocation( Object key, InputLocation location ) 444 { 445 if ( location != null ) 446 { 447 if ( this.locations == null ) 448 { 449 this.locations = new java.util.LinkedHashMap<Object, InputLocation>(); 450 } 451 this.locations.put( key, location ); 452 } 453 } //-- void setLocation( Object, InputLocation ) 454 455 /** 456 * Set indicates the dependency is optional for use of this 457 * library. While the 458 * version of the dependency will be taken into 459 * account for dependency calculation if the 460 * library is used elsewhere, it will not be passed 461 * on transitively. Note: While the type 462 * of this field is <code>String</code> for 463 * technical reasons, the semantic type is actually 464 * <code>Boolean</code>. Default value is 465 * <code>false</code>. 466 * 467 * @param optional 468 */ 469 public void setOptional( String optional ) 470 { 471 this.optional = optional; 472 } //-- void setOptional( String ) 473 474 /** 475 * Set the scope of the dependency - <code>compile</code>, 476 * <code>runtime</code>, 477 * <code>test</code>, <code>system</code>, and 478 * <code>provided</code>. Used to 479 * calculate the various classpaths used for 480 * compilation, testing, and so on. 481 * It also assists in determining which artifacts 482 * to include in a distribution of 483 * this project. For more information, see 484 * <a 485 * href="http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html">the 486 * dependency mechanism</a>. 487 * 488 * @param scope 489 */ 490 public void setScope( String scope ) 491 { 492 this.scope = scope; 493 } //-- void setScope( String ) 494 495 /** 496 * Set fOR SYSTEM SCOPE ONLY. Note that use of this property is 497 * <b>discouraged</b> 498 * and may be replaced in later versions. This 499 * specifies the path on the filesystem 500 * for this dependency. 501 * Requires an absolute path for the value, not 502 * relative. 503 * Use a property that gives the machine specific 504 * absolute path, 505 * e.g. <code>${java.home}</code>. 506 * 507 * @param systemPath 508 */ 509 public void setSystemPath( String systemPath ) 510 { 511 this.systemPath = systemPath; 512 } //-- void setSystemPath( String ) 513 514 /** 515 * Set the type of dependency. This defaults to 516 * <code>jar</code>. While it 517 * usually represents the extension on the filename 518 * of the dependency, 519 * that is not always the case. A type can be 520 * mapped to a different 521 * extension and a classifier. 522 * The type often correspongs to the packaging 523 * used, though this is also 524 * not always the case. 525 * Some examples are <code>jar</code>, 526 * <code>war</code>, <code>ejb-client</code> 527 * and <code>test-jar</code>. 528 * New types can be defined by plugins that set 529 * <code>extensions</code> to <code>true</code>, so 530 * this is not a complete list. 531 * 532 * @param type 533 */ 534 public void setType( String type ) 535 { 536 this.type = type; 537 } //-- void setType( String ) 538 539 /** 540 * Set the version of the dependency, e.g. <code>3.2.1</code>. 541 * In Maven 2, this can also be 542 * specified as a range of versions. 543 * 544 * @param version 545 */ 546 public void setVersion( String version ) 547 { 548 this.version = version; 549 } //-- void setVersion( String ) 550 551 552 553 public boolean isOptional() 554 { 555 return ( optional != null ) ? Boolean.parseBoolean( optional ) : false; 556 } 557 558 public void setOptional( boolean optional ) 559 { 560 this.optional = String.valueOf( optional ); 561 } 562 563 /** 564 * @see java.lang.Object#toString() 565 */ 566 public String toString() 567 { 568 return "Dependency {groupId=" + groupId + ", artifactId=" + artifactId + ", version=" + version + ", type=" + type + "}"; 569 } 570 571 572 573 574 /** 575 * @return the management key as <code>groupId:artifactId:type</code> 576 */ 577 public String getManagementKey() 578 { 579 return groupId + ":" + artifactId + ":" + type + ( classifier != null ? ":" + classifier : "" ); 580 } 581 582 583 }