Unable to use local jar in preference of mavenCentral()


(Mario Emmenlauer) #1

I’ve searched the forum for two hours now but I fail to find a working solution. I use a patched version of thrift in my project, so I require that gradle uses my own libthrift-0.10.0.jar, but I fail to achieve this.

The docs state clearly that repositories that provide a pom take precedence over repositories that don’t. So as a first step, I copy the libthrift-0.10.0.pom from my thrift build directory to my flatDir repository. However I find that gradle still prefers the thrift from mavenCentral().

So I assume that flatDir does not make use of the pom in the same directory. This was not as obvious from the documentation, at least not to me. But I found other posts suggesting to create a local flat maven repository. However here things become even less well documented. Most forum replies just say “create directories where you place the jar and pom”, but it is not explicit if multiple jars may share the same directory or if there is a specific directory hierarchy required. Furthermore, there are various syntax in use when it comes to environment variables in the local maven directory path. I found at least the following four syntax in use:

maven {
    url System.getenv('MYSOFTDEST') + "/thirdparty/lib"
}
maven {
    url uri(System.getenv('MYSOFTDEST') + "/thirdparty/lib")
}
maven {
    url "file://${System.getenv('MYSOFTDEST')}/thirdparty/lib"
}
maven {
    url "${MYSOFTDEST}/thirdparty/lib"
}

All of these did not help with my problem, and gradle still prefers the thrift from mavenCentral()! So I further checked the docs and found that the order of repositories is relevant. So I place the local maven above mavenCentral(). Still, no luck.

Now I am basically at the end of my wit. Gradle continues to prefer the thrift from mavenCentral(), despite having pom and jar in a local directory that is referenced as maven repository before mavenCentral(). Anything else I should try?

Is it a bug? Or what is going on?