本文介绍了为什么我必须为同一依赖指定“runtime”和“compile”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我依赖于我需要编译和运行我的应用程序的一些工件。



根据Gradle文档,运行时配置 / em>编译配置,因此确保使用 runtime 添加依赖性意味着隐式编译依赖性?

至少这是我的假设,但它不工作。当只依赖于使用 runtime 的工件时,我的项目不再编译。我真的必须:

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

在运行时查看Signpost类。



我错过了什么?这看起来不正确...

解决方案

几乎正确。运行时配置,扩展编译配置()。这意味着,添加到编译配置的任何依赖都可以在 runtime 配置中使用()。



compile'oauth.signpost:signpost-core:1.2.1.2'将足以在运行时和编译时获得这个工件。


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...

解决方案

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.

这篇关于为什么我必须为同一依赖指定“runtime”和“compile”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 10:12