Software Development, Agile Practices, Lean Thinking, Music
[ start | index | login or register ]
start > Releasing with Maven

Releasing with Maven

Created by brandon. Last edited by brandon, 3 years and 150 days ago. Viewed 1,134 times. #9
[diff] [history] [edit] [rdf]
labels
attachments

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.

Notes on Performing a SSH Public Key Swap

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 Configuration

When 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 Configuration

Next 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

  1. When executing the Maven release plugin pass a command line parameter to override the username used in interactions with CVS.
    1. mvn -Dusername=jdoe release:prepare
    2. mvn -Dusername=jdoe release:perform
Please login to post a comment.
Describe here what your SnipSnap is about!

Configure this box!

  1. Login in
  2. Click here: snipsnap-portlet-2
  3. Edit this box
www.brandonburk.com | Copyright 2008 Brandon N. Burk