Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven Parallel Build - Sequence some modules

I have a multi-module maven project and looking to leverage the parallel build feature in Maven 3. But some of the modules lay the groundwork for future modules (when built sequentially, like creating some directories, downloading some non-maven jars etc). Is there a way for me to control the parallelism partially so that the build starts of sequentially and then goes parallel and eventually converge to a final module that does aggregation and cannot be run before the others?

Thanks in advance

like image 966
Karthik Avatar asked Jan 06 '14 23:01

Karthik


2 Answers

Just add a dependency on the pom (pom) we use this to order our docker builds (images depend on base images that need to built earlier)

like image 149
Robert Willems Avatar answered Nov 02 '22 12:11

Robert Willems


I haven't tested this, but I think it should be possible. The downside is you will have to control that branch/join logic yourself by running mvn multiple times.

First, check out this article for how to do parallel builds: https://cwiki.apache.org/confluence/display/MAVEN/Parallel+builds+in+Maven+3

Now when it comes to building individual modules, you should use this command line option:

 -pl,--projects <arg>                   Comma-delimited list of specified
                                        reactor projects to build instead
                                        of all projects. A project can be
                                        specified by [groupId]:artifactId
                                        or by its relative path.

I think you will need to run the mvn command multiple times. Let me know if you need more info.


Side Note: Consider this line

This build-mode analyzes your project's dependency graph and schedules modules that can be built in parallel according to the dependency graph of your project.

You may not need to do any branch/join logic. See if it works without it.

like image 28
Daniel Kaplan Avatar answered Nov 02 '22 12:11

Daniel Kaplan