1
votes

I am using Artifactory as my artifact store, and have set this up so that it is being used as a proxy and cache for jcenter. This generally is working fine apart from for dependencies declared in the buildscript block in my main build.gradle.

My block looks like

buildscript {
    repositories {
        //proxies jcenter
        maven {
            url "https://<myArtiInstance>/artifactory/repo"
            credentials {
                username artifactory_reader_username
                password artifactory_reader_password
            }
        }
    }
    dependencies {
        classpath "org.jfrog.buildinfo:build-info-extractor-gradle:3.1.1"
        classpath "com.android.tools.build:gradle:2.1.2"
    }
}

which gives the error when running gradlew clean build (2.10)

A problem occurred configuring root project 'android'.
> Could not resolve all dependencies for configuration ':classpath'.
   > Could not find builder.jar (com.android.tools.build:builder:2.1.2).
     Searched in the following locations:
         https://<myArtiInstance>/artifactory/repo/com/android/tools/build/builder/2.1.2/builder-2.1.2.jar 

If I wack the above url into my (authenticated) browser, I get the jar and can see its put into the arti cache.

All my other proxied dependencies seem to work so I am a bit confused as to whats going on.

At present I am wondering if this is a bug with Gradle 2.10 or something, as this used to work as I can see previous cached versions of that artifact in my arti box.

Thanks for any help or pointers :)

EDIT: If I roll back to com.android.tools.build:gradle:2.1.0 which is not in my cached repo either, build completes fine and it caches it. For some reason it does not like 2.1.2, I wonder why?!

EDIT2: Still having issues, now its taken issue with https://<myArtiInstance>/artifactory/repo/com/google/guava/guava/15.0/guava-15.0.jar which gives a similar error to the above

* What went wrong:
A problem occurred configuring root project '<name>'.
> Could not resolve all dependencies for configuration ':classpath'.
   > Could not find guava.jar (com.google.guava:guava:15.0).
     Searched in the following locations:
         https://<myAriInstance>/artifactory/repo/com/google/guava/guava/15.0/guava-15.0.jar

This is again from a dependecency specified inside the buildscript block. Any ideas whats going on? This time is transative so I cant just swap the version. The only strange thing I notice from the error messages is that its looking for guava.jar at the url ending in guava-15.0.jar...

1
try running gradle with --info or --debug in order to get more information - Dror Bereznitsky
yes I did do that, always my first port of call, and didnt see anything enlightening. However, I did it again and it led to me fixing it! See answer. - Dori

1 Answers

1
votes

So it turns out inspecting the output of gradlew clean build --debug for a second time, I noticed everything was being obtained from the local ~/.gradle/cache, apart from the failing jars above. rm the cache and everything works fine, and the transitive dependencies can be obtained from the url given in the error msg. Subsequent builds which retreive from local cache work fine. Seems to me that something had corrupted the local cache (maybe partial download of complete resources i.e. pom, jar etc for the dependency) and that the gradle error msg was incorrect.

EDIT: testing just deleting the jar from cache and still compiles fine...