Over a million developers have joined DZone.

Benchmarking a Java/Maven Monorepo

DZone 's Guide to

Benchmarking a Java/Maven Monorepo

Ever wonder how a Maven monorepo stacks up when benchmarked? Take an example from Jooby, which uses a monorepo to organize its dependent integration modules.

· Performance Zone ·
Free Resource

Maven is the build technology that’s dominant in the Java community — but it also has a "love to hate" aspect to it. If you’re in Java development, you’re going to encounter it again and again, so on that basis, I’ll discuss a public monorepo that uses it: the excellent Jooby web microframework.

Note: I found this technology after a production usage of SparkJava that was cool, but that left me with dissatisfaction because of the static nature of it. I went as far as to complete a refactoring to make it non-static in nature that was also mostly backward-compatible. The author probably felt that it was wrong in a number of ways. Anyway, then I found Jooby as I was trying to stay way from SpringBoot. Apart from anything else, Jooby uses a monorepo for the organization of its dependent integration modules.

Cloning Jooby

git clone git@github.com:jooby-project/jooby.git

That takes 20 seconds and delivers a .git folder that is 46MB in size and a checkout that is 61MB.

Building It

There are three runs of mvn install below, each with different parameters. Each takes a different elapsed time and consumes disk space differently. Importantly, all these builds are from the project root.

In order to test the impact on the acquisition of JARs from Maven central that go into a local artifact cache, I’m doing a rm -rf ~/.m2/repository/ before each mvn command below.

Jooby Itself but No Modules That Depend on Jooby

mvn clean install -pl jooby -am

This gets a total of 268 jars from Maven central consuming 54MB of disk space and takes 1 minute and 41 seconds to complete. Much of those 268 are plugins for Maven itself. After the build, there is an additional 6MB of items in target/ folders.

The results in tabular form:

JARs from Maven Central 268
Disk space for those JARs 54MB
Build time 1m 41s
Temp target/ folder space 6MB

Jooby’s MongoDB Integration Module

There are things Jooby-Mongo depends on, but no modules that depend on it.

mvn clean install -pl jooby-mongodb -am

The results:

JARs from Maven Central 286
Disk space for those JARs 61MB
Build time 2m 10s
Temp target/ folder space 6.6MB

If you CD into jooby-mongo and run straight mvn clean install from there, the build time is just 17 seconds. At least, if the dependencies are already cached. Recursive build systems like Maven allow you to build that way, as an option. It turns out the -am -pl business is lesser-known, though, than straight mvn install after traversing to the directory/module you’re interested in.

Building Everything

Yup, Jooby itself and all dependent modules including Jooby-Mongo (again).

Perhaps only Jooby committers themselves are interested in this build. The results:

JARs from Maven Central 809
Disk space for those JARs 347MB
Build time 13m 30s
Temp target/ folder space 88.7MB

Working in an IDE

The pinnacle of Java IDEs is Intellij IDEA, of course.

Mvn idea:idea seems to work, but it doesn’t obey the -pl and -am flags. That was the official Maven plugin for Intellij IDEA, but it is abandoned now.

I raised a feature request with the excellent JetBrains folks, as they have a competing (and recommended) way of loading Maven projects into the IDE. Until that’s implemented, all the modules are going to be shown regardless of the intention of the developer.

Asking Jooby’s Author Edgar Espina

Edgar sharing his thinking on motivations, pros/cons, reflecting back now he’s accomplished it:

It was easy to start with… especially when I need to make a new release. All the modules are updated to follow the release. This simplifies a lot my work as framework developer but also helps framework users. On upgrades, they just change a single property/value.


Today, it is very very hard to just see the number of submodules in GitHub. It could be considered a GitHub UX issue, too, but also I think Jooby has too many modules and they need to be moved to their own repository. Having modules in their own repository helps when someone needs to change something… They just need to check out the subproject and not the entire repo.

The code coverage project was also hard to implement… It has references to all the existing modules. I need this for producing a single JaCoCo (code coverage) report. JaCoCo doesn’t work well on multi-module projects.

Conclusion and My Opinion

Edgar’s monorepo setup gives him a bunch of nebulous benefits without sacrificing build speed and disk space, given Maven’s build options. Maven’s command line is a little bit cryptic, though; specialist knowledge has to be shared.

Consistency is one of the nebulous benefits. While the wordsmith Emerson is generally right when he says “a foolish consistency is the hobgoblin of little minds,” in this case, he’s wrong — it was worth it.

Expanding and Contracting Monorepos

You may be interested in a previous article of mine on Jooby’s monorepo — specifically, a modification to it that allowed it to expanded and contract (like Google’s) based on the intention of the developer who’s about to do work.

maven ,benchmarking ,monorepo ,jooby

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}