0

I have big project with many submodules. It takes very long time to build it.

When I try to build it using multithreading, it fails.

How can I build some modules using multithreading at first, and then continue to build rest of modules using default building process without threads ?

sp41mer
  • 13
  • 6

1 Answers1

0

First, build up to the last module you know works with multithreading:

$ mvn clean install -pl <module1,...,last-module> -am -T 2C

You shouldn't have to list all modules if you make sure to add the ones with most dependencies.

Then, build the remaining modules single-threaded:

$ mvn install --resume-from <last-module>

You will be building last-module twice, but hopefully not a big issue.

gjoranv
  • 4,376
  • 3
  • 21
  • 37
  • Can I make `mvn clean install -pl -am -T 2C` then `mvn install -pl -am -T 2C` and so on, and at the end `mvn install --resume-from ` ? – sp41mer Feb 08 '18 at 19:02
  • @sp41mer I guess you could, but not sure why you want to split the multithreaded execution manually like that. If you are in control of this project, you should look for the real reason your multithreaded build fails, as mentioned by khmarbaise. For example, if you have custom maven plugins, make sure they are thread safe. Please also be aware that different maven versions behave differently. In our project, we can build successfully with multiple threads on 3.5.0, while 3.5.2 hangs. – gjoranv Feb 08 '18 at 23:14