0

I have a maven project and am using the nativedependencies-maven-plugin (https://github.com/fmarot/nativedependencies-maven) to manage the DLL.

The DLL is from a third party, and has the following structure. Let's say that the name of the JAR file is abc.jar and the corresponding DLL is abcxyz.dll, where xyz is the version number without periods. So if the version is 12.6.1, the DLL is named abc1261.dll. If the third party updates their product to version 12.7.0, they issue a new JAR abc.jar and a new DLL abc1270.dll.

I am storing the JAR in a local repository, and the name of the JAR as reflected in the repository is then abc-x.y.z.jar. I put a classifier on the DLL called natives-abc, and the name of the DLL in the repository (once deployed) is abc-x.y.z-natives-abc.dll. When I build the project, abc-x.y.z-natives-abc.dll is then properly copied over to the target/natives folder by the nativedependencies-maven-plugin.

When I run the project from Eclipse, it fails, because the JAR is looking for abcxyz.dll and not abc-x.y.z-natives-abc.dll. If I copy abc-x.y.z-natives-abc.dll into abcxyz.dll in the target/natives folder, then everything works, so I know that the java.library.path is getting set correctly, which I have also verified by inspecting the process using the jinfo tool.

What I need is for the DLL to get renamed once it is copied from the local repository into target/natives. I can't figure out how to make maven do that.

What I want to do is have different versions of abc.jar and abcxyz.dll in the local repository, and then just change the <version> tags in the pom.xml file to refer to different versions. The name of the JAR file in deployment isn't relevant, but it's associated DLL name is relevant because the JAR file from the third party for a specific version looks for a specific DLL name corresponding to the version.

Irv
  • 540
  • 4
  • 13

2 Answers2

2

Maintainer of nativedependencies-maven-plugin here.

I'm not sure I understand completely but I think I have a solution: if you were to deploy/install in you repo (local or not) the .jar (not the .dll) provided by your 3rd party, then when Maven will get this dependency and unzip it (with the nativedependency-maven-plugin), it will keep untouched the name of the .dll inside it. So your code (or the 3rd party code) will correctly find it at runtime.

If your own code loads the DLL, I'd have suggested to rename the DLL to a unique name without the version to simplify the process. Hope it helps.

Ahmed Ashour
  • 5,179
  • 10
  • 35
  • 56
Francois Marot
  • 1,145
  • 11
  • 18
0

The above suggestion worked. What I had to do was create a zip containing abcxyz.dll, (calling it abcxyz.dll.zip), add that to the maven repository using zip packaging, and then make the dependency in pom.xml refer to that.

In other words, here is the section of the pom.xml that had the dependency:

<dependency>
    <groupId>com.thegroup</groupId>
    <artifactId>abc</artifactId>
    <version>12.6.1</version>
    <type>zip</type>
    <classifier>natives-abc</classifier>
</dependency>

I just used WinZip to create the Zip.

mvn deploy:deploy-file -Durl=file:///path-to-my-repo -Dfile=abc1261.dll.zip -DgroupId=com.thegroup -DartifactId=abc -Dpackaging=zip -Dversion=12.6.1 -Dclassifier=natives-abc
Ahmed Ashour
  • 5,179
  • 10
  • 35
  • 56
Irv
  • 540
  • 4
  • 13