Add Native Shared Library (.so or .dll / .lib) to Jar file using Maven Plugin

There are already a lot of reports about this, but I did not find what describes my exact situation. What is:

  • I have an existing build system that generates a common C ++ library in .dll and .so format (OS dependent).
  • The build system also creates a set of java files generated by swig.
  • I also have a pom.xml file that creates a java source in a package.

I need a maven plugin that just copies its own library to the jar. It would be nice if the built-in shared library was loaded from within the jar, so clients do not need to manually add it to the library path. This is similar to the problem that was solved earlier.

I looked at maven-dependency-plugin . Which seems to be able to copy artifacts that are in the maven repository (not in my case). Or, if you are using assembly, this may be possible. However, if possible, this seems too complicated for what I want to accomplish. I would like to execute it only with pom.xml.

I also looked at nar-maven-plugin , but it looks like it focuses only on creating a native library and adding it to the .nar file. This is not what I need, since I can already create a C ++ library.

Finally, I looked at one-jar , which I should place in the library inside the library. However, I was not able to import classes from this jar, and the clients of this library expect to be able to do this.

, , , , , , , , .

+4

Source: https://habr.com/ru/post/1616295/


All Articles