I have a git projects having child projects.
pom.xml (parent pom)
Running the maven build on the parent project is not exactly random. As per the documentation:
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
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 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 builttrigger
build after other projects are builttrigger
Personally 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.