12

I have added a DLL in my maven project as dependency like this :

<dependency>
  <groupId>com.test.dll</groupId>
  <artifactId>myDll</artifactId>
  <version>0.1</version>
  <type>dll</type>
</dependency>

When I try to execute maven:install

It is giving me this error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.2-   
beta-5:single (jar-with-dependencies) on project testApp: Failed to create 
assembly:    Error adding file-set for 'com.test.dll:myDll:dll:0.1' to archive: Error 
 adding archived file-set. PlexusIoResourceCollection not found for: C:\Users\USER\.m2
 \repository\com\test\dll\myDll\0.1\myDll-0.1.dll: No such archiver: 'dll'

What Am I doing wrong here??

Update

 <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>   
        <executions>
        <execution>
        <goals>
            <goal>sign</goal>
        </goals>
        </execution>
       </executions>
       <configuration>
        <keystore>src/main/keystore/mykey.keystore</keystore>
        <alias>aliasname</alias>
        <storepass>passw0rd</storepass>                  
        <verify>true</verify>

    </configuration>        
    </plugin>               
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-assembly-plugin</artifactId>      
        <executions>
            <execution>
                <id>jar-with-dependencies</id>
                <phase>prepare-package</phase>
                <goals>
                    <goal>single</goal>
                </goals>       
            <configuration>
            <archive>
                <manifest>

                </manifest>
            </archive>              
            <descriptorRefs>
                <descriptorRef>jar-with-dependencies</descriptorRef>
            </descriptorRefs>           
            <appendAssemblyId>false</appendAssemblyId>
        </configuration>
    </execution>     
  </executions>      
  </plugin>   
 </plugins> 
Brian Agnew
  • 268,207
  • 37
  • 334
  • 440
Suave Nti
  • 3,721
  • 11
  • 54
  • 78
  • Could you please post the DLL pom.xml, and your assembly file please. – Jean-Rémy Revy Jul 22 '12 at 08:40
  • @Jean-Rémy : Thank you jean but I dont have any seperate assembly file..The `dependency` part of the dll is posted above. – Suave Nti Jul 22 '12 at 17:31
  • So, could you use the full pom ? The error mention maven-assembly-plugin. I would like to know why if you don't have a assembly file. – Jean-Rémy Revy Jul 23 '12 at 20:52
  • Looks like you have a problem similar to the one [here](http://www.mailinglistarchive.com/html/users@maven.apache.org/2008-07/msg05932.html). You need to provide the snippets for the plugins that you use at least, for someone to help you. Prima facie it appears to be an issue where maven is trying to `unpack` the `dll`. – Raghuram Jul 30 '12 at 17:36
  • @Raghuram : Thanks, Have updated my Question with the `plugins` section. – Suave Nti Jul 30 '12 at 17:41

3 Answers3

9

The problem here is the jar-with-dependencies descriptor. The descriptor unpacks all dependencies into a directory and packages this directory into a new JAR file. However, it cannot unpack a DLL file (that's the "No such archiver" error message). To get this working, you need to define your own assembly descriptor:

<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">

  <id>assembly-with-dll</id>
  <formats>
    <format>jar</format>
  </formats>
  <includeBaseDirectory>false</includeBaseDirectory>
  <dependencySets>
    <!-- package the regular dependencies -->
    <dependencySet>
      <outputDirectory>/</outputDirectory>
      <useProjectArtifact>true</useProjectArtifact>
      <unpack>true</unpack>
      <scope>runtime</scope>
      <!-- exclude the DLL -->
      <excludes>
        <exclude>com.example:my-dll</exclude>
      </excludes>
    </dependencySet>
    <!-- package the DLLs -->
    <dependencySet>
      <outputDirectory>/</outputDirectory>
      <includes>
        <include>com.example:my-dll</include>
      </includes>
    </dependencySet>
  </dependencySets>
</assembly>

Provided, that the descriptor above resides in src/main/assembly, the configuration of the maven-assembly-plugin looks as follows:

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-assembly-plugin</artifactId>
      <executions>
        <execution>
          <id>jar-with-dependencies</id>
          <phase>prepare-package</phase>
          <goals>
            <goal>single</goal>
          </goals>
          <configuration>
            <descriptor>src/main/assembly/assembly.xml</descriptor>
            <appendAssemblyId>false</appendAssemblyId>
          </configuration>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>
Stefan Ferstl
  • 5,135
  • 3
  • 33
  • 41
0

There is a piece of information here : Maven Dll Dependency Problem. To solve this issue, exlude dll from your assembly :

<excludes>
    <exclude>*:dll*</exclude>
</excludes>

Last time I had to create a executable jar with dependencies, I put them out of the jar, in a lib directory. DLL must be :

  • either in application classpath (like server/lib for a server)
  • or in the OS classpath (C:\Windows\system32 for instance)

After reading your pom and dependecy file set, I may be able to be more accurate :)

Community
  • 1
  • 1
Jean-Rémy Revy
  • 5,607
  • 3
  • 39
  • 65
0

To add to Stefan's answer, I don't think you want to do a jar-with-dependencies packaging for this project of yours. You should look at using one of the bin packaging (like .zip or tar.gz)

Raghuram
  • 51,854
  • 11
  • 110
  • 122