title: Add Native Shared Library (.so or .dll/.lib) to Jar File Using Maven Plugin
body: <p>There are lots of posts about this already but I have not found one that describes my exact situation. Which is:</p>
  
  <ol>
  <li>I have a preexisting build system that generates a C++ shared library in both .dll and .so format (depends on OS).</li>
  <li>The build system also produces a set of java files generated by swig.</li>
  <li>I also have a pom.xml file that builds the java source into a package.</li>
  </ol>
  
  <p>What I need is a plugin for maven that simply copies the native shared library into the jar. It would be nice if the native shared library was also loadable from within the jar so clients don't have to manually add it to the library path. This seems like a problem that has been solved before.</p>
  
  <p>I have looked at <a href="http://maven.apache.org/plugins/maven-dependency-plugin/index.html" rel="nofollow noreferrer">maven-dependency-plugin</a>. Which seems to be able to copy artifacts that are in a maven repository (not my case). Or if you use an assembly it might be possible. However, if it is possible, it seems overly complicated for what I want to accomplish. I would like to accomplish it with only a pom.xml.</p>
  
  <p>I have also looked at <a href="http://maven-nar.github.io/usage.html" rel="nofollow noreferrer">nar-maven-plugin</a>, but this seems like it focuses only on building the native library and adding it to a .nar file. This is not what I need since I can already build the C++ library.</p>
  
  <p>Finally, I looked at <a href="https://code.google.com/p/onejar-maven-plugin/" rel="nofollow noreferrer">one-jar</a> which I got to place the native library inside the jar. However, I was not able to import the classes from within that jar, and the clients of this library will expect to be able to do that.</p>
  
  <p>If what I want is possible and I don't need to <a href="https://stackoverflow.com/questions/5692256/maven-best-way-of-linking-custom-external-jar-to-my-project">install the shared library into my local repository</a>  please provide a link or an example of how you accomplished it. If it is not possible, please state why.</p>