Jar present in cache but not resolved in project

I have a groovy project in which I am trying to use the http-builder module. My build.gradle file looks as below

buildscript {
    repositories {
    dependencies {
        classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.0.0'
        classpath ('org.codehaus.groovy.modules.http-builder:http-builder:0.7.2') {
            exclude(module: 'groovy')

group 'example.gradle.plugins'
version '1.0.7'

apply plugin: 'groovy'
apply plugin: 'maven-publish'
apply plugin: "com.jfrog.artifactory"

sourceCompatibility = 1.7

dependencies {
    compile gradleApi()
    compile localGroovy()
    compile('org.codehaus.groovy.modules.http-builder:http-builder:0.7.2') {
        exclude(module: 'groovy')
    testCompile group: 'junit', name: 'junit', version: '4.11'

I cannot use HTTPBuilder though as it is not found in the external libraries. I checked my ~/.gradle/cache folder and it does have the following entries


What am I doing wrong here?

You need to specify a root level repositories { } block. Just because the module is cached (likely by another build) does not mean the cached version will be used for this build if you haven’t defined a repository to get things from. Basically, if I tell my build to only use dependencies downloaded from repository A, it will not use one downloaded from repository B, as there is no guarantee they are the same. We refer to this as the cache being “repository-aware”. Logically, if I specify no repositories at all, no external dependencies can be resolved.

Thanks!! Turns out adding another repo

maven {
            url 'http://gradle.artifactoryonline.com/gradle/libs/'

in a root repositories block solved the issue. However when I run the maven publish task it generates the follow pom

<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"

but when the plugin is applied I get an error saying

Error:Could not find org.codehaus.groovy.modules.http-builder:http-builder:0.7.2.
Searched in the following locations:
    file:/Applications/Android Studio.app/Contents/gradle/m2repository/org/codehaus/groovy/modules/http-builder/http-builder/0.7.2/http-builder-0.7.2.pom
    file:/Applications/Android Studio.app/Contents/gradle/m2repository/org/codehaus/groovy/modules/http-builder/http-builder/0.7.2/http-builder-0.7.2.jar

How can I include the repository in the generated pom?

You don’t. The pom.xml simply defines the dependencies, not where to get them. It’s up to the consuming project to specify this.

Is there a way I can package the dependency with the plugin so that the project using this plugin need not add the repo?

You could certainly use something like the shadow plugin to bundle dependencies in your plugin’s JAR.

Hy Mr. Mark, please I am new to android studio and I just created my first project but whenever I try to sync with gradle it takes alot of time and then later show error message "can’t download builder-4.0.0.jar. so I downloaded the jar file using browser but I don’t know the path to put the file. I searched for builder -4.0.0.pom and. I saw it located in folder that has a weird name and that makes it more confusing to me. Please do have any idea on what to do? Thank you