3
votes

I am looking for a way to merge META-INF/services files, e.g. META-INF/services/javax.ws.rs.ext.Providers, when building jar-with-dependencies using Maven Assembly plugin. I have found answers showing how to do that using Maven Shade plugin. Unfortunately, we are extensively using Mave Assembly plugin already and it is unclear how we could plug Maven Shade plugin...in.

1
@khmarbaise: As I have mentioned in OP, I do not want to use the Shade plugin as it is not clear how I would do that when I am already using Assembly plugin.wilx
Sorry to say than just try it and see how it works...Otherwise it will not work, cause maven-assembly-plugin does not support what you like....maven-shade-plugin supports merging as you like to have ? So I don't see an alternative....khmarbaise
philosophy with assembly plugin is that it will never modify contents, only assemble them. as @khmarbaise pointed out, your needs have outgrown your use of assembly plugin, you are now in the "modify content" world that the shade plugin was created to solve. (hint: you can do both btw, modify with shade, assemble with assembly)Joakim Erdfelt

1 Answers

6
votes

It turns out that some versions of Maven Assembly plugin can merge these files:

<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
    <id>jar-with-dependencies</id>
    <formats>
        <format>jar</format>
    </formats>
    <!-- ... -->
    <containerDescriptorHandlers>
        <containerDescriptorHandler>
            <handlerName>metaInf-services</handlerName>
        </containerDescriptorHandler>
        <containerDescriptorHandler>
            <handlerName>metaInf-spring</handlerName>
        </containerDescriptorHandler>
        <containerDescriptorHandler>
            <handlerName>plexus</handlerName>
        </containerDescriptorHandler>
    </containerDescriptorHandlers>
</assembly>