How to configure gradle to use a local repository only for certain dependency groups?
Asked Answered
M

3

19

Working off the gradle dependency docs, we have a build.gradle with snippets like this.

repositories {
    mavenCentral()
    ivy {
        name = 'localRepo'
        artifactPattern "http://localRepo.com/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]"
    }
}

dependencies {
    compile group: 'localRepo', name: 'my-private-library', version: '2.5'
}

This setup does download everything correctly, but I would like to tweak it so that things in group localRepo are only attempted to be pulled from the ivy repository and localRepo is only used for group localRepo. localRepo only holds private jars so we do not want it to be used as the first repo and we do not want to spend a long time querying mavenCentral for jars that will not exist.

Basically I would like to say in the dependency to use a specific repo or that the local ivy repo is only to be used for specific groups. Is there an easy way to do this?

Minta answered 10/8, 2011 at 18:59 Comment(2)
You might get a faster/better response asking this on gradle nabble: gradle.1045684.n5.nabble.comMont
Thanks for both of your answers, artifactory worked for me, I just didn't have time to test it before the bounty ended. I gave sbridges the answer since he got in first. I also reopened the bounty so that you can get bounty credits. Sorry I did not get to it in time.Minta
W
5

Not quite what you want, but we set up our repositories so that developers get all dependencies from the local private repo, and that local private repo caches the maven central repo. This is faster, as dependencies are only pulled once from maven central by the first developer to access them, and also allows you to see what artifacts are being used in your company. Nexus and artifactory and I am sure all other repositories do as well.

Whitener answered 29/8, 2011 at 5:3 Comment(0)
D
1

Looks like something similar was asked on the gradle mailing list and the best option currently available is indeed to turn to artifcatory and manage your own shared repository.

Delegation answered 29/8, 2011 at 5:51 Comment(0)
J
1

It's currently not possible, but it's an open request http://issues.gradle.org/browse/GRADLE-1066

Jago answered 28/5, 2013 at 15:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.