Why do I have to specify both 'runtime' and 'compile' for the same dependency?

若如初见. 提交于 2019-12-12 08:21:40

问题


I am depending on a few artifacts that I need to both compile and run my application.

According to the Gradle docs, the runtime configuration extends the compile configuration, so surely adding a dependency using runtime implies an implicit compile dependency?

At least that was my assumption, but it does not work. When just depending on the artifact using runtime, my project does not compile anymore. I literally have to:

compile 'oauth.signpost:signpost-core:1.2.1.2'
runtime 'oauth.signpost:signpost-core:1.2.1.2'

for the application to both compile and see the Signpost classes at runtime.

Am I missing something? That just doesn't look right...


回答1:


Almost right. Runtime configuration, indeed, extends compile configuration (docs). It means, that any dependency added to compile configuration is available in runtime configuration (docs).

compile 'oauth.signpost:signpost-core:1.2.1.2' will be enough to get this artifact in both, runtime and compile.



来源:https://stackoverflow.com/questions/4693490/why-do-i-have-to-specify-both-runtime-and-compile-for-the-same-dependency

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