runtimeonly
runtimeOnly is a dependency configuration in Gradle that marks dependencies needed at runtime but not for compiling the source code. Dependencies added to runtimeOnly are not on the compile classpath and are not exported to consumers of a library project. Instead, they are included on the runtime classpath when the application or tests are executed.
This configuration is useful for libraries that must load certain components only during execution, such as
In practice, you declare runtimeOnly dependencies in the dependencies block. Examples:
- In the Groovy DSL: dependencies { runtimeOnly 'org.postgresql:postgresql:42.2.5' }
- In the Kotlin DSL: dependencies { runtimeOnly("org.postgresql:postgresql:42.2.5") }
Gradle also provides other configurations for different purposes, such as api, implementation, and compileOnly, to control