Managing DLL dependencies with Maven

2019-01-06 14:24发布

I have a Java program with Maven managing its dependencies. One of those dependency is a JNI wrapper for another program. Maven takes care of the reference to the relevant JAR file, but I'm left messing around with the DLL file myself.

Is there a good way of having Maven handle the DLL as well? Ideally I would like to have the DLL loaded into our local repository like the JAR file.

2条回答
别忘想泡老子
2楼-- · 2019-01-06 15:04

Did you try something like this:

<dependency>
    <groupId>com.foo</groupId>
    <artifactId>footron</artifactId>
    <version>4.2</version>
    <scope>runtime</scope>
    <type>dll</type>
</dependency>

You can add them to maven's repository with something like this:

mvn install:install-file -Dfile=footron.dll -DgroupId=com.foo -DartifactId=footron  -Dversion=4.2 -Dpackaging=dll -DgeneratePom=true 

Haven't done this for DLLs but something like this should work.

查看更多
啃猪蹄的小仙女
3楼-- · 2019-01-06 15:11

I found another solution, which is described in the answer to this question: Using maven with DLL from third party and managing the name of the DLL

Basically, if you put the DLL into a ZIP file, and manage it as a separate dependency, and use the nativedependencies-maven-plugin, then the DLL will get unpacked with the right name.

查看更多
登录 后发表回答