The 'Booter' Mechanism

Overview

The Booter mechanism is a solution to tame long classpath problems. The idea is to have a small main part which will read the different dependency information via an XML file into Java and create a classpath out of it and start your part afterwards.

How to configure the Booter mechanism

The first thing you have to configure is the main class which contains your main part which should be executed after the booter mechanism has built up the classpath which makes it available to you. The next thing is you have to give the platforms for which your start scripts has to be created. These are the scripts which will start your program from command line. An example how an configuration can look like is shown in the excerpt below:

  <configuration>
    <daemons>
      <daemon>
      <id>my-server</id>
      <mainClass>org.codehaus.mojo.appassembler.example.helloworld.HelloWorld</mainClass>
      <platforms>
        <platform>booter-unix</platform>
        <platform>booter-windows</platform>
      </platforms>
      </daemon>
    </daemons>
  </configuration>

The next part is to generate your scripts during the execution of the maven lifecycle. The goal generate-daemons is responsible for the creation of the scripts for their appropriate platforms whereas the create-repository goal is responsible to create a repository which contains all the dependencies you need to run your program.

  <executions>
    <execution>
      <goals>
        <goal>generate-daemons</goal>
        <goal>create-repository</goal>
      </goals>
    </execution>
  </executions>

A part which is really important that you define the appassembler-booter artifact as a dependency to your project cause it contains the part which is executed first and will read the XML file which contains the definitions of the dependencies to build the classpath for your program.

  <dependencies>
    <dependency>
      <groupId>org.codehaus.mojo.appassembler</groupId>
      <artifactId>appassembler-booter</artifactId>
      <version>1.10</version>
    </dependency>
  </dependencies>

Based on the above configuration you will find the created structure under target folder which is described in the booter structure.