Difference between compile and runtime configurati

2019-01-30 21:07发布

问题:

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.

回答1:

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.