Gradle中编译和运行时配置的区别 [英] Difference between compile and runtime configurations in Gradle
问题描述
我的问题有点常见,但它也与Gradle链接。
为什么我们需要编译和运行时配置?
当我编译某些东西时,我需要工件来转换我的字节码中的java类,所以我需要编译配置,但为什么需要运行时配置,我是否需要其他东西来运行我的应用程序JVM?
对不起,如果听起来很愚蠢,但我不明白。
app
的程序使用库 foo
和库 foo
内部使用库 bar
。然后只需要 foo
来编译 app
,但是 foo
>和 bar
来运行它。这就是为什么默认情况下,放在Gradle的 compile
配置上的所有内容都可以在它的 runtime
配置中看到,但是相反是不正确的。 My question is a little bit common, but it is linked with Gradle too.
Why we need compile and runtime configuration?
When I compile something I need artifacts to convert my java classes in bytecode so I need compile configuration, but why is needed runtime configuration do I need something else to run my application in JVM?
Sorry if it sounds stupid, but I don't understand.
In the most common case, the artifacts needed at compile time are a subset of those needed at runtime. For example, let's say that a program called app
uses library foo
, and library foo
internally uses library bar
. Then only foo
is needed to compile app
, but both foo
and bar
are needed to run it. This is why by default, everything that you put on Gradle's compile
configuration is also visible on its runtime
configuration, but the opposite isn't true.
这篇关于Gradle中编译和运行时配置的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!