Karaaie
Karaaie

Reputation: 567

Gradle dependency resolution

I have an issue with how gradle resolves my dependencies.

I have four repositories that I need to investigate for different jars, five counting Maven central. Thus my repo statment in gradle.build looks like this:

repositories {

  maven {
    url 'urltoRepoA'
    artifactUrls mavenLocal()
  }
  maven {
    url 'urltoRepoB'
    artifactUrls mavenLocal()
  }
  maven {
    url 'urltoRepoC'
    artifactUrls mavenLocal()
  }
  maven {
    url 'urltoRepoD'
    artifactUrls mavenLocal()
  }

  mavenCentral()
}

What I want to acheive: Look for dependencies both in the remote repositories and the local maven repository.

But I get this error below, that is a jar that should be resolved from repoA (repoA is a mirror of maven central, and I have verified that this jar can be found there)

[16:43:10][Step 1/3] > Could not resolve all dependencies for configuration ':runtime'.
[16:43:10][Step 1/3]    > Artifact 'junit:junit:4.11@jar' not found.

According to what I've read in gradles manual is that it tries to resolve all the dependencies from the same repo. Is that what I'm running in to here? Or have I failed to configure gradle properly?

Upvotes: 1

Views: 6694

Answers (1)

Jeff Storey
Jeff Storey

Reputation: 57202

I suspect there is something wrong elsewhere in your gradle configuration. I think you are misunderstanding how gradle resolves artifacts.

According to the gradle docs (see section 8.5)

A project can have multiple repositories. Gradle will look for a dependency in each repository in the order they are specified, stopping at the first repository that contains the requested module.

In fact, it's rather common to have multiple repositories in a gradle script.

Upvotes: 2

Related Questions