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.
Merging META-INF/services files with Maven Assembly plugin
Asked Answered
How about this: maven.apache.org/plugins/maven-shade-plugin/usage.html –
Drome
@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. –
Alvita
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.... –
Drome
philosophy with assembly plugin is that it will never modify contents, only assemble them. as @Drome 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) –
Lepanto
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>
Worked for me. Thanks for the solution. –
Dormant
@Surabhi Mundra I also have similar requirement, Could you please provide sample how you did it ? I see above accepted example with mutliple folder. how to merge providers ? –
Dodd
© 2022 - 2024 — McMap. All rights reserved.