Reputation: 18861
I have a Maven dependency that requires a DLL at runtime. What I want to do is to simply have that dll in resources/lib
folder and place its DLLs to the target
directory. So what've I done is :
src/main/resources/lib
Modified pom.xml
to use argument -Djava.library.path=${basedir}/lib like so:
<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>
However I am still getting runtime error that DLL is not present in java.library.path.
Upvotes: 22
Views: 14272
Reputation: 32627
Your <argLine/>
points to an incorrect path. Try this instead:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<forkMode>once</forkMode>
<workingDirectory>target</workingDirectory>
<argLine>-Djava.library.path=${basedir}/src/main/resources/lib</argLine>
</configuration>
</plugin>
If this DLL will only be used for tests, you should put it under src/test/resources
. In that case the <argLine/>
path will change to ${project.build.directory}/test-classes
.
Upvotes: 18