I’m just beginning to grasp the setup of maven2 while porting over a simple project of mine. I’ve ran through the package command line example on the Sonatype web site but I’m a bit confused of how I could expand and change the packaging of this project. I’ve tried to find more information on this subject but I think I’m either thinking about the problem wrong or phrasing the searches wrong.
Essentially I want to build a project that would be a zip of all the dependency jars, the main jar itself, batch scripts to start it for convenience and maybe other various files for the application (like properties files or something). However, I don’t want these all bundled into the jar. I’d like to just have a compressed archive build of the project with a lib directory of all the jars, the root containing properties files and batch scripts and maybe sub folders to hold extra non-essential files. Kind of like:
- sample-proj.zip:
- easy.bat
- props.ini
- lib
- dependent1.jar
- dependent2.jar
- main.jar
- sub_dir
- someextrafile.txt
What’s the correct way of building a project like this using maven2? Do I need to make a parent project that builds the zip and includes the sub project as a module? This would be just a simple project that wouldn’t need to be multi-module…
Building on matt b’s answer. Here’s some examples of how to use the referenced plugins. Note the executions are bound to the integration-test phase to ensure the jar has been created before attempting to package it.
The appassembler-maven-plugin will generate batch/shell files, download the dependencies (in this example to the lib directory), and place all the contents in target/appassembler
The assembly plugin can be used to package the appassembler output into a zip:
And the assembly descriptor looks something like this: