Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why gradle doesn't search for dependency in other maven repos?

Why does gradle not searching for dependency in ALL defined maven repos?

Repos block is defined:

repositories {
    maven {
        name = 'JBoss.org Maven repository'
        url 'https://repository.jboss.org/nexus/content/groups/public'
    }
    maven {
        name = 'spring-milestones'
        url 'http://repo.springsource.org/libs-milestone/'
    }
    mavenCentral()
}

(Assuming I got somewhere in the subproject net.sf.json-lib:json-lib:2.2.1) I receive:

* What went wrong:
Could not resolve all dependencies for configuration ':myproject:compileClasspath'.
> Could not find json-lib.jar (net.sf.json-lib:json-lib:2.2.1).
  Searched in the following locations:
      http://repo.springsource.org/libs-milestone/net/sf/json-lib/json-lib/2.2.1/json-lib-2.2.1.jar

Why the only one search-location? The json-lib clearly exists in mavenCentral().

Is there any way to profile that, or debug somehow?

P.S. I could fix that if I move mavenCentral() up one position in the list of repos, but that will break another subproject dependency-resolution by the very same reason -- something from "spring" repo does not exist in mavenCentral().

like image 1000
head_thrash Avatar asked Aug 12 '16 13:08

head_thrash


1 Answers

In fact, gradle searches for all maven repos. You can see that JBoss repo does not contain 2.2.1 version of json-lib, so, it skips to the next one (spring repo).

Spring repo has 2.2.1, but, the issue here is that the artifact has distribution specified, so, you just need to fix the dependency:

compile 'net.sf.json-lib:json-lib:2.2.1:jdk15'
like image 164
head_thrash Avatar answered Jan 03 '23 13:01

head_thrash