views:

22

answers:

2

I have a multi-module Maven project, and I would like to assemble together artifacts created by running the assembly plugin on individual modules. Is this possible?

+1  A: 

Yes it is possible to do so using the project dependencies which can read in detail on the documentation of the Maven Assembly Plugin.

khmarbaise
A: 

I think I have found the answer to my own problem by running the assembly plugin during the package phase for each sub-module. This guarantees that when I run the assembly on the top level project, all sub-modules would have been assembled.

The plugin configuration in my top level POM looks like:

<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd"&gt;
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.quantel</groupId>
    <artifactId>project-folders-modules</artifactId>
    <version>1.0</version>
    <packaging>pom</packaging>
    <description>Collection of modules for project folders. </description>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <modules>
        <module>db-controller</module>
    </modules>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <ignoreDirFormatExtensions>true</ignoreDirFormatExtensions>
                    <descriptors>
                        <descriptor>src/main/assembly/assembly.xml</descriptor>
                    </descriptors>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>

            </plugin>
        </plugins>
    </build>
</project>
Guillaume