Tuesday, July 24, 2012

Maven variable referencing path to local repository

In one of our projects we use Spring + EclipseLink with runtime weaving. To achieve Entity enhancement in our tests we have to run them with flag 'javaagent':
java ... -javaagent:path/to/spring-instrument.jar
The project is based on maven and we wanted to keep smooth build procedure. Thus we had to provide path/to/spring-instrument.jar in an environment independent way. And solution for this was to:
  1. Add maven dependency on the spring-instrument.jar with test scope
  2. Configure maven-surefire-plugin with the mentioned argLine referencing spring-instrument.jar in the maven local repository by using maven variable settings.localRepository

Finally, here is pom.xml snippet with surefire configuration.
<plugin>
  <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
      <argLine>-javaagent:${settings.localRepository}/org/springframework/spring-instrument/3.1.0.RELEASE/spring-instrument-3.1.0.RELEASE.jar</argLine>
    </configuration>
</plugin>

No comments:

Post a Comment