views:

1076

answers:

1

I use Eclipse and for some of my unit tests, I need to set some JVM args for the test to work, -Djava.library.path in particular. I set it in my POM file as follows:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <configuration>
    <argLine>-Djava.library.path=target/dll</argLine>
  </configuration>
</plugin>

and it works correctly when I build with Maven. However, when I run in Eclipse (even with the Maven plug-in installed - I have everything else in my Eclipse environment working properly with maven), this JVM argument is not applied. Does anyone know why this is or how to fix this?

+2  A: 

Running the test in Eclipse with the JUnit test runner does not invoke maven , even if you are using m2eclipse.

I suggest you either:

  • create a maven launch configuration for the test goal;
  • add -Djava.library.path=target/dll to your JVM arguments in the JUnit launch configuration.
Robert Munteanu
thanks for clarifying. I had done the second option. my worry was that other developers would all have to modify their configs manually - I was hoping to push that out automatically. appreciate the help.
Jeff Storey