Monday, April 27, 2015

Maven Shade Plugin to bundle all the SCIs

We are having an Tomcat OSGi bundle which consist of following dependencies.
<artifactId>tomcat-dbcp</artifactId>
<artifactId>tomcat-embed-core</artifactId>
<artifactId>tomcat-embed-jasper</artifactId>
<artifactId>tomcat-embed-websocket</artifactId>
Both tomcat-embed-jasper and tomcat-embed-websocket contains SCIs. I wanted to bundle these dependencies to a single OSGi bundle with all their SCIs. If we use maven-bundle plugin as follows

Since all the SCIs use the same interface javax.servlet.ServletContainerInitializer, based on the order we specify the resource previous references get override and only the last resource SCI will get bundle.

We can use maven-shade-plugin to overcome the issue. It has lot of other features as well. You can refer to the official documentation page for more details about shade-plugin
Maven-shade-plugin

If you wanna combine all the META-INF/services (like what I wanted to do) you can use following configuration

No comments:

Post a Comment