Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven multi-module project and Jenkins

I have the following projects organized in a flat structured way:

parentProject
+-pom.xml

projectWeb <depends on libraryA and libraryB>
+-pom.xml

libraryA
+-pom.xml

libraryB
+-pom.xml

The pom.xml inside the parentProject has references to the other modules and its used for inheritance and dependencyManagement, here is a snippet:

<project>
    ....
    <modules>
        <module>../projectWeb</module>
        <module>../libraryA</module>
        <module>../libraryB</module>
    </modules>
    <dependencyManagement>
    ...
    </dependencyManagement>
    <build>
    ...
    </build>
    ....
</project>

In Jenkins I have one maven job for each project, and it works fine when I build the parentProject, ie. builds every project referenced in the modules section. The problem that I have is when I commit to the SVN a change in libraryA, I would expect that after building libraryA, a rebuild to projectWeb to be launched, but that didn't happen. Anyone knows what am I doing wrong?

Thanks in advance.

EDIT

When I remove the modules section from parentProject\pom.xml, it works as espected, but I loose the aggregation advantage of having a parent pom.

like image 342
Diego Sergnese Avatar asked Sep 26 '12 23:09

Diego Sergnese


1 Answers

It looks like you're asking your parent POM to do two things:

  1. Set up dependency management stuff
  2. Aggregate your build

It's generally better if you split this out into two poms - a parent pom for #1 and an aggregate pom for #2. You'd then have something like..

[root dir] aggregate pom.xml
+ /parent 
+ /web
+ /libA
+ /libB

See this answer for more details: https://stackoverflow.com/a/3301162/211993

You'd then configure Jenkins to check out the root dir and run "mvn clean install"

like image 144
dan Avatar answered Sep 24 '22 18:09

dan