Bootstrapping Java applications with Maven (under the hood)

Maven is a great build tool – once you get used to its XML configuration file and figure what plugins are to be used for what purpose. However,  if you only want to build an application from already existing Maven artifacts, then it is a massive overkill to write an XML file and configure all the plugins. Quite a while ago, I had an idea to utilize Maven’s ability to manage dependencies and download the jars with a simple Java application where you (more or less) only specify the artifacts that you want to use.

Well, long story short, last weekend, I put together a little hack that managed to achieve this and I turned this into a proper command-line application over the last few days, calling it bootstrapp.

The application comes bundled with Maven and you only need to have Java installed on the machine for building applications. When executed, a Maven installation with get extracted (if necessary) and used for resolving and pulling in the dependencies. For generating the application from the dependencies, a pom.xml file is generated from a template and then executed with Maven.

The following example generates an application for Weka 3.9.4 and the PLS package in the ./out directory (including shell/batch scripts for launching the Weka GUI):

java -jar bootstrapp-0.0.1-spring-boot.jar \
  -d nz.ac.waikato.cms.weka:weka-dev:3.9.4 \
  -d nz.ac.waikato.cms.weka:partialLeastSquares:1.0.5 \
  -s \
  -o ./out \
  -v -Xmx1g \
  -c weka.gui.GUIChooser \
  -e

I’m planning on re-using this application for my ADAMS framework, making it easier to create custom ADAMS applications on the fly, without having to rely on build scripts or a build server.