如何配置gradle以仅为某些依赖关系组使用本地存储库? [英] How to configure gradle to use a local repository only for certain dependency groups?

查看:106
本文介绍了如何配置gradle以仅为某些依赖关系组使用本地存储库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过 gradle依赖文档,我们有一个build.gradle,其中包含这样的代码片断。

 存储库{
mavenCentral()
ivy {
name ='localRepo'
artifactPatternhttp://localRepo.com/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]
}
}

依赖项{
编译组:'localRepo',名称:'my-private-library',版本:'2.5'
}
pre>

这个设置确实下载了所有东西,但是我想调整它,以便localRepo组中的内容只会尝试从常青藤资源库中提取,而localRepo只是用于组localRepo。 localRepo只拥有私人罐子,所以我们不希望它被用作第一个回购,我们不想花费很长时间来查询mavenCentral是否存在不存在的罐子。



<基本上我想说在依赖中使用特定的回购或本地常春藤回购仅用于特定组。有没有简单的方法来做到这一点?

解决方案

不是你想要的,但是我们设置了我们的仓库,来自当地私人回购的所有依赖,以及当地私人回购缓存maven中央回购。这是更快的,因为只有第一个开发人员才能从maven central获取依赖关系,以便访问它们,并且还可以查看公司中正在使用的工件。 Nexus artifactory ,我相信所有其他仓库也可以。


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?

解决方案

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.

这篇关于如何配置gradle以仅为某些依赖关系组使用本地存储库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆