Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The maven build takes too long

The global build of our application (30 Maven modules) is taking too much time (15 minutes). This includes units and integration tests. The majority of the time is consumed by the integrations tests (60%).

Our tech stack comprises of Spring, Spring MVC, Spring Batch etc. and Maven. Our developers are not motivated to keep this practice (Build All before commit)

Since I want to improve the build time I am suggesting these scenarios:

  • Parallel build : mvn -T 1C is not going to work as this consumes all resources of developer machine which prevents the developer from doing other things.
  • Organize module by profile (front, batch, connector, commons) is not going to work either as our modules are inter-dependent and we must do the build all.

Do you have some suggestions to improve the build time of large projects?

Thanks in advance.

like image 328
Nabil Avatar asked Jan 13 '14 12:01

Nabil


2 Answers

  1. Adjust memory configurations to optimum for eg: add this line to mvn.bat set MAVEN_OPTS=-Xmx512m -XX:MaxPermSize=256m

  2. Clean phase of mvn normally deletes target folder. Instead if we are renaming target folder the cleaning phase will be much faster.

  3. -Dmaven.test.skip=true will skip the test execution.

  4. Add -Denforcer.skip=true to mvn command line argument (This is enforcing versions of maven, jdk etc ,we can skip it after initial runs)

  5. Disable non-critical operations during build phase: Analysis, javadoc generation, source packaging. This will save huge time.

  6. Spawnig new process also helps in time improvement -Dmaven.junit.fork=true (fork the junit tests into a new process) -Dmaven.compile.fork=true (forks the compilation)

Hope it helps.

like image 95
Sinto Avatar answered Oct 27 '22 02:10

Sinto


Don't run the integration tests in the normal profile, let the developers check in after running unit tests only.

Run integration tests on a separate server (a build server or continuous integration server, like Jenkins or similar). Have the build server email the developers that checked in bad code.

In our work office, we also have big screens showing green/yellow/red flags for each module, so everyone can see if a module is unstable (and who has checked in since the last stable build).

like image 29
Harald K Avatar answered Oct 27 '22 04:10

Harald K