我们在 Hudson 中使用 Maven 来运行我们的 Java 构建过程,并使用 Surefire 插件来执行 JUnit 测试,但是我在一个需要本机 dll 的项目的单元测试中遇到了问题。
我们看到的错误是:
测试错误:TestFormRegistrationServiceConnection(com.#productidentifierremoved#.test.RegistrationServiceTest): no Authenticator in java.library.path
其中 Authenticator 是我们需要的 dll 的名称。我发现这个 SO post表明设置它的唯一方法是通过 argLine。我们将配置修改为:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.10</version>
<configuration>
<forkMode>once</forkMode>
<argLine>-Djava.library.path=${basedir}\src\main\native\Authenticator\Release</argLine>
</configuration>
</plugin>
但是,如果我们包含 System.out.println(System.getProperty("java.library.path")); 我们可以看到这没有被添加到路径中。
有什么想法可以解决这个问题吗?