选择带Branchname的版本作为Gradle的分类器 [英] Pick Version with Branchname as Classifier with Gradle

查看:164
本文介绍了选择带Branchname的版本作为Gradle的分类器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我们的项目评估Gradle。我们有多个包含小型util库的小型项目。大多数项目都在一个额外的存储库中,不能使用共享的构建脚本。
在跨多个项目工作时使用相同的功能分支。我已经设法让gradle将branchname作为分类器放入创建的Maven工件中。
对于我们的持续集成,如果它存在,将解析对这样一个库的依赖关系对使用它自己的分支名称的依赖关系是非常有用的。如果没有,它应该回退到正常的声明版本。

我设法通过resolutionStrategy.eachDependency更改版本,但如果没有该分支的版本存在,我找不到实现回退的方法。

有没有什么办法可以实现?



问候,
arne

解决方案

必须编写一些代码来实现这一点。例如,您可以复制配置,通过 resolutionStrategy.eachDependency 设置复制配置的分类器,通过 configuration.resolvedConfiguration.lenientConfiguration解析复制的配置,检查可以解决哪些依赖项,然后相应地为原始配置选择分类器(同样通过 resolutionStrategy.eachDependency )。做所有这一切的最好的地方是 configuration.incoming.beforeResolve


I am evaluating gradle for our project. We have multiple small project that contain small util libraries. Most projects are in an extra repository and cannot use a shared buildscript. When working across multiple project the same feature branch is used. I already managed to get gradle to put the branchname into the created maven artifact as classifier. For our continous integration it would be really helpful to resolve a dependency to such a library to the one using its own branch name if it exists. If it doesn't it should fallback to the normal declared version.

I managed to change the versions via resolutionStrategy.eachDependency but I couldn't find a way to implement the fallback if no version for this branch exists.

Is there any way this can be achived?

Regards, arne

解决方案

You'll have to write some code to achieve this. For example, you could copy the configuration, set classifiers for the copied configuration via resolutionStrategy.eachDependency, resolve the copied configuration via configuration.resolvedConfiguration.lenientConfiguration, check which dependencies could be resolved, and then choose classifiers for the original configuration accordingly (again via resolutionStrategy.eachDependency). The best place to do all of this is in configuration.incoming.beforeResolve.

这篇关于选择带Branchname的版本作为Gradle的分类器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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