How can I append to the system path for Maven Surefire tests that use DLLs?
-
08-12-2019 - |
Question
I'd like to be able to append a lib directory to the system path to allow Maven to run unit tests that (gah) use DLL native libraries.
I have so far used <argLine>-Djava.library.path=${path.dll}</argLine>
to add my DLL path as a library path. However, Windows still wants to resolve DLLs via the path, and I'm getting:
java.lang.UnsatisfiedLinkError
So, is there a way of providing a modified system path to Surefire?
Thanks in advance for your help.
Solution
Turns out the following config was necessary:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
...
<environmentVariables>
<PATH>${basedir}\..;${java.library.path}</PATH>
</environmentVariables>
...
</configuration>
</plugin>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow