2

I'm currently working on a project which often involves building Maven projects containing a relatively large number of sub-modules, e.g. 10-15. We have a bunch of plugins enabled for all projects like animal sniffer, javadoc etc. For development, in order to speed things up a bit I typically use the following properties locally to deactivate some of the steps:

mvn clean install -DskipTests -Dmaven.javadoc.skip=true -Danimal.sniffer.skip=true

My question is whether there are some other tricks, which one can use to speed up a typical Maven build process.

Dmitry
  • 2,883
  • 1
  • 21
  • 26
ejboy
  • 3,831
  • 5
  • 26
  • 31

2 Answers2

7

You can use -Dmaven.test.skip to avoid compiling tests and use -T to build modules in parallel. Consider that many plugins are not thread safe and you may run into concurrency problems which means that your build might fail. If you use Jenkins as CI tool, you can configure your Maven jobs in a way that it builds

  1. Maven modules in parallel as well
  2. only those Maven modules which are affected by the last SCM change.
Jonathan
  • 18,696
  • 6
  • 62
  • 66
Daniel S.
  • 588
  • 3
  • 11
  • Thanks, in my case enabling parallel builds reduced a total build time by around 10%. `-Dmaven.test.skip` does not always work. In my case one of the modules relies on the test classpath, therefore I had to use `-DskipTests` – ejboy Jun 17 '13 at 14:35
  • If one of your modules relies on the test classpath you might have trouble when you build a release or when you want to use the released artifacts, doesn't it? – Daniel S. Jun 18 '13 at 06:50
  • I think if a [test-jar dependency](http://stackoverflow.com/questions/174560/sharing-test-code-in-maven#174670) is used, -Dmaven.test.skip will fail, but this shouldn't stop one from releasing assuming that test phase is not skipped. We had this issue on one of our projects, but as of recent trunk the test-jar dependency is no longer used, so -Dmaven.test.skip also worked for me. – ejboy Jun 18 '13 at 08:54
  • According to [this thread](http://maven.40175.n5.nabble.com/Dmaven-test-skip-true-amp-amp-jar-test-jar-td2801646.html), the test-jar goal is skipped. – ejboy Jun 18 '13 at 09:03
1

Possible references here, here, and here.

mvnsh might be helpful for development time.

Community
  • 1
  • 1
ceilfors
  • 2,242
  • 16
  • 32