Building a maven2 project

Hudson provides a job type dedicated for Maven2. This job type integrates Hudson deeply with Maven2 and provides the following benefits compared to more generic free-style software project.

  • Hudson parses Maven POMs to obtain much of the information needed to do its work. As a result, amount of configuration is drastically reduced.
  • Hudson listens to Maven execution and figures out what should be done when on its own. For example, it will automatically record JUnit report when Maven runs the test phase. Or if you run the javadoc goal, Hudson will automatically record javadoc.

Thus mostly you just need to configure SCM information and what goals you'd like to run, and Hudson will figure out everything else.

Maven version

Some user reported a problem using this feature with Maven versions other than 2.0.4. We are particularly interested in any reports on this kind of issues.

Here is one such report: Using Hudson 1.337 on top of Tomcat 6.0.14 on top of MS XP, Maven 2.0.7 would "hang" inside Hudson but not using the command line.  Trying it with Maven 2.0.4 resulted in success inside Hudson, and a resolution of the problem with 2.0.7. 

TODO
Talk about how maven modules gets represented in sub projects, and how build numbers among sub-projects are controlled. Use some screenshots.

Automatic build chaining from module dependencies

Hudson reads dependencies of your project from your POM, and if they are also built on Hudson, triggers are set up in such a way that a new build in one of those dependencies will automatically start a new build of your project. Hudson understands all kinds of dependencies in POM. Namely,

  • parent POM
  • <dependencies> section of your project
  • <extensions> section of your project
  • <reporting> section of your project

This process takes versions into account, so you can have multiple versions/branches of your project on the same Hudson and it will correctly determine dependencies.

The Maven Integration Plugin

The Maven 2 project type is contained in the Maven Integration plugin, which is bundled with Hudson. It may show up in your list of plugins available to be upgraded, if you're running any version of Hudson earlier than the current release, but it's recommended that you not upgrade the Maven Integration plugin separately from Hudson itself. While it is technically a plugin, it is developed, tested, and released as part of Hudson core

Labels:

maven2 maven2 Delete
pom pom Delete
Enter labels to add to this page:
Wait Image 
Looking for a label? Just start typing.
  1. Jun 15, 2009

    Carolyn Teo says:

    I have a project that has this setup in a project parent POM Module 1 <d...

    I have a project that has this setup in a project
    parent POM
    Module 1

    • <dependencies> section of your project
    • <extensions> section of your project
    • <reporting> section of your project
      Module 2
    • <dependencies> section of your project
    • <extensions> section of your project
    • <reporting> section of your project
      Module 3
    • <dependencies> section of your project
    • <extensions> section of your project
    • <reporting> section of your project

    Each module creates its own reporting section. However Hudson only display the reporting section in the Module 1. Module 2 and 3 are not accessible.

    Is there any way to get Hudson to display all 3?

    Thanks!

    1. Feb 24, 2010

      Gaston Gamietea says:

      Hi Carolyn, I've the same structure but I'm not able to build anything... it ke...

      Hi Carolyn,

      I've the same structure but I'm not able to build anything... it keeps saying that there is a missing dependency... can you add some example of your parent pom and at least one module pom ?

      I'm using Eclipse Galileo, M2 plugin to create parent projects and modules...

      Thanks in advance

      GASTON

  2. Jul 01, 2009

    Tom Pijl says:

    If a maven2 job is triggered by SCM it logs in with user "anonymous". When solvi...

    If a maven2 job is triggered by SCM it logs in with user "anonymous". When solving dependencies it uses a local repository.

    Where is that located in this case? And if I have a specific settings.xml where should I place this in this case

    I use Javawrapper to start my Hudson as a daemon on an OpenSuse 10.3 Linux server.

  3. Mar 25

    mmorizot says:

    hi, I was wondering if there was a way of trigerring the reloading of a pom fil...

    hi,

    I was wondering if there was a way of trigerring the reloading of a pom file by hudson?

    the idea behind this is to modify in my workspace, the pom files (pre-build task) and then ask hudson to consider my newly modified pom, and not the initial one.

    I'm trying to implement a release process (without using release:*).

  4. Jul 28

    bombjack says:

    Hello everyone. We have a problem with Hudson and maven . We want to use Hudso...

    Hello everyone.
    We have a problem with Hudson and maven

    .
    We want to use Hudson outsourcing all configuration files (hudson_home) on another server.
    We configured the hudson_home in web.xml:
    \\ServerName\hudson

    When Hudson starts, it created all the files on the server. Therefore, the address is correct.
    But when will perform an initial build (maven in our case), it no longer works. Hudson displays the following message:

    OutputConsole
    [trunk] $ \\pcdsi547\int-continue\jdk\jdk1.5.0_07/bin/java -Xmx1024m -XX:MaxPermSize=256m -cp D:int-continue\hudson\plugins\maven-plugin\WEB-INF\lib\maven-agent-1.358.jar;\\pcdsi547\int-continue\maven\boot\classworlds-1.1.jar hudson.maven.agent.Main \\pcdsi547\int-continue\maven D:\P747\tomcat\tomcat-6-su\webapps\hudson\WEB-INF\lib\remoting-1.358.jar D:int-continue\hudson\plugins\maven-plugin\WEB-INF\lib\maven-interceptor-1.358.jar 3522 D:\int-continue\hudson\plugins\maven-plugin\WEB-INF\lib\maven2.1-interceptor-1.2.jar
    java.lang.NoClassDefFoundError: hudson/maven/agent/Main
    Exception in thread "main" ERROR: Failed to launch Maven. Exit code = 1 Finished: FAILURE

    It was noticed in the console output, it replaces some jars network address
    MyServer with D:\ (the letter is located where the application server).
    There is more then some jars (whose address is changed). We should not have D:\ *** but all the time
    pcdsi547****.
    What do you think? Did you encounter this error?
    We tested on Tomcat and Weblo (and therefore jdk and jrockit), we get the same error.

    edit: it works on a Windows environment I think the problem is adress UNC.