How to exclude jersey 1.x dependencies when running tests with gradle -


we have web service project relies on netflix's eureka , has dependency on jersey client 1.x.

our project using gradle , in project have our src, unit, integration, , functional tests. our functional tests have jar import in testcompile gradle section wraps jersey client send requests web service.

now question how can netflix jersey client dependency ignored in testcompile can use new jersey 2.x client functional tests?

build scripts below:

main service build script excerpt:

dependencies {   compile 'com.netflix.eureka:eureka-client:1.1.97'   compile 'com.sun.jersey:jersey-bundle:1.18'    testcompile 'some.domain:service-test-client:1.0.1'     } 

service test client relevant parts:

dependencies {   compile 'org.glassfish.jersey.core:jersey-client:2.19'   compile 'org.glassfish.jersey.connectors:jeresey-apache-connector:2.19' } 

relevant parts of eureka client gradle script github:

ext {     githubprojectname = 'eureka'     awsversion='1.9.3'     servletversion='2.5'     jerseyversion='1.11'     governatorversion='1.3.3'     archaiusversion='0.6.5'     blitzversion='1.34'     mockitoversion='1.9.5'     junit_version='4.10'     mockserverversion='3.9.2'     jetty_version='7.2.0.v20101020' }  dependencies {   compile "com.sun.jersey:jersey-core:$jerseyversion"   compile "com.sun.jersey:jersey-client:$jerseyversion"   compile 'com.sun.jersey.contribs:jersey-apache-client4:1.11'   compile 'org.apache.httpcomponents:httpclient:4.2.1'  } 

with above setup method not found errors because when tests running of jersey 1.x classes taking precedence on classes brought in test-client jar.

you can use gradle dependency monitoring find out libraries bringing in jersey.

./gradlew dependencies 

you can pipe file, , less way finding out who's bringing in jersey 1.*.

then, exclude specifically, , compile own:

compile("com.example.library:artifactid:x.y.z"){    exclude group:'org.glassfish.jersey', module:jersey-common }  compile('org.glassfish.jersey.core:jersey-common:2.4.1') 

Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -