Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get version 4.0 of httpclient off of my classpath in grails

I am using Grails 1.3.7 and cannot figure out how to get version 4.0 of httpclient off of my classpath (in favour of 4.1). I need to do this because of a no-args constructer used in 4.1 that the plugin relies on.

Running a grails 'dependency-report', it appears that 4.1 should be the one being used at runtime. And it IS, if I package things up into a .war. HOWEVER version 4.0 is still ending up on the classpath when using run-app for some reason. Note it is (correctly) being used at compile time for some grails internals, and somehow it is still ending up on my classpath.

-> Can I figure out where exactly that 4.0 .jar is coming from and ending up on my classpath and stop it from happening (where are all the .jars put when running via run-app?)

-> Can I tell grails to compile with 4.1 instead of 4.0 for its internals (in this case the http-builder by org.codehaus.groovy.modules.http-builder module?) Arguable not the best solution but I'll take it, as packaging everything into a .war every time I want to test it is not pleasant.

Help would be greatly appreciated.

like image 228
Peter Avatar asked Nov 01 '11 22:11

Peter


2 Answers

I just went through the same thing, add the following to your BuildConfig.groovy

dependencies {        
        build 'org.apache.httpcomponents:httpcore:4.1.2' 
        build 'org.apache.httpcomponents:httpclient:4.1.2' 
        runtime 'org.apache.httpcomponents:httpcore:4.1.2'
        runtime 'org.apache.httpcomponents:httpclient:4.1.2'
} 

cheers

Lee

like image 148
leebutts Avatar answered Nov 14 '22 14:11

leebutts


You can get httpclient 4.0 off of the classpath by adding an excludes line in BuildConfig.groovy. Figure out which plugin is declaring it as a dependency by using the grails dependency-report command.

Once you find which one included it, you can exclude it in the plugins section of BuildConfig.groovy. Example:

plugins {
    compile ':other-plugin:1.0.0' // other-plugin depends on httpclient 4.1
    compile(':aws:1.2.12.2') { // aws plugin depends on httpclient:3.1
        excludes 'httpclient'
    }
}

The plugin that relies on the no-arg constructor in httpclient 4.1 should declare it as a dependency. If it does not you should open an issue with the author of the plugin. To workaround this, you can list httpclient 4.1 in the dependencies section as leebutts describes above.

like image 38
Jay Prall Avatar answered Nov 14 '22 14:11

Jay Prall