1

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.

Nikem
  • 5,716
  • 3
  • 32
  • 59
Lake
  • 4,072
  • 26
  • 36

2 Answers2

2

If your repository is mirroring the central repo, then what happens is this:

  1. Gradle tries to find a dependency from your repo
  2. Your repo does have it, so it contacts the upstream repo that it is mirroring
  3. Dependency is downloaded from the upstream repo and is cached in your repo
  4. Dependency is handed to Gradle

This never leaves Gradle the chance to try to contact jcenter directly :)

Nikem
  • 5,716
  • 3
  • 32
  • 59
  • Thanks for the reply :) I could imagine steps 1),2) and 4) but is 3) mandatory or should it be configurable? I would consider the possibility of not having my personal repo flooded with every single dependency that it caches when using it :) – Lake Nov 06 '16 at 20:51
  • I believe that 2) and 3) are quite connected :) You may try to switch off repo mirroring. Did not use Archiva, so don't know how. – Nikem Nov 06 '16 at 20:52
  • I finally found out the settings. Thanks for the conceptual guiding^^ – Lake Nov 06 '16 at 20:56
0

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.

Lake
  • 4,072
  • 26
  • 36