I’m trying to create a distributable zip of my project that contains several configuration files and directories, as well as the executable jar of my project. In the Maven assembly plug-in, I’ve found how to make the executable jar with full dependencies. However, I haven’t been able to figure out how to create the zip file around the jar after it has been made. Ideally, I’d like to move the jar to a directory which already has the correct files and sub-directories, then zip the whole thing at once. Is there any way to do this?
edit:
I now have the jar building, and a rudimentary zip as well. My assembly file looks like this:
<assembly>
<id>financials-import-server</id>
<formats>
<format>zip</format>
</formats>
<dependencySets>
<dependencySet>
</dependencySet>
</dependencySets>
<files>
<file>
<source>target/import-server-1.0.0-SNAPSHOT.jar</source>
<destName>service.jar</destName>
<outputDirectory>/</outputDirectory>
</file>
</files>
</assembly>
I feel comfortable including the other files I would need, such as config files or shell scripts. I have a few questions remaining. How would I create empty directories within the zip? Also, how do I change the name of the file that is produced?
Thanks for the help!
First, use the Maven JAR plugin to create an executable JAR.
Then, configure your assembly to include all the files needed (eventually you can add a
run.bat/run.shfile that will launches the application), and also all dependencies.Finally, bind the assembly creation to your package goal in the
pom.xml:This way, you will simply need to run one Maven command
mvn clean installfor example, to compile your project, and then creates the ZIP package.Do not hesitate to update your question if my answer doesn’t fit your needs, and you can also give your current
assembly.xmlandpom.xml…Edit
Regarding your update:
I don’t think the assembly will let you create an empty directory. An idea is to put an empty file (or a
readme.txtfor example) and include the directory in the final ZIP. For example, in my project, I want to have alogs/directory, so I have alogs/directory in my project which only contains areadme.txtfile:For the name of the ZIP created, you can specify it in the
pom.xml:If I am correct, the assembly will use this name, add the
IDdefined in theassembly.xmlfile, and uses the prefix adapted to the format specified.