Do you use source control? Tell Maven about it, and you'll be able to generate some interesting reports described later in this book. Once you have associated your project with a source code repository, you will be able to use the Maven Source Control Management (SCM) plug-in which provides goals for updating and releasing from a version control system such as CVS or Subversion.
You need to add a repository element to your project's project.xml. The following repository element is from the Apache Struts project, and it points to the Subversion repository available at http://svn.apache.org/repos/asf/struts/core/trunk:
<repository> <connection> scm:svn:http://svn.apache.org/repos/asf/struts/core/trunk </connection> <developerConnection> scm:svn:https://svn.apache.org/repos/asf/struts/core/trunk </developerConnection> <url>http://svn.apache.org/repos/asf/struts/core/trunk</url> </repository>
The connection
element tells Maven about the read-only location of the SCM.
scm
identifies this URL as being an
SCM location, svn
tells Maven that
this URL will be for a Subversion repository, and the final section of
the URL is the location to the project's trunk. You may also specify
the developerConnection
; you use
this element when you need to segment your audience into people
without write access to source code, and people with write
access.
The url
element supplies a
URL that can be used to browse the repository. In the case of Struts,
they have elected to point to the Subversion repository itself, as it
can be browsed with a regular web browser. The Struts team could also
elect to point to the ViewCVS
instance configured to point to the ASF Subversion repository, which
can be found at the following URL: http://cvs.apache.org/viewcvs.cgi/struts/core/trunk/?root=Apache-SVN.
When you point a project.xml file at a particular source
control system, you can also specify the different versions and
branches of a particular project. The following XML shows a reduced
version of the versions
and
branches
elements from the Apache
Struts project.xml file:
<versions> <version> <id>1.2.0</id> <name>1.2.0</name> <tag>STRUTS_1_2_0</tag> </version> <version> <id>1.2.6</id> <name>1.2.6</name> <tag>STRUTS_1_2_6</tag> </version> </versions> <branches> <branch> <tag>STRUTS_1_1_BRANCH</tag> </branch> <branch> <tag>STRUTS_1_2_BRANCH</tag> </branch> </branches>
Versions are used by several plug-ins, such as the Announcements plug-in, which is used to create release notes for each version.
...CVS?
While many corporate and open source projects have switched to Subversion, some major open source projects such as JBoss have yet to make the jump to Subversion. If your project is using CVS, you will need to add a repository element similar to the repository element from the Jakarta Cactus project shown here:
<repository> <connection> scm:cvs:pserver:anoncvs@cvs.apache.org:/home/cvspublic:jakarta-cactus </connection> <url>http://cvs.apache.org/viewcvs.cgi/jakarta-cactus/</url> </repository>
The previous excerpt is appropriate if you are exposing your
repository using CVS pserver. If you are accessing CVS over SSH, you
will need to set your CVS_RSH
environment variable to ssh
and use
the following syntax:
<repository> <connection> scm:cvs:pserver:anoncvs@cvs.apache.org:/home/cvspublic:jakarta-cactus </connection> <url>http://cvs.apache.org/viewcvs.cgi/jakarta-cactus/</url> <developerConnection> scm:cvs:ext:tobrien@somehost:/home/cvs/repository:modulename </developerConnection> </repository>
Get Maven: A Developer's Notebook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.