Gradle-实现和运行时之间的区别 [英] Gradle - difference between implementation and runtime

查看:51
本文介绍了Gradle-实现和运行时之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

已阅读 Gradle文档,我了解其中的区别在 api implementation 之间.但是我想知道实现和已弃用的 runtime 之间是否有区别.

Having read this Gradle documentation I understand the difference between api and implementation. However I'd like to know if there's a difference between implementation and the deprecated runtime.

根据此表,两者之间没有区别行为,但是在实践中使用 runtime 似乎在尝试时会泄漏"编译类路径,因此我试图隐藏的类实际上已暴露给使用模块.

According to this table there is no difference in behavior, but using runtime in practice seems to "leak" the compile classpath when I was trying it out and so the classes I was trying to hide was actually being exposed to the consuming module.

推荐答案

实现依赖项被添加到声明它们的项目的编译类路径中.依赖项.

implementation dependencies are added to the compilation classpath of the project they are declared in. That is not the case for runtime dependencies.

如果您纯粹是在谈论实现 runtime 依赖关系如何影响项目的使用者,则

If you're talking purely about how implementation and runtime dependencies affect consumers of the project, the 4.6 release notes state that runtime dependencies have always been included on the compilation classpath, which is why you're seeing the leakage.

如果您发布的库具有 implementation 依赖项,则这些依赖项将在POM中标记为 runtime 范围,我怀疑它们也将包含在编译中消费项目的类路径.您需要启用 IMPROVED_POM_SUPPORT 功能来更改该功能.

If you published a library with implementation dependencies, those dependencies would be marked as runtime scope in the POM, and I suspect that they would also be included in the compilation classpath of consuming projects. You would need to enable the IMPROVED_POM_SUPPORT feature to change that.

这篇关于Gradle-实现和运行时之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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