Mímir
The Maven workstation and LAN cache
Maveniverse Mímir started as solution of my own problem: workstation hopping, and a LOT of download when when picking
up where I left on.
A Maven 3/4 extension that offers “global cache” on workstation, and shares cache via LAN to other Mimir running nodes.
Mímir is on Github: https://github.com/maveniverse/mimir
1 - What is it?
The Maven workstation and LAN cache
Mímir is a Maven 3 and Maven 4 extension that offers global caching on workstations. More precisely, Mímir is a
Resolver 1.x and 2.x extension (is a RepositoryConnector
)
that is loaded via Maven extensions mechanism and extends Resolver.
As you may know, Maven historically uses “local repository” as mixed bag, to store cached artifacts fetched
from remote along with locally build and installed artifacts. Hence, your local repository usually contains
both kind of artifacts.
Mímir alleviates this, by introducing a new workstation wide read-through cache (by default in ~/.mimir/local
) and placing
hardlinks in Maven local repository pointing to Mímir cache entries. This implies several important things:
- you have separated pure cache, unlike existing local repository, that is a mixed bag on your disk.
- because of hardlinks, ideally you have only one copy of any cached artifact on your disk (as opposed to as many, as many local repositories you use).
- is more compatible than “split local repository” as it is in reality “invisible” for Maven and Maven Mojos.
Also some consequences are:
- you can easily adhere to “best practices” and delete your local repository often, as you still have it all locally (in Mímir caches).
You will not lose you precious time by waiting to populate local repository.
- backup or caching (like in CI case) is simple also: instead of tip-toeing and doing trickery with your local repository,
just store and restore Mímir caches instead, you may forget local repository.
Advanced features of Mímir is LAN-wide cache sharing, so if you hop from workstation to workstation on same LAN,
you don’t need to pull everything again, as your build will get it from the workstation that already has it. Nowadays
with Gigabit LANs combined with modern WiFi networks, doing this is usually faster, than going to Maven Central.
2 - Why would I use it?
The Maven workstation and LAN cache
In short: you want to use it for proper local repository maintenance, but it also helps with disk space usage as well,
and real workstation wide caching, irrelevant of how many local repositories you use.
Finally, if you workstation-hop a lot (like I do) on same LAN, it makes pretty much sense to pick up on the new
workstation where you left off on old workstation.
On CI-like setups it also simplifies caching between jobs, as all you need is to store Mímir cache after job finishes,
and on subsequent job runs just restore it.
3 - How to use it?
The Maven workstation and LAN cache
Simplest way to use Mímir is with Maven 4, it supports user wide extensions. Just create ~/.m2/extensions.xml
with following content (adjust Mímir version as needed):
<?xml version="1.0" encoding="UTF-8"?>
<extensions>
<extension>
<groupId>eu.maveniverse.maven.mimir</groupId>
<artifactId>extension</artifactId>
<version>0.4.1</version>
</extension>
</extensions>
Using it with Maven 3 is also possible and completely fine and compatible, but there you will need to set up
per-project extensions in .mvn/extensions.xml
file instead of one user-wide one.
One extra step is needed, in case you have non-trivial networking (like Docker, Tailscale or alike): you need
to “help” a bit to JGroups, to figure out which networking interface belongs to your LAN. To achieve that,
you need to create ~/.mimir/daemon.properties
file with following content (use your LAN IP address):
mimir.jgroups.interface=match-address\:192.168.1.*
This will help JGroups to properly bind to interface that is used on your LAN.
With these, you are fully set up. Now just go and fire up a Maven or Maven Daemon build.
4 - Use case: Maven CI
The Maven workstation and LAN cache
TBD: explain how is Mímir used in Maven GH CI