maven zip uber-jar and shell script
You don't want to use the maven-assembly-plugin
for creating the uber-jar. But you will want to use it to create that ZIP.
Currently, your maven-shade-plugin
is bound to the package
phase. You could shift that execution to the prepare-package
phase (since it actually prepares your final packaging) add an execution of the maven-assembly-plugin
bound to the package
phase. Your assembly would create a ZIP based on the shaded JAR (which will exist since the shade plugin will have been executed) and the shell script.
A sample descriptor would be the following:
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd"> <id>your-id</id> <formats> <format>zip</format> </formats> <files> <file> <source>${project.build.directory}/projB-shaded.jar</source> <outputDirectory>/</outputDirectory> </file> <file> <source>/path/to/mvn_script.sh</source> <outputDirectory>/</outputDirectory> </file> </files></assembly>
with the following POM configuration:
<plugin> <artifactId>maven-shade-plugin</artifactId> <version>2.4.3</version> <executions> <execution> <phase>prepare-package</phase> <goals> <goal>shade</goal> </goals> <configuration> <!-- current configuration --> </configuration> </execution> </executions></plugin><plugin> <artifactId>maven-assembly-plugin</artifactId> <version>2.6</version> <executions> <execution> <id>assemble</id> <goals> <goal>single</goal> </goals> <phase>package</phase> <configuration> <descriptors> <descriptor>/path/to/assembly.xml</descriptor> </descriptors> </configuration> </execution> </executions></plugin>
The typical location for the assembly descritor is under src/assembly
as per the Maven standard directory layout.