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