问题
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