如何配置 gradle 仅对某些依赖项组使用本地存储库?

发布于 2024-11-29 05:03:41 字数 677 浏览 1 评论 0原文

通过 gradle 依赖文档,我们得到了一个包含如下代码片段的 build.gradle。

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'
}

此设置确实正确下载了所有内容,但我想对其进行调整,以便仅尝试从 ivy 存储库中提取 localRepo 组中的内容,并且 localRepo 仅用于 localRepo 组。 localRepo 仅保存私有 jar,因此我们不希望将其用作第一个存储库,并且我们不想花很长时间查询 mavenCentral 来查找不存在的 jar。

基本上我想说在依赖项中使用特定的存储库,或者本地常春藤存储库仅用于特定组。有没有简单的方法可以做到这一点?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

囚你心 2024-12-06 05:03:41

不完全是您想要的,但我们设置了存储库,以便开发人员从本地私有存储库获取所有依赖项,并且本地私有存储库缓存 Maven 中央存储库。这更快,因为第一个开发人员仅从 Maven 中心提取一次依赖项来访问它们,并且还允许您查看公司中正在使用哪些工件。 Nexusartifactory 我相信所有其他存储库也是如此。

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.

oО清风挽发oО 2024-12-06 05:03:41

看起来类似的问题在 gradle 邮件列表上被问到 目前可用的最佳选择确实是转向 artifcatory 并管理您自己的共享存储库。

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.

屋顶上的小猫咪 2024-12-06 05:03:41

目前不可能,但这是一个开放请求 http://issues.gradle.org/browse/GRADLE -1066

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文