Hi all, I just stumbled upon something, I think I observed before, but wanted to bring it back to the list (again). First off, I’m unsure if it’s a bug or a feature so lets discuss this (and if it’s a feature, here is an explanation how to deal with it gracefully).
For my interop server (see PLC4X-111) I built a server which other languages can run in the background to issue queries against. Thus, a “fat-jar” was necessary (which I created using the assembly plugin). And after that, I observed that I can only use ONE driver, all others do “not work”. This is, due to the fact, that our service files (under META-INF/service) are overwritten, with the default configuration as they are copied together. If one uses the maven assembly plugin this can be solved as there are container descriptor handlers [1] which copy all lines from all these files together. But, if using these, one needs to create a separate assembly descriptor. Mine is ``` <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"> <!-- TODO: a jarjar format would be better --> <id>jar-with-dependencies</id> <formats> <format>jar</format> </formats> <includeBaseDirectory>false</includeBaseDirectory> <dependencySets> <dependencySet> <outputDirectory>/</outputDirectory> <useProjectArtifact>true</useProjectArtifact> <unpack>true</unpack> <scope>runtime</scope> </dependencySet> </dependencySets> <containerDescriptorHandlers> <containerDescriptorHandler> <handlerName>metaInf-services</handlerName> </containerDescriptorHandler> </containerDescriptorHandlers> </assembly> ``` This is basically the default “jar-with-dependencies” plus the container descriptor handler for the meta-inf/services files. This xml should be placed unter src/assembly (states the docu). Then, the pom has to adapted in the following way: ``` <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-assembly-plugin</artifactId> <version>2.5.3</version> <configuration> <!-- get all project dependencies --> <!-- <descriptorRefs>--> <!-- <descriptorRef>jar-with-dependencies</descriptorRef>--> <!-- <descriptorRef>metaInf-services</descriptorRef>--> <!-- </descriptorRefs>--> <descriptors>src/assembly/assembly.xml</descriptors> <!-- MainClass in mainfest make a executable jar --> <archive> <manifest> <mainClass>org.apache.plc4x.interop.impl.Server</mainClass> </manifest> </archive> </configuration> <executions> <execution> <id>make-assembly</id> <!-- bind to the packaging phase --> <phase>package</phase> <goals> <goal>single</goal> </goals> </execution> </executions> </plugin> ``` The finally packed “fat-jar” works then flawlessly and with multiple implementations of the same Service. Is this the way we agree to go? Is my setting correct? Julian PS.: This code (above) can be found in my implementation for PLC4X-111 the interop server, see [2]. [1] https://maven.apache.org/plugins/maven-assembly-plugin/examples/single/using-container-descriptor-handlers.html# [2] https://github.com/apache/incubator-plc4x/tree/7aeefaf5df63c6e235256d5d1140d4c5dd7d1047