Initial Setup and Configuration to Release with Ease
Most organizations, especially enterprises, require encrypted connectivity to network resources such as CVS. When releasing with Maven using an SSH connection to your CVS server and your remote repository, it is ideal to perform a public key swap with the servers you will be communicating.
Preparing your Project
As part of the release process, Maven will physically deploy your application artifacts, source, and generated site to your team Maven repository. Maven must be told where the version control system and Maven repository servers are located.
POM Preparation
SCM ConfigurationWhen using the Maven release plugin to perform a release, it will first check for local modifications to the code that have not been committed to your source control repository. Additionally it will tag your project for you. To instruct Maven on how to connect to your SCM repository and where your project is stored you must include SCM information in your POM (the master POM if this is a multi-module project).
SCM Example for a CVS Repository
<scm>
<connection>
scm:cvs:ext:foo@myserver:/usr/cvsroot:module/project
</connection>
</scm>More information about the SCM element of the POM can be found at
http://maven.apache.org/pom.html#SCM.Artifact Distribution ConfigurationNext the POM needs to know where and how to physically distribute your released software. This is declared in the distributionManagement element as follows:
<distributionManagement>
<repository>
<id>team-maven-repo</id>
<name>my-team-maven-repo</name>
<url>
scpexe://myserver/home/Brandon/maven/team/<myteam>/repository
</url>
</repository>
<site>
<id>team-maven-site</id>
<name>my-team-maven-site</name>
<url>
scpexe://myserver/home/Brandon/maven/team/<myteam>/site
</url>
</site>
</distributionManagement>The repository element declares the location that will receive the artifacts when released. The site element declares where the auto-generated HTML project web site should be sent.
In the above example scpexe is used as the protocol handler. This instructs Maven to use an external SCP implementation when copying the files. This is usually necessary when releasing from a Microsoft Windows client. When doing a release from a dedicated build server, a different configuration can be implemented as in the example below.
<profiles>
<profile>
<id>env-qual</id>
<distributionManagement>
<repository>
<id>team-repo</id>
<name>Team Maven Repository</name>
<url>
file:///home/buildadm/maven/team/<myteam>/repository
</url>
</repository>
<site>
<id>team-site</id>
<name>Team Maven Project Site</name>
<url>
file:///home/buildadm/maven/team/<myteam>/site/<myproject>
</url>
</site>
</distributionManagement>
</profile>
</profiles>By specifying a separate distributionManagement configuration for a build server we can bypass the overhead of SCP copy operations. The file protocol handler simply copies the files to the specified local path.
Releasing in 2 Easy Steps
- When executing the Maven release plugin pass a command line parameter to override the username used in interactions with CVS.
mvn -Dusername=jdoe release:prepare
mvn -Dusername=jdoe release:perform