Search code examples
mavenmaven-assembly-pluginmulti-module

Maven assembly useAllReactorProjects in child module not work


Maven assembly plugin for a multi modules project does not collect all sub modules.

Here is the hierarchy of my project (in terms of maven parent/child) :

ss.parent (parent multi module)
   |_ ss.a (parent multi module)
         |_ ss.a.1
         |_ ss.a.2
   |_ ss.b (parent multi module)
         |_ ss.b.2
         |_ ss.b.2
   |_ ss.assembly

The ss.parent/pom.xml contains :

<module>ss.a</module>
<module>ss.b</module>
<module>ss.assembly</module>

Here is the ss.assembly/pom.xml

<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">
<modelVersion>4.0.0</modelVersion>
<parent>
    <groupId>ss</groupId>
    <artifactId>ss.parent</artifactId>
    <version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>sis.assembly</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<description>Produces delivery for MOSS</description>

<build>
    <plugins>
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.6</version>
            <configuration>
                <descriptor>src/assembly/assembly.xml</descriptor>
            </configuration>
            <executions>
                <execution>
                    <id>create-archive</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

<dependencies>
    <dependency>
        <groupId>ss</groupId>
        <artifactId>ss.a</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupId>ss</groupId>
        <artifactId>ss.b</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </dependency>
</dependencies>

assembly.xml :

<id>assembly</id>
<formats>
    <format>dir</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<moduleSets>
    <moduleSet>
        <useAllReactorProjects>true</useAllReactorProjects>
        <includeSubModules>true</includeSubModules>
        <includes>
          <include>*:*</include>
        </includes>
        <binaries>
            <outputDirectory>assembly</outputDirectory>
            <unpack>false</unpack>
        </binaries>
    </moduleSet>
</moduleSets>

What I expect as a result is an assemly containing :

  • ss.a.1.jar
  • ss.a.2.jar
  • ss.b.1.jar
  • ss.b.2.jar

BUT, what I have is only ss.a.1.jar and ss.a.2.jar ! It seems that maven stops just after the first multi module (i.e ss.a).

Any idea ? Thanks.


Solution

  • I found the problem :)

    It was that by default maven assembly plugin selects artefact without classifier (or none as classifier). Indeed, the module ss.b produces artefacts with a classifier that is not none, that's why it was ignored.