Dependencies on Cloudera Repo Available with Maven not Gradle


(neil) #1

I have the following in a Maven project:

<repositories>
        <repository>
            <id>cloudera</id>
            <url>https://repository.cloudera.com/artifactory/cloudera-repos/</url>
        </repository>
    </repositories>
    <dependencies>
        <dependency>
             <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-common</artifactId>
            <version>2.0.0-cdh4.2.0</version>
        </dependency>
    </dependencies>

And that works just fine.

I also have the following in Gradle:

repositories {
    mavenCentral()
    mavenLocal()
    maven {
        url "https://repository.cloudera.com/artifactory/cloudera-repos/"
    }
}
  dependencies {
    compile group: "org.apache.hadoop", name: "hadoop-common", version: "2.0.0-cdh4.2.0"
}

When I run, I get this:

Execution failed for task ‘:run’. > Could not resolve all dependencies for configuration ‘:runtime’.

Could not find org.apache.hadoop:hadoop-common:2.0.0-cdh4.2.0.

Required by:

:myproject:unspecified

I would love to know what I am doing wrong in my setup.

Thanks.


(Luke Daley) #2

Can you run with the ‘-i’ switch please. This will provide some information about the network traffic.


(neil) #3

Here is the relevant output:

Task ':run' has not declared any outputs, assuming that it is out-of-date.
Resource missing. [HTTP GET: http://repo1.maven.org/maven2/org/apache/hadoop/hadoop-common/2.0.0-cdh4.2.0/hadoop-common-2.0.0-cdh4.2.0.pom]
Resource missing. [HTTP HEAD: http://repo1.maven.org/maven2/org/apache/hadoop/hadoop-common/2.0.0-cdh4.2.0/hadoop-common-2.0.0-cdh4.2.0.jar]
Resource missing. [HTTP GET: http://download.oracle.com/maven/org/apache/hadoop/hadoop-common/2.0.0-cdh4.2.0/hadoop-common-2.0.0-cdh4.2.0.pom]
Resource missing. [HTTP HEAD: http://download.oracle.com/maven/org/apache/hadoop/hadoop-common/2.0.0-cdh4.2.0/hadoop-common-2.0.0-cdh4.2.0.jar]
:run FAILED

Interesting Gradle is only looking in certain repos. Here is the full declaration (which I omitted partially before for brevity):

repositories {
    mavenCentral()
    mavenLocal()
    maven {
        url "https://repository.cloudera.com/artifactory/cloudera-repos/"
        url "https://repo.springsource.org/libs-milestone"
        url "http://repo.spray.io"
        url "http://repo.springsource.org/release"
        url "http://repo.typesafe.com/typesafe/repo"
        url "http://download.oracle.com/maven"
    }
}

Thanks.


(Luke Daley) #4

You’re just replacing the URL value with each subsequent call. You need a separate maven {} block for each repo.


(neil) #5

Yes, that was the issue. Thanks for your help.

Out of curiosity, why is it that you can only supply one URL per Maven closure? Not a big deal; just curious what the thinking is behind that.

Thanks again.


(Luke Daley) #6

Because each repository is one logical object. You may need to configure different credentials to access the repository, or other configuration options.