Gradle - difference between implementation and runtime

落爺英雄遲暮 提交于 2020-06-15 22:31:09

问题


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.

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.


回答1:


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

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.

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.



来源:https://stackoverflow.com/questions/51127422/gradle-difference-between-implementation-and-runtime

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!