It is doable, but not that simple. You need to set LD_LIBRARY_PATH environment variable. It needs to include your own shareable libraries, those of dependencies, and then where your added library is. I use the following for surefire, because I need to have the Oracle shareable library in my path when I test my JNI project.
Please note:
- You need to exclude the variable first, because the Java setenv will not overwrite.
- This is for a JNI project, the exact path is different for other types of projects.
- This example does not have other dependencies.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludedEnvironmentVariables>
<excludedEnvironmentVariable>LD_LIBRARY_PATH</excludedEnvironmentVariable>
</excludedEnvironmentVariables>
<environmentVariables>
<LD_LIBRARY_PATH>${env.ORACLE_HOME}/lib:${project.build.directory}/nar/${project.artifactId}-${project.version}-${nar.aol}-jni/lib/${nar.aol}/jni</LD_LIBRARY_PATH>
</environmentVariables>
</configuration>
</plugin>