简体   繁体   中英

Gradle - what is “runtime” dependency configuration used for?

Can you please help me understand what are the typical use-cases in which one would use the runtime dependency configuration (provided by the Java plugin)?

In the Gradle user-guide, Table 23.5. Java plugin - dependency configurations , I can see that the runtime configuration is not used by any tasks - as opposed to eg the compile configuration which is used by the compileJava task.

What then is the runtime dependency useful for?

The runtime configuration is for libraries that are needed at runtime but NOT at compile time (For example JDBC drivers and SLF4J api implementations).

You could just add them to your compile configuration, but then they would be on the compile classpath and you would run the risk of accidentally introducing a compile dependency on something from the implementation rather than the api.

It is not for libraries that are 'provided' by a container - it is actually how you provide libraries to your app while making sure you haven't introduced a compile depencency on them.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM