1 /* 2 * $Id$ 3 */ 4 5 package org.apache.maven.model; 6 7 //---------------------------------/ 8 //- Imported classes and packages -/ 9 //---------------------------------/ 10 11 import java.util.Date; 12 13 /** 14 * 15 * 16 * The <code><project></code> element is the root of 17 * the descriptor. 18 * The following table lists all of the possible child 19 * elements. 20 * 21 * 22 * 23 * @version $Revision$ $Date$ 24 */ 25 public class Model extends ModelBase 26 implements java.io.Serializable 27 { 28 29 30 //--------------------------/ 31 //- Class/Member Variables -/ 32 //--------------------------/ 33 34 /** 35 * Declares to which version of project descriptor this POM 36 * conforms. 37 */ 38 private String modelVersion; 39 40 /** 41 * The location of the parent project, if one exists. Values 42 * from the parent 43 * project will be the default for this project if 44 * they are left unspecified. The location 45 * is given as a group ID, artifact ID and version. 46 */ 47 private Parent parent; 48 49 /** 50 * 51 * 52 * A universally unique identifier for a project. 53 * It is normal to 54 * use a fully-qualified package name to 55 * distinguish it from other 56 * projects with a similar name (eg. 57 * <code>org.apache.maven</code>). 58 * 59 * 60 */ 61 private String groupId; 62 63 /** 64 * The identifier for this artifact that is unique within the 65 * group given by the 66 * group ID. An artifact is something that is 67 * either produced or used by a project. 68 * Examples of artifacts produced by Maven for a 69 * project include: JARs, source and binary 70 * distributions, and WARs. 71 */ 72 private String artifactId; 73 74 /** 75 * The current version of the artifact produced by this project. 76 */ 77 private String version; 78 79 /** 80 * 81 * 82 * The type of artifact this project produces, for 83 * example <code>jar</code> 84 * <code>war</code> 85 * <code>ear</code> 86 * <code>pom</code>. 87 * Plugins can create their own packaging, and 88 * therefore their own packaging types, 89 * so this list does not contain all possible 90 * types. 91 * 92 * 93 */ 94 private String packaging = "jar"; 95 96 /** 97 * The full name of the project. 98 */ 99 private String name; 100 101 /** 102 * A detailed description of the project, used by Maven 103 * whenever it needs to 104 * describe the project, such as on the web site. 105 * While this element can be specified as 106 * CDATA to enable the use of HTML tags within the 107 * description, it is discouraged to allow 108 * plain text representation. If you need to modify 109 * the index page of the generated web 110 * site, you are able to specify your own instead 111 * of adjusting this text. 112 */ 113 private String description; 114 115 /** 116 * 117 * 118 * The URL to the project's homepage. 119 * 120 * 121 */ 122 private String url; 123 124 /** 125 * The year of the project's inception, specified with 4 126 * digits. This value is 127 * used when generating copyright notices as well 128 * as being informational. 129 */ 130 private String inceptionYear; 131 132 /** 133 * This element describes various attributes of the 134 * organization to which the 135 * project belongs. These attributes are utilized 136 * when documentation is created (for 137 * copyright notices and links). 138 */ 139 private Organization organization; 140 141 /** 142 * Field licenses. 143 */ 144 private java.util.List licenses; 145 146 /** 147 * Field mailingLists. 148 */ 149 private java.util.List mailingLists; 150 151 /** 152 * Field developers. 153 */ 154 private java.util.List developers; 155 156 /** 157 * Field contributors. 158 */ 159 private java.util.List contributors; 160 161 /** 162 * The project's issue management system information. 163 */ 164 private IssueManagement issueManagement; 165 166 /** 167 * Specification for the SCM used by the project, such as CVS, 168 * Subversion, etc. 169 */ 170 private Scm scm; 171 172 /** 173 * The project's continuous integration information. 174 */ 175 private CiManagement ciManagement; 176 177 /** 178 * Describes the prerequisites in the build environment for 179 * this project. 180 */ 181 private Prerequisites prerequisites; 182 183 /** 184 * Information required to build the project. 185 */ 186 private Build build; 187 188 /** 189 * Field profiles. 190 */ 191 private java.util.List profiles; 192 193 194 //-----------/ 195 //- Methods -/ 196 //-----------/ 197 198 /** 199 * Method addContributor. 200 * 201 * @param contributor 202 */ 203 public void addContributor( Contributor contributor ) 204 { 205 if ( !(contributor instanceof Contributor) ) 206 { 207 throw new ClassCastException( "Model.addContributors(contributor) parameter must be instanceof " + Contributor.class.getName() ); 208 } 209 getContributors().add( contributor ); 210 } //-- void addContributor( Contributor ) 211 212 /** 213 * Method addDeveloper. 214 * 215 * @param developer 216 */ 217 public void addDeveloper( Developer developer ) 218 { 219 if ( !(developer instanceof Developer) ) 220 { 221 throw new ClassCastException( "Model.addDevelopers(developer) parameter must be instanceof " + Developer.class.getName() ); 222 } 223 getDevelopers().add( developer ); 224 } //-- void addDeveloper( Developer ) 225 226 /** 227 * Method addLicense. 228 * 229 * @param license 230 */ 231 public void addLicense( License license ) 232 { 233 if ( !(license instanceof License) ) 234 { 235 throw new ClassCastException( "Model.addLicenses(license) parameter must be instanceof " + License.class.getName() ); 236 } 237 getLicenses().add( license ); 238 } //-- void addLicense( License ) 239 240 /** 241 * Method addMailingList. 242 * 243 * @param mailingList 244 */ 245 public void addMailingList( MailingList mailingList ) 246 { 247 if ( !(mailingList instanceof MailingList) ) 248 { 249 throw new ClassCastException( "Model.addMailingLists(mailingList) parameter must be instanceof " + MailingList.class.getName() ); 250 } 251 getMailingLists().add( mailingList ); 252 } //-- void addMailingList( MailingList ) 253 254 /** 255 * Method addProfile. 256 * 257 * @param profile 258 */ 259 public void addProfile( Profile profile ) 260 { 261 if ( !(profile instanceof Profile) ) 262 { 263 throw new ClassCastException( "Model.addProfiles(profile) parameter must be instanceof " + Profile.class.getName() ); 264 } 265 getProfiles().add( profile ); 266 } //-- void addProfile( Profile ) 267 268 /** 269 * Get the identifier for this artifact that is unique within 270 * the group given by the 271 * group ID. An artifact is something that is 272 * either produced or used by a project. 273 * Examples of artifacts produced by Maven for a 274 * project include: JARs, source and binary 275 * distributions, and WARs. 276 * 277 * @return String 278 */ 279 public String getArtifactId() 280 { 281 return this.artifactId; 282 } //-- String getArtifactId() 283 284 /** 285 * Get information required to build the project. 286 * 287 * @return Build 288 */ 289 public Build getBuild() 290 { 291 return this.build; 292 } //-- Build getBuild() 293 294 /** 295 * Get the project's continuous integration information. 296 * 297 * @return CiManagement 298 */ 299 public CiManagement getCiManagement() 300 { 301 return this.ciManagement; 302 } //-- CiManagement getCiManagement() 303 304 /** 305 * Method getContributors. 306 * 307 * @return java.util.List 308 */ 309 public java.util.List getContributors() 310 { 311 if ( this.contributors == null ) 312 { 313 this.contributors = new java.util.ArrayList(); 314 } 315 316 return this.contributors; 317 } //-- java.util.List getContributors() 318 319 /** 320 * Get a detailed description of the project, used by Maven 321 * whenever it needs to 322 * describe the project, such as on the web site. 323 * While this element can be specified as 324 * CDATA to enable the use of HTML tags within the 325 * description, it is discouraged to allow 326 * plain text representation. If you need to modify 327 * the index page of the generated web 328 * site, you are able to specify your own instead 329 * of adjusting this text. 330 * 331 * @return String 332 */ 333 public String getDescription() 334 { 335 return this.description; 336 } //-- String getDescription() 337 338 /** 339 * Method getDevelopers. 340 * 341 * @return java.util.List 342 */ 343 public java.util.List getDevelopers() 344 { 345 if ( this.developers == null ) 346 { 347 this.developers = new java.util.ArrayList(); 348 } 349 350 return this.developers; 351 } //-- java.util.List getDevelopers() 352 353 /** 354 * Get 355 * 356 * A universally unique identifier for a project. 357 * It is normal to 358 * use a fully-qualified package name to 359 * distinguish it from other 360 * projects with a similar name (eg. 361 * <code>org.apache.maven</code>). 362 * 363 * 364 * 365 * @return String 366 */ 367 public String getGroupId() 368 { 369 return this.groupId; 370 } //-- String getGroupId() 371 372 /** 373 * Get the year of the project's inception, specified with 4 374 * digits. This value is 375 * used when generating copyright notices as well 376 * as being informational. 377 * 378 * @return String 379 */ 380 public String getInceptionYear() 381 { 382 return this.inceptionYear; 383 } //-- String getInceptionYear() 384 385 /** 386 * Get the project's issue management system information. 387 * 388 * @return IssueManagement 389 */ 390 public IssueManagement getIssueManagement() 391 { 392 return this.issueManagement; 393 } //-- IssueManagement getIssueManagement() 394 395 /** 396 * Method getLicenses. 397 * 398 * @return java.util.List 399 */ 400 public java.util.List getLicenses() 401 { 402 if ( this.licenses == null ) 403 { 404 this.licenses = new java.util.ArrayList(); 405 } 406 407 return this.licenses; 408 } //-- java.util.List getLicenses() 409 410 /** 411 * Method getMailingLists. 412 * 413 * @return java.util.List 414 */ 415 public java.util.List getMailingLists() 416 { 417 if ( this.mailingLists == null ) 418 { 419 this.mailingLists = new java.util.ArrayList(); 420 } 421 422 return this.mailingLists; 423 } //-- java.util.List getMailingLists() 424 425 /** 426 * Get declares to which version of project descriptor this POM 427 * conforms. 428 * 429 * @return String 430 */ 431 public String getModelVersion() 432 { 433 return this.modelVersion; 434 } //-- String getModelVersion() 435 436 /** 437 * Get the full name of the project. 438 * 439 * @return String 440 */ 441 public String getName() 442 { 443 return this.name; 444 } //-- String getName() 445 446 /** 447 * Get this element describes various attributes of the 448 * organization to which the 449 * project belongs. These attributes are utilized 450 * when documentation is created (for 451 * copyright notices and links). 452 * 453 * @return Organization 454 */ 455 public Organization getOrganization() 456 { 457 return this.organization; 458 } //-- Organization getOrganization() 459 460 /** 461 * Get 462 * 463 * The type of artifact this project produces, for 464 * example <code>jar</code> 465 * <code>war</code> 466 * <code>ear</code> 467 * <code>pom</code>. 468 * Plugins can create their own packaging, and 469 * therefore their own packaging types, 470 * so this list does not contain all possible 471 * types. 472 * 473 * 474 * 475 * @return String 476 */ 477 public String getPackaging() 478 { 479 return this.packaging; 480 } //-- String getPackaging() 481 482 /** 483 * Get the location of the parent project, if one exists. 484 * Values from the parent 485 * project will be the default for this project if 486 * they are left unspecified. The location 487 * is given as a group ID, artifact ID and version. 488 * 489 * @return Parent 490 */ 491 public Parent getParent() 492 { 493 return this.parent; 494 } //-- Parent getParent() 495 496 /** 497 * Get describes the prerequisites in the build environment for 498 * this project. 499 * 500 * @return Prerequisites 501 */ 502 public Prerequisites getPrerequisites() 503 { 504 return this.prerequisites; 505 } //-- Prerequisites getPrerequisites() 506 507 /** 508 * Method getProfiles. 509 * 510 * @return java.util.List 511 */ 512 public java.util.List getProfiles() 513 { 514 if ( this.profiles == null ) 515 { 516 this.profiles = new java.util.ArrayList(); 517 } 518 519 return this.profiles; 520 } //-- java.util.List getProfiles() 521 522 /** 523 * Get specification for the SCM used by the project, such as 524 * CVS, Subversion, etc. 525 * 526 * @return Scm 527 */ 528 public Scm getScm() 529 { 530 return this.scm; 531 } //-- Scm getScm() 532 533 /** 534 * Get 535 * 536 * The URL to the project's homepage. 537 * 538 * 539 * 540 * @return String 541 */ 542 public String getUrl() 543 { 544 return this.url; 545 } //-- String getUrl() 546 547 /** 548 * Get the current version of the artifact produced by this 549 * project. 550 * 551 * @return String 552 */ 553 public String getVersion() 554 { 555 return this.version; 556 } //-- String getVersion() 557 558 /** 559 * Method removeContributor. 560 * 561 * @param contributor 562 */ 563 public void removeContributor( Contributor contributor ) 564 { 565 if ( !(contributor instanceof Contributor) ) 566 { 567 throw new ClassCastException( "Model.removeContributors(contributor) parameter must be instanceof " + Contributor.class.getName() ); 568 } 569 getContributors().remove( contributor ); 570 } //-- void removeContributor( Contributor ) 571 572 /** 573 * Method removeDeveloper. 574 * 575 * @param developer 576 */ 577 public void removeDeveloper( Developer developer ) 578 { 579 if ( !(developer instanceof Developer) ) 580 { 581 throw new ClassCastException( "Model.removeDevelopers(developer) parameter must be instanceof " + Developer.class.getName() ); 582 } 583 getDevelopers().remove( developer ); 584 } //-- void removeDeveloper( Developer ) 585 586 /** 587 * Method removeLicense. 588 * 589 * @param license 590 */ 591 public void removeLicense( License license ) 592 { 593 if ( !(license instanceof License) ) 594 { 595 throw new ClassCastException( "Model.removeLicenses(license) parameter must be instanceof " + License.class.getName() ); 596 } 597 getLicenses().remove( license ); 598 } //-- void removeLicense( License ) 599 600 /** 601 * Method removeMailingList. 602 * 603 * @param mailingList 604 */ 605 public void removeMailingList( MailingList mailingList ) 606 { 607 if ( !(mailingList instanceof MailingList) ) 608 { 609 throw new ClassCastException( "Model.removeMailingLists(mailingList) parameter must be instanceof " + MailingList.class.getName() ); 610 } 611 getMailingLists().remove( mailingList ); 612 } //-- void removeMailingList( MailingList ) 613 614 /** 615 * Method removeProfile. 616 * 617 * @param profile 618 */ 619 public void removeProfile( Profile profile ) 620 { 621 if ( !(profile instanceof Profile) ) 622 { 623 throw new ClassCastException( "Model.removeProfiles(profile) parameter must be instanceof " + Profile.class.getName() ); 624 } 625 getProfiles().remove( profile ); 626 } //-- void removeProfile( Profile ) 627 628 /** 629 * Set the identifier for this artifact that is unique within 630 * the group given by the 631 * group ID. An artifact is something that is 632 * either produced or used by a project. 633 * Examples of artifacts produced by Maven for a 634 * project include: JARs, source and binary 635 * distributions, and WARs. 636 * 637 * @param artifactId 638 */ 639 public void setArtifactId( String artifactId ) 640 { 641 this.artifactId = artifactId; 642 } //-- void setArtifactId( String ) 643 644 /** 645 * Set information required to build the project. 646 * 647 * @param build 648 */ 649 public void setBuild( Build build ) 650 { 651 this.build = build; 652 } //-- void setBuild( Build ) 653 654 /** 655 * Set the project's continuous integration information. 656 * 657 * @param ciManagement 658 */ 659 public void setCiManagement( CiManagement ciManagement ) 660 { 661 this.ciManagement = ciManagement; 662 } //-- void setCiManagement( CiManagement ) 663 664 /** 665 * Set describes the contributors to a project that are not yet 666 * committers. 667 * 668 * @param contributors 669 */ 670 public void setContributors( java.util.List contributors ) 671 { 672 this.contributors = contributors; 673 } //-- void setContributors( java.util.List ) 674 675 /** 676 * Set a detailed description of the project, used by Maven 677 * whenever it needs to 678 * describe the project, such as on the web site. 679 * While this element can be specified as 680 * CDATA to enable the use of HTML tags within the 681 * description, it is discouraged to allow 682 * plain text representation. If you need to modify 683 * the index page of the generated web 684 * site, you are able to specify your own instead 685 * of adjusting this text. 686 * 687 * @param description 688 */ 689 public void setDescription( String description ) 690 { 691 this.description = description; 692 } //-- void setDescription( String ) 693 694 /** 695 * Set describes the committers of a project. 696 * 697 * @param developers 698 */ 699 public void setDevelopers( java.util.List developers ) 700 { 701 this.developers = developers; 702 } //-- void setDevelopers( java.util.List ) 703 704 /** 705 * Set 706 * 707 * A universally unique identifier for a project. 708 * It is normal to 709 * use a fully-qualified package name to 710 * distinguish it from other 711 * projects with a similar name (eg. 712 * <code>org.apache.maven</code>). 713 * 714 * 715 * 716 * @param groupId 717 */ 718 public void setGroupId( String groupId ) 719 { 720 this.groupId = groupId; 721 } //-- void setGroupId( String ) 722 723 /** 724 * Set the year of the project's inception, specified with 4 725 * digits. This value is 726 * used when generating copyright notices as well 727 * as being informational. 728 * 729 * @param inceptionYear 730 */ 731 public void setInceptionYear( String inceptionYear ) 732 { 733 this.inceptionYear = inceptionYear; 734 } //-- void setInceptionYear( String ) 735 736 /** 737 * Set the project's issue management system information. 738 * 739 * @param issueManagement 740 */ 741 public void setIssueManagement( IssueManagement issueManagement ) 742 { 743 this.issueManagement = issueManagement; 744 } //-- void setIssueManagement( IssueManagement ) 745 746 /** 747 * Set 748 * 749 * This element describes all of the licenses for 750 * this project. 751 * Each license is described by a 752 * <code>license</code> element, which 753 * is then described by additional elements. 754 * Projects should only list the license(s) that 755 * applies to the project 756 * and not the licenses that apply to dependencies. 757 * If multiple licenses are listed, it is assumed 758 * that the user can select 759 * any of them, not that they must accept all. 760 * 761 * 762 * 763 * @param licenses 764 */ 765 public void setLicenses( java.util.List licenses ) 766 { 767 this.licenses = licenses; 768 } //-- void setLicenses( java.util.List ) 769 770 /** 771 * Set contains information about a project's mailing lists. 772 * 773 * @param mailingLists 774 */ 775 public void setMailingLists( java.util.List mailingLists ) 776 { 777 this.mailingLists = mailingLists; 778 } //-- void setMailingLists( java.util.List ) 779 780 /** 781 * Set declares to which version of project descriptor this POM 782 * conforms. 783 * 784 * @param modelVersion 785 */ 786 public void setModelVersion( String modelVersion ) 787 { 788 this.modelVersion = modelVersion; 789 } //-- void setModelVersion( String ) 790 791 /** 792 * Set the full name of the project. 793 * 794 * @param name 795 */ 796 public void setName( String name ) 797 { 798 this.name = name; 799 } //-- void setName( String ) 800 801 /** 802 * Set this element describes various attributes of the 803 * organization to which the 804 * project belongs. These attributes are utilized 805 * when documentation is created (for 806 * copyright notices and links). 807 * 808 * @param organization 809 */ 810 public void setOrganization( Organization organization ) 811 { 812 this.organization = organization; 813 } //-- void setOrganization( Organization ) 814 815 /** 816 * Set 817 * 818 * The type of artifact this project produces, for 819 * example <code>jar</code> 820 * <code>war</code> 821 * <code>ear</code> 822 * <code>pom</code>. 823 * Plugins can create their own packaging, and 824 * therefore their own packaging types, 825 * so this list does not contain all possible 826 * types. 827 * 828 * 829 * 830 * @param packaging 831 */ 832 public void setPackaging( String packaging ) 833 { 834 this.packaging = packaging; 835 } //-- void setPackaging( String ) 836 837 /** 838 * Set the location of the parent project, if one exists. 839 * Values from the parent 840 * project will be the default for this project if 841 * they are left unspecified. The location 842 * is given as a group ID, artifact ID and version. 843 * 844 * @param parent 845 */ 846 public void setParent( Parent parent ) 847 { 848 this.parent = parent; 849 } //-- void setParent( Parent ) 850 851 /** 852 * Set describes the prerequisites in the build environment for 853 * this project. 854 * 855 * @param prerequisites 856 */ 857 public void setPrerequisites( Prerequisites prerequisites ) 858 { 859 this.prerequisites = prerequisites; 860 } //-- void setPrerequisites( Prerequisites ) 861 862 /** 863 * Set a listing of project-local build profiles which will 864 * modify the build process 865 * when activated. 866 * 867 * @param profiles 868 */ 869 public void setProfiles( java.util.List profiles ) 870 { 871 this.profiles = profiles; 872 } //-- void setProfiles( java.util.List ) 873 874 /** 875 * Set specification for the SCM used by the project, such as 876 * CVS, Subversion, etc. 877 * 878 * @param scm 879 */ 880 public void setScm( Scm scm ) 881 { 882 this.scm = scm; 883 } //-- void setScm( Scm ) 884 885 /** 886 * Set 887 * 888 * The URL to the project's homepage. 889 * 890 * 891 * 892 * @param url 893 */ 894 public void setUrl( String url ) 895 { 896 this.url = url; 897 } //-- void setUrl( String ) 898 899 /** 900 * Set the current version of the artifact produced by this 901 * project. 902 * 903 * @param version 904 */ 905 public void setVersion( String version ) 906 { 907 this.version = version; 908 } //-- void setVersion( String ) 909 910 911 912 /** 913 * @return the model id as <code>groupId:artifactId:packaging:version</code> 914 */ 915 public String getId() 916 { 917 StringBuffer id = new StringBuffer(); 918 919 id.append( getGroupId() ); 920 id.append( ":" ); 921 id.append( getArtifactId() ); 922 id.append( ":" ); 923 id.append( getPackaging() ); 924 id.append( ":" ); 925 id.append( getVersion() ); 926 927 return id.toString(); 928 } 929 930 931 private String modelEncoding = "UTF-8"; 932 933 /** 934 * Set an encoding used for reading/writing the model. 935 * 936 * @param modelEncoding the encoding used when reading/writing the model. 937 */ 938 public void setModelEncoding( String modelEncoding ) 939 { 940 this.modelEncoding = modelEncoding; 941 } 942 943 /** 944 * @return the current encoding used when reading/writing this model. 945 */ 946 public String getModelEncoding() 947 { 948 return modelEncoding; 949 } 950 }