Wiki

Clone wiki

maven-repository-launcher / Home

Welcome

The maven repository launcher is quite possibly something that only I am interested in. It makes it possible to configure a group id, artifact id and optional version (or latest if none specified) and run a particular class as an application with all dependencies provided.

The need

I started this project because I have an etl agent project I run as a windows service on a few different machines, and it was getting tedious building and moving jar files around the network to keep them all up to date. Now I simply publish the artifacts to central, and once there, I can bounce the services and the correct version will be pulled from maven and executed.

Components

The launcher consists of two parts: a Bootstrapper and a launcher.

The Bootstrapper

The bootstrapper does nothing more than load the launcher from a jar file (with all the launcher dependencies jarred together) and then call public static void main(String [] argv) on that class. The bootstrapper is required because if the launcher runs on its own, all of the dependencies it has (and there are a LOT) they would interfere with any versions the target project linked to.

The Launcher

The launcher uses Aether and some sample code from eclipse to access maven central and pull down either a specific maven group/artifact/version, or else the most recent version available, then constructs a classloader with all artifacts resolved in the dependency tree. Once the class is loaded it calls the public static void main(String [] argv) method of that class and it's job is done.

The Launcher acts like any other good maven citizen and utilizes a persistent local repository so central is only required for pulling down new versions.

Updated