Gradle 中编译和运行时配置的区别 [英] Difference between compile and runtime configurations in Gradle

查看:27
本文介绍了Gradle 中编译和运行时配置的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题有点常见,但它也与 Gradle 相关.

My question is a little bit common, but it is linked with Gradle too.

为什么我们需要编译和运行时配置?

当我编译某些东西时,我需要工件来将我的 Java 类转换为字节码,所以我需要编译配置,但是为什么需要运行时配置我还需要其他东西来在 JVM 中运行我的应用程序吗?

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.

推荐答案

在最常见的情况下,编译时所需的工件是运行时所需工件的子集.例如,假设一个名为 app 的程序使用库 foo,而库 foo internally 使用库 >bar.那么编译app只需要foo,运行foobar都需要.这就是为什么默认情况下,您放在 Gradle 的 compile 配置上的所有内容也在其 runtime 配置中可见,但事实并非如此.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆