grailsivyapache-commons-codecgoogle-reporting-api

UNRESOLVED DEPENDENCIES for commons-codec


I'm trying to retrieve the library for Google Reporting API:

compile 'com.google.apis:google-api-services-analytics:v3-rev74-1.17.0-rc'

but I got an unresolved dependencies error and I don't know what to do with it:

:: commons-codec#commons-codec;1.6: configuration not found in commons-codec#commons-codec;1.6: 'master'. It was required from org.apache.httpcomponents#httpclient;4.0.1 compile

I checked the .grails\ivy-cache\ folder and there's a commons-codec folder with jars of commons-codec-1.5, few xml files ivy-1.5.xml and ivy-1.6.xml and ivydata-1.5.properties and ivydata-1.6.properties. I also tried to delete the whole ivy-cache folder, but the result is the same.


Solution

  • Just right after writing my question, I found an answer. Changing the "compile" scope to "build" should resolve the error:

    build 'com.google.apis:google-api-services-analytics:v3-rev74-1.17.0-rc'
    

    Actually this solved my previous problem, but raised another one :) A "build" scope includes the library only when compiling, but not at runtime! So I didn't have google-api-services-analytics available when deployed to Tomcat. My final and working solution is:

    dependencies {
            def googleLibVersion = "1.17.0-rc"
            compile("com.google.apis:google-api-services-analytics:v3-rev74-${googleLibVersion}") {
                excludes "commons-codec"
            }
            compile("com.google.http-client:google-http-client-jackson2:${googleLibVersion}") {
                excludes "commons-codec"
            }
    }