[GRADLE-1794] Gradle does not download transitive dependencies that are in subsequent mavenRepo urls Created: 14/Sep/11  Updated: 04/Jan/13  Resolved: 17/Sep/11

Status: Resolved
Project: Gradle
Affects Version/s: 1.0-milestone-4
Fix Version/s: None

Type: Bug
Reporter: Matt Callanan Assignee: Unassigned
Resolution: Not A Bug Votes: 0


 Description   

Need to be able to download POMs from more than one mavenRepo url.

  • My build depends on A
  • A depends on B depends on C
  • A is in "inhouse" repo
  • B and C are in "public" repo
  • With this setup:
    repositories {
        mavenRepo urls: [
                "http://.../inhouse",  // contains A
                "http://.../public",   // contains B and C
        ]
    }
    

    I get A.jar and B.jar but not C.jar

    • Gradle doesn't know B's dependencies as it doesn't attempt to get B.pom from "public" repository.
  • With this setup:
    repositories {
        mavenRepo urls: [
                "http://.../public",   // contains B and C
                "http://.../inhouse",  // contains A
        ]
    }
    

    I only get A.jar

    • Gradle doesn't know A's dependencies as it doesn't attempt to get A.pom from "inhouse" repository.

A workaround for now:

  • Set the mavenRepo urls so that "public" is before "inhouse"
  • Add B as a direct dependency in build.gradle (in addition to A)
  • This allows B.jar and C.jar to be downloaded from "public"
  • A.jar also gets downloaded from "inhouse" (the POM does not get downloaded)

Tried to find a better approach but could only see this explanation]:

"The first URL is used to look for POMs and JARs. The subsequent URLs are used to look for JARs."



 Comments   
Comment by Daz DeBoer [ 14/Sep/11 ]

For a single defined maven repository, gradle will only use the first defined URL to locate POMs, subsequent URLs are only used to locate artifacts referenced by POMs in the first location. Unfortunately, the DSL syntax is unclear; see GRADLE-1385.

In your case, you want to look up POMS + artifacts in 2 different maven repositories. This is done by declaring 2 repositories:

repositories {
    mavenRepo urls: "http://.../public"
    mavenRepo urls: "http://.../inhouse"
}
Comment by Matt Callanan [ 14/Sep/11 ]

Ah, that explains it. Thanks Daz, works fine now.
Don't think I would have stumbled on that myself - I've raised documentation improvement issue (GRADLE-1796) to help others possibly migrating from Maven.

Generated at Wed Jun 30 12:04:31 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.