Reputation: 13753
I have a git projects having child projects.
Sample representation:
parent
core
-src
-pom.xml
projA
-src
-pom.xml
projB
projB1
-src
-pom.xml
projB2
-src
-pom.xml
projC
-src
-pom.xml
pom.xml (parent pom)
projA
, projB1
, projB2
and projC
are independent projects which uses internally core
project. In real, there are around 8-10 independent projects.
I am using Jenkins for CI. I am using git plugin to fetch project details and maven plugin to build the project and run test cases.
I am simply using clean install
goal.
Currently, I created a single job. some of the projects took more time (1-2 hours) to run all the test cases. Using this approach, the order of execution of projects is random.
core
module I want to build other modules in parallel (2 or 3 at a time) to fast build process. How can I achieve this?Upvotes: 0
Views: 552
Reputation: 15518
Running the maven build on the parent project is not exactly random. As per the documentation:
The Reactor
The mechanism in Maven that handles multi-module projects is referred to as the reactor. This part of the Maven core does the following:
- Collects all the available modules to build
- Sorts the projects into the correct build order
- Builds the selected projects in order
Reactor Sorting
Because modules within a multi-module build can depend on each other, it is important that The reactor sorts all the projects in a way that guarantees any project is built before it is required.
The following relationships are honoured when sorting projects:
- a project dependency on another module in the build
- a plugin declaration where the plugin is another modules in the build
- a plugin dependency on another module in the build
- a build extension declaration on another module in the build
- the order declared in the
<modules>
element (if no other rule applies)Note that only "instantiated" references are used - dependencyManagement and pluginManagement elements will not cause a change to the reactor sort order
Given that it takes that long to build all of it, I suspect that you may be running some integration tests as well. Thus, I'd try to isolate them and run everything during a nightly build, while running the (hopefully & desirably) fast unit test in a continuous integration build after each commit.
Regarding the setup for parallelism, there are a few options which have one thing in common: creating a job for each of the modules. To enumerate a few (you can read a nice description for some of them here):
build whenever a SNAPSHOT dependency is built
triggerbuild after other projects are built
triggerPersonally I've used just the implicit upstream-downstream support for maven jobs & the snapshot dependency
trigger, meaning that Jenkins analyses the dependencies between the modules and triggers builds for the appropriate dependant jobs.
Upvotes: 1