John is an experienced consultant specialising in Enterprise Java, Web Development, and Open Source technologies, currently based in Sydney, Australia. Well known in the Java community for his many published articles, and as author of Java Power Tools and Jenkins: The Definitive Guide, and founder of the open source Thucydides Automated Acceptance Test Library project, John helps organisations to optimize their Java development processes and infrastructures and provides training and mentoring in agile development, automated testing practices, continuous integration and delivery, and open source technologies in general. John is the CEO of Wakaleo Consulting, and runs several Training Courses on open source Java development tools and best practices. John is a DZone MVB and is not an employee of DZone and has posted 123 posts at DZone. You can read more from them at their website. View Full User Profile

More New Cool Features in Maven 3 - Parallel Builds

09.09.2010
| 8591 views |
  • submit to reddit

One of the big focuses of Maven 3 is to provide a more reliable, more stable and better performing build tool. And one big area of improvement is Performance.

Maven 3 has the (new and somewhat experimental) ability to analyze your project structure, and the dependencies between your modules, to figure out which modules can be built in parallel. This has major performance implications for larger multi-module projects - the documentation reports typical speed increases of 20-50%.

To configure your modules to be built in parallel, you need to tell Maven how many threads you want to work with. The following command will run Maven using 4 threads:

mvn -T 4 clean install

Or you can get Maven to calculate how many threads to run, based on the number of available CPU cores. In this example, Maven will run up to 2 threads per core in parallel.

mvn -T 2C clean install

The biggest speed increase comes from tests. Of course, not all tests can be run in parallel - if two modules both start up a web server on the same port, for example, you will get yourself into trouble. Speed increases will also depend on how your tests are distributed through your modules - if all the slow ones are together in one module, for example, speed increases are likely to be limited. In this case, you might want to also try running your unit tests in parallel.

From http://weblogs.java.net/blog/johnsmart/archive/2010/09/07/more-new-cool-features-maven-3-parallel-builds

Published at DZone with permission of John Ferguson Smart, author and DZone MVB.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)