DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
  1. DZone
  2. Coding
  3. Java
  4. Benchmarking a Java/Maven Monorepo

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.

Paul Hammant user avatar by
Paul Hammant
·
Apr. 09, 17 · Opinion
Like (3)
Save
Tweet
Share
3.55K Views

Join the DZone community and get the full member experience.

Join For Free

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.

cons?

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.

Monorepo Build (game engine) Apache Maven Space (architecture) JAR (file format)

Published at DZone with permission of Paul Hammant, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • The 5 Books You Absolutely Must Read as an Engineering Manager
  • How To Handle Secrets in Docker
  • Multi-Cloud Integration
  • 11 Observability Tools You Should Know

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: