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.
We have created a profile called all-in-one which can be called to create our distribution:
all-in-one org.codehaus.mojo appassembler-maven-plugin 1.8.1 flat lib true unix windows com.swayam.demo.rmi.server.core.SpringNonSecureRmiServer run_rmi_server package assemble org.apache.maven.plugins maven-assembly-plugin 2.4 src/assembly/all-in-one-assembly-descriptor.xml assemble-all package single
This profile contains 2 parts:
The maven assembly plugin works using the below assembly descriptor (all-in-one-assembly-descriptor.xml):
all-in-one tar false ${project.basedir}/src/static / readme.txt ${project.build.directory}/appassembler / **/**
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:
You can now run the Rmi Server by invoking the shell or bat scripts from the prompt.
The sources can be found here: https://github.com/paawak/blog/tree/master/code/maven-ant-assembly-example