Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

maven-surefire-plugin, DLLs and java.library.path

Tags:

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 :

  1. Added DLLs to src/main/resources/lib
  2. 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.

like image 283
Xorty Avatar asked Mar 04 '13 10:03

Xorty


People also ask

How does maven surefire plugin work?

Maven sure fire plugin is used to follow the sequence of tests in testng. xml file. If we don't include the Mavwen surefire plugin then it will execute all the testcases under src/test/java which has prefix or suffix as 'test' and these tests will get executed without any sequence.

What is Maven surefire report plugin?

The Surefire Report Plugin parses the generated TEST-*. xml files under ${basedir}/target/surefire-reports and renders them using DOXIA, which creates the web interface version of the test results.


1 Answers

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.

like image 183
carlspring Avatar answered Oct 23 '22 02:10

carlspring