Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to reference native DLL from Maven repo?

Tags:

java

maven

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?

like image 896
Oleg Mikheev Avatar asked Jan 15 '12 21:01

Oleg Mikheev


2 Answers

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>
like image 81
Sascha Vetter Avatar answered Nov 04 '22 14:11

Sascha Vetter


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.

like image 28
Monty0018 Avatar answered Nov 04 '22 15:11

Monty0018