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

2

7

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.

Schoolbag answered 1/11, 2011 at 22:47 Comment(0)
B
7

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

Bookcraft answered 4/11, 2011 at 0:6 Comment(1)
I actually resolved this by modifying the plugin that specified 'build ':release:1.0.0.RC3' by adding 'exported = false' but I have accepted your solution as it may be a bit cleaner to keep it within your own code and not have to modify plugin dependencies file. Bottom line, it is the 'build' specifier. that is the culprit. ThanksSchoolbag
J
1

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.

Jordanna answered 2/11, 2013 at 17:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.