mavenmaven-assembly-plugin

Maven assembly plugin - multiple descriptors?


The goal is to create a single ZIP file, but split the configuration of the Maven Assembly plugin into a general and more specific descriptor.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-assembly-plugin</artifactId>
    <version>3.0.0</version>
    <configuration>
        <descriptors>
            <descriptor>${project.basedir}/../src/assembly/rest-executables.xml</descriptor>
            <descriptor>${project.basedir}/../../src/assembly/deliverables.xml</descriptor>
        </descriptors>
    </configuration>
    <executions>
        <execution>
            <id>make-assembly</id>
            <phase>package</phase>
            <goals>
                <goal>single</goal>
            </goals>
        </execution>
    </executions>
</plugin>

However, when the two custom descriptors have unique IDs, two ZIP files are created - each with the expected contents. When the IDs are identical, only the last descriptor is executed (or it overwrites the previous contents).

Is what I'm attempting not possible or am I missing an option somewhere like 'append to existing ZIP' rather than 'always create new ZIP'?


Solution

  • Component Descriptors is definitely the way to go. Yes, I am pulling from the comments, but that is because the accepted answer did not work and I wanted to highlight what @user944849 said. The accepted answer doesn't actually make a difference to the maven assembly plugin, it is just a different way to convey multiple descriptors.

    Component Descriptors however, allow you to define a "component" that can be used in an assembly. So you can define a common set of files, without having to copy and paste all of them into different assemblies.