1
I have a scenario where I need to run a test with Junit in a feature that has an external dependency, but to run this functionality on the application server I need to put this external dependency in the group of exclusions in my pom.xml
. Only in the test I don’t need/don’t have the container of Jboss EAP 5 started, which already has this dependency. And at this point the test accuses that the dependency is not available.
Does anyone know any alternative to run unit test with external dependency, and when packaging my project in a jar/War perform the deletion properly.
Below I put the dependency in question:
<dependency>
<groupId>net.sourceforge.nekohtml</groupId>
<artifactId>nekohtml</artifactId>
<version>1.9.21</version>
<exclusions>
<exclusion>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
</exclusion>
<exclusion>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
</exclusion>
</exclusions>
</dependency>
If I do this, Nekohtml won’t be available in my package, and the only dependency I don’t need in Runtime is xerces/xml-Apis.
– eliocapelati
@eliocapelati I think I understand your need. I updated my answer.
– Caffé
Thanks @Caffé, I had already considered this alternative, I thought I had something specific to declare the dependencies selectively... Anyway thank you very much for the reply! I ended up using the scopo
provided
which has best fit with the Maven documentation: http://books.sonatype.com/mvnref-book/reference/pom-relationships-sect-project-dependencies.html#pom-relationships-sect-dependency-Scope– eliocapelati