Question

We have a local artifactory repository setup for caching. It is configured in our projects, but when I'm looking at stdout of the build process I see rows like this

Downloading: http://ourserver/artifactory/our-repo/javax/transaction/jta/1.1/jta-1.1-sources.jar
Downloading: http://repo1.maven.org/maven2/javax/transaction/jta/1.1/jta-1.1-sources.jar
Downloaded: http://repo1.maven.org/maven2/javax/transaction/jta/1.1/jta-1.1-sources.jar (25 KB at 54.5 KB/sec)

So it looks like it is trying to download the jar from the local repository AND from Maven Central and then actually uses Maven Central).

If I copy the url of the local repository in my browser I get the jar without a problem.

If I check with the admin application of artifactory I can see the artefact.

Can anybody explain why Maven Central is used at all?

UPDATE: What was going on and what I did:

orien's answer explaines why Maven Central was accessed at all.

mliebelt comments hinted me towards my solution: Looks like our local repository was to slow to answer when it had to download the artifact first. I configured the cache to eagerly download jars and sources when a pom gets requested. This should reduce the number of artifacts downloaded from elsewhere.

Was it helpful?

Solution

Maven can be configured with multiple repositories. Adding a repository, as you have in your project, does not invalidate any repositories you have already configured. By default everyone gets the repository at Maven Central. Maven is then free to download an artifact from any repository it has available.

Sounds like what you really want to do is set up a mirror. You can configure a mirror in your settings.xml file:

<mirrors>
    <mirror>
        <id>our-server-repo</id>
        <name>our local repository</name>
        <url>http://ourserver/artifactory/our-repo</url>
        <mirrorOf>*</mirrorOf>
    </mirror>
</mirrors>

Note that we've used a wildcard (*) in the mirrorOf element. This specifies that all repositories will be accessed via the specified URL. With this configuration Maven will only access your local Artifactory repository.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top