Monthly Archives: August 2014

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:




Invoking Ant from Maven: The Maven AntRun Plugin


In my previous entries, Accessing Maven dependencies through Ant: Part 1 and Part 2 , I had been talking about how we can explore Maven dependencies from Ant. Here, we will talk about how we can do the reverse, that is, invoke Ant from within Maven. I guess this is the more common scenario of the two. Often we have encountered a legacy project which has Ant as the build tool, and we need to integrate that with Maven, often invoking the Ant’s build file from pom.xml. We will continue using our RMI Sever as an example.

We will actually use the Idiot’s paradigm © to demonstrate how to invoke Ant through Maven.

Using the Maven AntRun Plugin

Is pretty straight forward. I have created a Profile called AetherAntTaskExample, which looks like:

You invoke this by doing:

mvn clean package -P AetherAntTaskExample

The ant file is invoked and executed. The original pom.xml can be found here.

Accessing Maven dependencies through Ant: Part 2: The Aether Ant Tasks


This is the 2nd increment of this series. Here is Part 1:

The context and the problem remains same: we want to access Maven dependencies through Ant. We will continue using the Rmi Server as an example.

What is Aether?

Aether is an API which facilitates accessing artifacts from various repositories like Maven, Nexus, Central, etc. From Maven 3 onwards, Maven is fully Aether compliant.


I was not able to get Aether work on a complex Maven project having both Spring 2.x and 3.x: it invariably messes up. But with simpler modules, it seems to work fine. Though Aether is still very much bleeding edge and yet to stabilize, I believe thats the way to go, as it makes accessing artifacts language agnostic.

Using the Aether Ant Tasks

This is how my ant file build-with-aether-ant-task.xml looks like:

Invoking Ant

Use the following command:

ant -f build-with-aether-ant-task.xml -Dproject.version=1.0

You should see a zip with all the dependencies in the target folder.

Accessing Maven dependencies through Ant: Part 1: The Maven Ant Tasks


I have a project which is managed by Maven. Suppose for some reason, best know to me :), I want to do the following using Ant:

  1. Inspect the project’s dependencies
  2. Zip all the dependencies together

This can be achieved by using the Maven Ant Tasks.

Project Structure

We will take the Rmi Server as an example to demonstrate how we can access Maven dependencies in Ant through the Maven Ant Tasks.

The pom.xml looks like this:

Building the project with Ant

The following is how my ant file, build-with-maven-ant-task.xml, looks:

Invoking Ant

From the command prompt, issue the following command:

ant -f build-with-maven-ant-task.xml -Dproject.version=1.0

In the target folder, you should see the, containing all the dependencies of the project.