Gradle获取从中解决了依赖关系的存储库(智能胖子) [英] Gradle get what repository a dependency was resolved from (smart fat jar)
问题描述
我有一个用例,需要创建一个 smart 胖子.到底是什么意思?
I have a use case where I need to create a smart fat jar. What, exactly does that mean?
本质上,我可以使用不同的存储库来解决我们的应用程序依赖关系,其中一些存储在全局复制的文件共享(用作ivy存储库)中,而其他存储在未生产的私有Maven存储库中,并且不应由生产中的应用程序直接使用.
Essentially I have different repositories which our application dependencies can be resolved from, some of them exist in a globally replicated file share (which is served as an ivy repository), while others exist in a private maven repository that is not productionized, and should not be used directly by applications in production.
我想以一种聪明的方式创建一个罐子,例如:
I would like to create a fat jar in a smart way, such that:
- 如果依赖项来自私有maven存储库,则应将其添加到胖jar中.
- 如果依赖项来自文件共享,则它直接指向该文件共享中的jar(即胖jar的清单将那个jar添加到类路径中.
我是否有任何设施可以区分从何处解决依赖项?
例如:
repositories {
stableIvy()
unreliableMaven()
}
dependencies {
...
}
推荐答案
从Gradle 5.2开始,没有API允许您访问该信息.但是,这是Gradle内部已知的.您可以针对该项目提出功能请求.
As of Gradle 5.2 there is no API that allows you to acces that information. However this is internally known by Gradle. You could file a feature request against the project.
这篇关于Gradle获取从中解决了依赖关系的存储库(智能胖子)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!