如何从Maven repo引用本机DLL?

Ole*_*eev 5 java maven

如果JAR伴随着Maven repo中的本机DLL,我需要将哪些内容放入我的pom.xml以将该DLL放入包装中?

更具体地说,例如雅各布库.你怎么运行后jacob-1.14.3-x64.dll进入该WEB-INF/lib文件夹mvn package

在我们的本地Nexus存储库中,我们有JAR和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>
Run Code Online (Sandbox Code Playgroud)

但是将相同的依赖项放到我们的项目POM并运行mvn package并不会使DLL进入WEB-INF/lib,但JAR可以很好地完成.

我们做错了什么?

Sas*_*ter 8

感谢Monty0018的提示,我能够解决问题.适用于我的maven代码:

<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>
Run Code Online (Sandbox Code Playgroud)


Mon*_*018 6

对于DLL,您将需要使用复制依赖项MOJO.

您可以过滤除DLL之外的所有依赖项,并指定项目结构中的任何位置以将其复制到,包括target/webapp/WEB-INF/lib.