Search code examples
gradlearchiva

Why does gradle push a dependency to my maven repo while resolving dependencies?


This is my basic setup:

// Dependencies
repositories {
    maven { url "http://MYREPO.." }
    jcenter()
    mavenLocal()
}

dependencies {
    compile 'org.bytedeco.javacpp-presets:opencv:3.1.0-1.2'
}

From my understanding of how dependency resolution works, gradle should try and seek for the dependency first in my repo, then in jcentral() and then in mavenLocal.

Instead, I get this output on ./gradlew assemble:

:compileJava
Download http://MYREPO.../org/bytedeco/javacpp-presets/opencv/3.1.0-1.2/opencv-3.1.0-1.2.jar
:processResources UP-TO-DATE
:classes
:jar UP-TO-DATE
:assemble UP-TO-DATE

BUILD SUCCESSFUL

In fact, when I take a look inside my repository to see what happens, I found the opencv dependency being PUSHED as a consequence of the dependency resolution.

I would expect instead the artifact to be downloaded from jcenter, where it's in fact present.

I am using apache archiva.

Why does this happen? Is this behaviour documented somewhere? I don't undrstand if this is a problem with my repository settings or with the gradle script.


Solution

  • For Apache Archiva, the caching settings are configurable under "Proxy Connectors" and documented here:

    http://archiva.apache.org/docs/1.4-M4/adminguide/proxy-connectors.html

    You can basically choose how frequently (or not at all) to cache the artifacts from the mirrored repo for use in subsequent requests.