6

If a JAR is accompanied with a native DLL in Maven repo what do I need to put into my pom.xml to get that DLL into the packaging?

To be more specific take for example Jacob library. How do you make jacob-1.14.3-x64.dll go into the WEB-INF/lib folder after you run mvn package?

In our local Nexus repository we've got these definitions for JAR and DLL:

<dependency>
  <groupId>net.sf.jacob-project</groupId>
  <artifactId>jacob</artifactId>
  <version>1.16-M2</version>
</dependency>

<dependency>
  <groupId>net.sf.jacob-project</groupId>
  <artifactId>jacob</artifactId>
  <version>1.16-M2</version>
  <classifier>x64</classifier>
  <type>dll</type>
</dependency>

But putting the same dependencies to our project POM and running mvn package doesn't make DLL go to WEB-INF/lib, but JAR gets there fine.

What are we doing wrong?

Oleg Mikheev
  • 17,186
  • 14
  • 73
  • 95

2 Answers2

7

Thanks to the hint from Monty0018 I was able to solve the problem. The maven code that works for me:

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-dependency-plugin</artifactId>
      <executions>
        <execution>
          <id>copy-dependencies</id>
          <phase>prepare-package</phase>
          <goals>
            <goal>copy-dependencies</goal>
          </goals>
          <configuration>
            <excludeTransitive>true</excludeTransitive>
            <includeArtifactIds>jacob</includeArtifactIds>
            <failOnMissingClassifierArtifact>true</failOnMissingClassifierArtifact>
            <silent>false</silent>
            <outputDirectory>target/APPNAME/WEB-INF/lib</outputDirectory>
            <overWriteReleases>true</overWriteReleases>
            <overWriteSnapshots>true</overWriteSnapshots>
            <overWriteIfNewer>true</overWriteIfNewer>
          </configuration>
        </execution>
      </executions>
    </plugin>
  </plugins>
 </build>
Sascha Vetter
  • 2,466
  • 1
  • 19
  • 36
  • 1
    Can you tell me one thing: How does it work your solution ? Must you modify path of libararies during starting ? Must you do something else thatn modyfiying pom.xml ? –  Mar 09 '17 at 18:01
6

For a DLL, you will need to use the Copy Dependencies MOJO.

You can filter out all dependencies other than the DLL and specify anywhere in your project structure to copy them to, including your target/webapp/WEB-INF/lib.

Monty0018
  • 193
  • 11