plc4x-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christofer Dutz <christofer.d...@c-ware.de>
Subject Re: Fat-Artefacts and multiple Drivers
Date Tue, 23 Apr 2019 07:25:15 GMT
Another option would be to manually create the file in the resources that lists up all drivers
of the fat jar ...

Chris

Am 23.04.19, 09:22 schrieb "Julian Feinauer" <j.feinauer@pragmaticminds.de>:

    Hi Lukasz, 
    
    thanks for your email.
    I think this is similar to what I now achieved with the assembly plugin.
    As I understand it, the shading plugin is the "big brother" of the assembly plugin as
it can also shade... but I think we don’t need it for this case.
    Just wanted to bring this to the list, as I had this issue multiple times.
    Perhaps we should even write this somewhere in the docu.
    
    Julian
    
    Am 21.04.19, 21:54 schrieb "Łukasz Dywicki" <luke@code-house.org>:
    
        From quick look at issue and description - you might check out maven shade plugin
[1] with its resource transformers [2] which can help you to merge manifests and other things
in case of overlapping occurrences. 
        
        Cheers,
        Łukasz
        
        [1] https://maven.apache.org/plugins/maven-shade-plugin/index.html
        [2] https://maven.apache.org/plugins/maven-shade-plugin/examples/resource-transformers.html
        
        > On 21 Apr 2019, at 14:24, Julian Feinauer <j.feinauer@pragmaticminds.de>
wrote:
        > 
        > 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
        
    
    

Mime
View raw message