Migration to Maven 3

I’ve read a number of articles which say about new cool features like parallel builds and performance speed-ups. Sounds rather sweet.

So I’ve taken the current project I’m working at and migrated it to Maven 3 to check if it’s possible to get any compilation speed-up. The only thing which was changed in the root pom.xml was replacing http://download.java.net/maven/1 repository with http://maven.glassfish.org/content/groups/public. This has been done because legacy layouts are no longer supported in Maven 3

The project contains about 10 modules, one of these modules compiles GWT, another one – JasperReports reports. This causes the whole compilation process to take about 12-13 minutes.

I’ve tested three main scenarios used for this project:

  1. Scenario 1. Quick compilation without running JUnit tests. GWT is configured to support only one browser which reduces compilation time.
  2. Scenario 2. Quick compilation with running JUnit tests. GWT is configured to support only one browser which reduces compilation time.
  3. Scenario 3. Full compilation with running JUnit tests.

Below are the results of running these scenarios with:

  1. Maven 2.
  2. Maven 3. Parallel build is enabled by specifying -T 1C parameter which tells Maven to use a thread per core.
Scenario Maven 2.2.1 Maven 3.0.2 Build Time Delta
Scenario 1 3m 54s 4m 07s +6%
Scenario 2 6m 51s 5m 45s -16%
Scenario 3 12m 53s 11m 20s -12%

As you can see straightforward compilation without tests was not quicker. But running JUnit tests in parallel is quite a nice thing which can speed up your build process.

Of course everything depends on the specifics of your project, the way it’s structured, a list of used plugins. For example the default GWT plugin settings are already good enough to utilize all cores of your CPU. But in general Maven 3 will definetely make your development cycle faster.