RSS Feed for This PostCurrent Article

Integrate Maven with Version Control System

Download

In one of my projects I am using CVS. No SubVersion and Continuum yet, maybe in other new projects I will use them.

One problem I found is that there are no clear example on how to use the SCM plugin, Maven profiles, etc for a multiple modules project.

Here I briefly describe how I integrate Maven 2.x with CVS for a multi modules project.

1. Create a Multiple Modules Project

Create a multiple modules project, as described here.

2. Use release.xml for CVS Checkout and Compilation

You can download a sample of release.xml from this post.

In release.xml, I defined 2 profiles, dev and prod.

<profiles>

<profile>
<id>dev</id>
<activation>
<property>
<name>!env</name>
</property>
</activation>
<properties>
<maven.repository>http://<hostname>/artifactory/
repo</maven.repository>
<checkoutDirectory>${basedir}/build</checkoutDirectory>
<goals>compile,package</goals>

<cvs.server>scm:cvs|pserver|<username>@<hostname>|
/cvsrepo|${module}</cvs.server>
<goalsDirectory>${project}</goalsDirectory>

</properties>
</profile>

<profile>
<id>prod</id>
<activation>
<property>
<name>env</name>
<value>prod</value>
</property>
</activation>
<properties>
<maven.repository>http://<hostname>/artifactory/
repo</maven.repository>
<checkoutDirectory>${basedir}/build</checkoutDirectory>
<goals>compile,package</goals>

<cvs.server>scm:cvs|pserver|<username>@<hostname>|
/cvsrepo|${module}</cvs.server>
<goalsDirectory>${project}</goalsDirectory>
</properties>
</profile>

</profiles>

I defined maven.repository in the profiles as development and production Maven repositories are in different locations. I used Artifactory as my maven repository.

For dev profile, it is defined as !env, which means if env is not defined, then use this profile.

cvs.server defines the SCM url. You can find out more at http://maven.apache.org/scm/

checkoutDirectory is the staging area for the checkout and build process.

goalsDirectory is the target project to be built.

  1. To build a particular project, e.g. XXX-<version>.jar, execute the following commands

    mvn scm:bootstrap -Dmodule=<module_name> -Dproject=<XXX> -f release.xml

    The jar file is generated under build/<XXX>/target

  2. To build a particular revision/branch/tag, e.g. for revision REV_1 in CVS, execute the following commands


    mvn scm:bootstrap -Dmodule=<module_name> -Dproject=<project_name> -DscmVersionType=revision -DscmVersion=REV_1 -f release.xml


Trackback URL


Sorry, comments for this entry are closed at this time.