Maven: Set up java.library.path

I’ve tried to set up java.library.path as next example

     <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemProperties>
<property>
<name>java.library.path</name>
<value>target/lib/</value>
</property>
</systemProperties>
</configuration>
</plugin>

but there were problems in testing, one test with JNI was passed but others were failed. I’ve spent about 4 hours for investigation and found that in last part of documentation there are special properties, so I’ve tried it and it is working!!!

Simple example of working plugin configuration

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<forkMode>once</forkMode>
<workingDirectory>target</workingDirectory>
<argLine>-Djava.library.path=${basedir}/lib</argLine>
</configuration>
</plugin>

Cheers!

READ  Source Control for your Code

Leave a Reply

Your email address will not be published. Required fields are marked *