Maven: Creating deployable distribution: Part 1: Using the Appassembler plugin


Often, we have a standalone Java application, from which we want to create a deployable distribution having all the dependencies in one place and with a shell script or bat file which can be then invoked from the command prompt. The Mojo Appassembler plugin helps do just that. We will be using the maven-distribution-example as reference. This project would need the project rmi-service-api to compile.

Using the Appassembler plugin

We have created a profile called all-in-one which can be called to create our distribution:

This profile contains 2 parts:

  1. The appassembler plugin
    1. Collects all the maven dependencies in the target/appassembler/lib
    2. Generates the  .sh and .bat scripts to invoke the main class which is provided
  2. The maven assembly plugin which creates a tar archive from
    1. The appassembler directory
    2. readme.txt file

The maven assembly plugin works using the below assembly descriptor (all-in-one-assembly-descriptor.xml):

Next, we invoke Maven by:

mvn clean package -P all-in-one

Go to the tar file is generated in the target directory. You will find two directories inside the tar:

  1. bin: This contains the shell script and the bat file
  2. lib: This has all the dependant jars

You can now run the Rmi Server by invoking the shell or bat scripts from the prompt.

The sources can be found here:




Leave a Reply

Your email address will not be published. Required fields are marked *