Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Including shared object in maven assembly

I'm currently trying to build my project with maven and sqlite4java. Which is available in the offical maven repositories. The offical sqlite4java page on google code does have an example configuration but it's a bit outdated and does not suit my needs. I want to have a single .jar-File in the end which i can deploy elsewhere. The problem here is the shared object depedency. I am using the official build goal from their page to copy the so to the build.dir/lib but my assembly goal crashes with:

[INFO] Failed to create assembly: Error adding file-set for 'com.almworks.sqlite4java:libsqlite4java-linux-i386:so:0.282' to archive: Error adding archived file-set. PlexusIoResourceCollection not found for: /home/lhw/.m2/repository/com/almworks/sqlite4java/libsqlite4java-linux-i386/0.282/libsqlite4java-linux-i386-0.282.so
No such archiver: 'so'.

​ What am I doing wrong? Here is my current pom.xml stripped from some dependencies unrelated to this topic

<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>de.ring0.lhw</groupId>
  <artifactId>system</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <dependencies>
    <dependency>
      <groupId>com.almworks.sqlite4java</groupId>
      <artifactId>sqlite4java</artifactId>
      <version>${sqlite4java.version}</version>
    </dependency>
    <dependency>
      <groupId>com.almworks.sqlite4java</groupId>
      <artifactId>libsqlite4java-linux-i386</artifactId>
      <version>${sqlite4java.version}</version>
      <type>so</type>
    </dependency>
  </dependencies>
  <properties>
    <sqlite4java.version>0.282</sqlite4java.version>
  </properties>
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <id>copy</id>
            <phase>compile</phase>
            <goals>
              <goal>copy</goal>
            </goals>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>com.almworks.sqlite4java</groupId>
                  <artifactId>libsqlite4java-linux-i386</artifactId>
                  <version>${sqlite4java.version}</version>
                  <type>so</type>
                  <overWrite>true</overWrite>
                  <outputDirectory>${project.build.directory}/lib</outputDirectory>
                </artifactItem>
              </artifactItems>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.5.1</version>
        <configuration>
          <source>1.6</source>
          <target>1.6</target>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.12.2</version>
        <configuration>
          <skipTests>true</skipTests>
          <systemProperties>
            <property>
              <name>sqlite4java.library.path</name>
              <value>${project.build.directory}/lib</value>
            </property>
          </systemProperties>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
            <configuration>
              <archive>
                <manifest>
                  <mainClass>de.ring0.lhw.Init</mainClass>
                </manifest>
              </archive>
              <descriptorRefs>
                <descriptorRef>jar-with-dependencies</descriptorRef>
              </descriptorRefs>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>
like image 552
lhw Avatar asked Aug 30 '12 12:08

lhw


People also ask

What is fileset in Maven?

Defines the rules for matching and working with files in a given base directory.

How does Maven Assembly plugin work?

The Assembly Plugin for Maven enables developers to combine project output into a single distributable archive that also contains dependencies, modules, site documentation, and other files. Your project can easily build distribution "assemblies" using one of the prefabricated assembly descriptors.

What is assembly descriptor in Maven?

This descriptor specifies the type of assembly archive to create, the contents of the assembly, and the ways in which dependencies or its modules are bundled with an assembly. <assembly xmlns="http://maven.apache.org/ASSEMBLY/2.1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

Are Maven dependencies included in jar?

The difference is that the Maven Assembly Plugin will automatically copy all required dependencies into a jar file.


1 Answers

Edit :

I think that the jar-with-dependencies assembly descriptor tries to unpack the dependencies.

See the link :

http://maven.apache.org/plugins/maven-assembly-plugin/descriptor-refs.html

maven.apache.org/plugins/maven-assembly-plugin/… ...

<unpack>true</unpack>

And of course it fails to unpack the .so

So you might have to use a custom assembly to perform what you want to do

like image 120
Samuel EUSTACHI Avatar answered Sep 20 '22 10:09

Samuel EUSTACHI