I have 3 modules which are linked to a parent project. I need to create a zip file including all these projects. I know it can be done using maven assembly plugin. But in which pom.xml should I use it. Is there a way I can copy the resources from 3 projects in to 1 common folder. Is there any example available for the same. This is a multi module build
For such purposes the best ways is to create a separate module in your multi-module build which result into the following strcuture:
root (pom.xml)
+--- mod1 (pom.xml)
+--- mod2 (pom.xml)
+--- mod3 (pom.xml)
+--- mod-package (pom.xml)
The pom.xml of mod-package looks like this:
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.soebes.packaging.test</groupId>
<artifactId>root</artifactId>
<version>0.1.0-SNAPSHOT</version>
</parent>
<artifactId>mod-package</artifactId>
<packaging>pom</packaging>
<name>Packaging :: Mod Package</name>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.3</version>
<configuration>
<descriptors>
<descriptor>pack.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>package-the-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
And don't forget the pack.xml file which is located in mod-package/pack.xml:
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>pack</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<moduleSets>
<moduleSet>
<!-- Enable access to all projects in the current multimodule build! -->
<useAllReactorProjects>true</useAllReactorProjects>
<binaries>
<outputDirectory>modules/${artifactId}</outputDirectory>
<unpack>false</unpack>
</binaries>
</moduleSet>
</moduleSets>
</assembly>