Issue
Can someone please help me in creating a zip target instead of jar in maven. I tried several ways but couldn't progress. Given descriptor file in the assembly path is as follows:
<assembly>
<formats>
<format>zip</format>
</formats>
<fileSets>
<fileSet>
<directory>src/main</directory>
</fileSet>
</fileSets>
</assembly>
The assembly plugin section in my pom file is as follows:
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>src/assembly/descriptor.xml</descriptor>
</descriptors>
</configuration>
</plugin>
</plugins>
</build>
Final Output:
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ sql1 ---
[INFO] Building jar: C:\Divakar\mvn_project\sql1\target\sql1-0.1.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
Solution
You need to bind the plugin to a particular build lifecycle phase via execution like this:
<executions>
<execution>
<id>make-zip</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
Afterwards you can do it via mvn clean package
.
Answered By - khmarbaise