在Maven中使用本地依赖关系 [英] Using native dependencies inside Maven
本文介绍了在Maven中使用本地依赖关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
p>回答我自己的问题: http:// web.archive.org/web/20120308042202/http://www.buildanddeploy.com/node/17
简而言之,你可以使用maven -dependency-plugin:解压缩目标,将库解压缩到已知路径中,并将其传递到 java.library.path
中:
< plugin>
< groupId> org.apache.maven.plugins< / groupId>
< artifactId> maven-dependency-plugin< / artifactId>
<执行>
< execution>
< id> unpack< / id>
< phase> compile< / phase>
< goals>
< goal> unpack< / goal>
< / goals>
< configuration>
< artifactItems>
< artifactItem>
< groupId> org.jdesktop< / groupId>
< artifactId> jdic-native< / artifactId>
< version> $ {jdic.version}< / version>
< classifier> $ {build.type}< / classifier>
< type> jar< / type>
< overWrite> true< / overWrite>
< outputDirectory> $ {project.build.directory} / lib< / outputDirectory>
< / artifactItem>
< / artifactItems>
< / configuration>
< / execution>
< / executions>
< / plugin>
A POM dependency contains native libraries (DLLs inside a JAR file). How do I programmatically look up the path of the downloaded JAR file so I can pass it into "java.library.path"?
解决方案
Answering my own question: http://web.archive.org/web/20120308042202/http://www.buildanddeploy.com/node/17
In short, you can use the maven-dependency-plugin:unpack goal to extract the libraries into a known path, and pass that into java.library.path
:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack</id>
<phase>compile</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.jdesktop</groupId>
<artifactId>jdic-native</artifactId>
<version>${jdic.version}</version>
<classifier>${build.type}</classifier>
<type>jar</type>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
这篇关于在Maven中使用本地依赖关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文