Including Module Sources


It is common practice to create an assembly using the parent POM of a multimodule build. At times, you may want to ensure that this assembly also includes the source code from one or more of the modules in this build.

This example demonstrates how to include the project sources from a module in the project assembly, under the directory sources/<module-name>.

The Assembly Descriptor

First, let's write an assembly descriptor to create this assembly. For the sake of clarity, this descriptor will be as simple as possible, only demonstrating the features described by this example.

<assembly xmlns=""

This descriptor states that the assembly id should be src, that the output format is a directory, and that the contents of the assembly should not be contained within a directory named after the finalName of the top-level project.

Furthermore, it states that we wish to include the source files for the module with a groupId of org.test and an artifactId of child1. These sources should be contained within the directory structure sources/child1 for this module, since the outputDirectory expression will be interpolated on a module-by-module basis.


Now, let's review the POM configuration necessary to enable the building of this assembly via the assembly:directory mojo:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns=""





This POM simply directs the Assembly Plugin to use the src.xml assembly descriptor when executing.


To build the assembly, we issue the following command:

mvn clean assembly:directory

This will ensure that the output directory (normally, target), is removed before building the assembly directory.

Examining the Output

When the Maven execution completes, the following directory structure should be left:

`-- sources
    `-- child1
        |-- pom.xml
        `-- src
            |-- main
            |   `-- java
            |       `-- org
            |           `-- test
            |               `--
            `-- test
                `-- java
                    `-- org
                        `-- test