logo
header art

Using Maven to Manage Your Projects

June 23, 2005

Describing Your Project

After setting up the basic directory structure for your project, the next step is describing it in a project.xml file. These files can get somewhat complicated, so it's usually easier, at least at first, to copy an existing project.xml file and adapt it to your own project. The project descriptor reference on Maven's site, mentioned above, is invaluable for creating a project descriptor that maximizes the use your project will get out of Maven. Having said that, the reference is not intended to be a tutorial, and it shows. Therefore, we'll walk you through creating one from scratch.

  • <?xml version="1.0" encoding="UTF-8"?> - As with any XML document, the first step is the XML declaration.
  • <project> - this is the root element of the document; it contains all the elements that actually describe your project.
  • <pomVersion> - this tag is currently unused, but Maven requires it to be present.
  • <name> - This tag is pretty self-explanatory: it's the name of your project.
  • <groupId> - If you choose to install your project's generated artifact in a Maven repository, the value of this tag serves as the directory name.
  • <artifactId> - This tag contains a unique identifier for your project. The name of the generated artifact is typically composed of this tag's value, a dash, and the value of the next tag, <currentVersion>.
  • <currentVersion> - Once again, this tag's name says it all: it's the current version of the project. The value of this tag is used in conjunction with the value of the previous tag, <id>, to create the name of your project's generated artifact.
  • <organization> - This element contains information about the organization in charge of the project.
    • <name> - The name of the organization in charge of this project.
    • <url> - The URL for this organization's website.
    • <logo> - A URI for the logo for this organization.
  • <inceptionYear> - This tag contains the year the project was begun.
  • <package> - This tag contains the base package name for the project.
  • <description> - This is another self-explanatory tag; it's a short blurb about the project that will be used in the project documentation site.
  • <shortDescription> - This tag contains an even shorter description, one line or less, that is useful for things like manifest files.
  • <url> - This tag contains the URL for the project's home page.
  • <siteAddress> - This tag's value points to the documentation site.
  • <versions> - This element contains information about previous versions of the project.
    • <version> - This element describes a specific version of your project.
      • <id> - This tag provides a unique identifier for this version of your project.
      • <name> - This tag contains the version number for this version of your project.
      • <tag> - This tag contains a tag identifier for the name your version control system associates with this specific version. Since we did not use the <repository> tag to identify a version control server for this project, the <tag> tag doesn't serve much purpose in this project.
  • <developers> - This element contains a list of the developers who work on the project.
    • <developer> - This element contains info about a specific developer working on this project.
      • <name> - This tag contains the name of this developer.
      • <id> - This tag contains this developer's userid for things like CVS.
      • <email> - This tag contains the email address for this developer.
      • <organization> - This tag contains the name of the primary organization with which this developer is associated.
      • <timezone> - This tag contains the timezone in which the developer maintains his/her primary residence.
  • <licenses> - This element contains info about the different licenses under which the project is available.
    • <license> - This element contains detailed information about a specific license.
      • <name> - This tag contains the name of this license, e.g., LGPL.
      • <url> - This tag contains a URL that points to the text of this license.
      • <distribution> - This tag contains the distribution method for receiving the project under this license. The value can be either "manual" or "repo".
  • <dependencies> - This element contains descriptions of all the libraries on which your project depends.
    • <dependencies> - This element describes a specific dependency of your project.
      • <groupId> - The group containing the project, typically the name of an organization, e.g., Skillfusion.
      • <artifactId> - An identifier unique within the group above used to identify the particular library it needs.
      • <version> - The exact version number of the library.
      • <type> - The type of artifact; the default value is jar. The other acceptable values are ejb and plugin.
      • <url> - The homepage for this dependency. The user will see this URL if the artifact can't be found in the central repository.
      • <properties> - This element contains one or more properties for a dependency, with the tag's name serving as the equivalent of the name and the tag's value serving as the equivalent of the value the in a "name=value" pair.
  • <build> - This element describes the aspects of your project that are relevant to the build process.
    • <nagEmailAddress> - this is the email address used by tools doing unattended builds, such as continuous integration tools, when something untoward occurs.
    • <sourceDirectory> - this is the root directory for your project's source code; the code in this directory and its subdirectories will be compiled when you run your project's build goal.
    • <unitTestSourceDirectory> - this directory contains the source for your project's unit tests. They will be compiled and run as part of the build process.
    • <unitTest> - this element contains info about the specific unit tests to be run and any resources they need to function properly.
      • <includes>
        • <include> - a pattern set to be included.
      • <excludes>
        • <exclude> - a pattern set to be excluded.
      • <resources>
        • <resource>
          • <directory> - A path to the resource in question.
          • <includes> - As above.
          • <excludes> - As above.
          • <filtering> - Whether the resource is filtered.
    • <resources> - This element describes resources required by the standard build process; it has the same structure as the <resources> element inside the <unitTest> element.
  • <reports> - This element describes all the reports that should be run as part of creating the documentation site.
    • <report> - This tag contains the name of a specific report that should be generated as part of creating the documentation site.

Click here for an example of a complete project descriptor.