Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle - what is "runtime" dependency configuration used for?

Tags:

java

gradle

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 e.g. the compile configuration which is used by the compileJava task.

What then is the runtime dependency useful for?

like image 980
Doron Gold Avatar asked Sep 11 '14 13:09

Doron Gold


1 Answers

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.

like image 67
Perryn Fowler Avatar answered Sep 28 '22 07:09

Perryn Fowler