continuous integration based on maven2 continuous integration based on maven2 shell shell

continuous integration based on maven2


Take a look at Hudson. It's free, open-source, actively developed, has dozens of useful plugins, has great Maven2 support, and is all around awesome.

It's also frequently discussed on Stack Overflow.


I'd recommend using a recognised CI tool for managing this as there is more to CI than just the build.

But if you are determined to roll your own, you can use some of the goals from the maven-scm-plugin and capture the output.

Assuming you have a local copy of the project so you've access to the pom, you can run the status command to check for changes, and parse the output checking for any changesThe goal to use is:

mvn scm:status

If you see any changed files, then you can check out the changes and invoke your build.Beware though, there is a bug in maven-scm-provider-svnlink text that means changed files can be skipped! You may be better invoking Subversion directly and parsing its output.

For example the following will clear up a previous build, check out any changed content and then run the deploy goal.

mvn clean scm:checkout deploy

If you don't have a working copy of the project, you can use the scm:bootstrap goal to obtain it. If you set up some properties in a pom you can reuse the pom to bootstrap multiple projects.

For example the pom below can bootstrap any project if you pass the appropriate command line arguments to it:

mvn scm:bootstrap -DscmUserName=me -DscmPassword=mypass -DscmConnectionUrl=scm:svn:http://myserver/myproject/trunk<project>  [...]  <packaging>jar</packaging>  <version>0.0.1</version>  <name>SCM bootstrapper</name>  <url>http://somecompany.com</url>  <scm>    <connection>${scmConnectionUrl}</connection>    <developerConnection>${scmDeveloperConnectionUrl}</developerConnection>    <url>${scmUrl}</url>  <scm>  [...]  <build>    [...]    <plugins>      <plugin>        <groupId>org.apache.maven.plugins</groupId>        <artifactId>maven-scm-plugin</artifactId>        <version>1.0</version>        <configuration>          <goals>install</goals>          <username>${scmUsername}</username>          <password>${scmPassword}</password>        </configuration>      </plugin>    </plugins>    [...]  </build>  [...]  <properties>    <scmDeveloperConnectionUrl>dummy</scmDeveloperConnectionUrl>    <scmConnectionUrl>dummy</scmConnectionUrl>    <scmUrl>dummy</scmUrl>    <scmUsername>dummy</scmUsername>    <scmPassword>dummy</scmPassword>  </properties></project>

To make Maven work with subversion you need to configure the scm section of the POM:

<scm>  <connection>scm:svn:http://path/to/project</connection>  <developerConnection>scm:svn:http://path/to/project/tags/version</developerConnection>  <url>scm:svn:http://path/to/project/tags/version</url></scm>

As an alternative for polling for changes, consider adding a hook to subversion so that the build is triggered when a change is made. There's another question that can give you a pointer on doing that.


Maven is a repository for storing code and building projects. Personally I wouldn't use it as a continuous integration tool.

Take a look at hudson, and I think you'll find more what you're looking for. Other continuous build tools will work for you as well. It will work by getting the latest version of your code from your repository, and building it on any schedule you want (or even a non-scheduled manual build).