Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Yes, a transitive dependency in Gradle can be marked as "runtimeOnly" which means that the dependency will only be included at runtime and not during compile time. This allows you to reduce the size of your compiled JAR or WAR file according to your project's requirements.

For example, you can mark a dependency as runtimeOnly in your Gradle build script by adding the following code to the dependencies block:

dependencies {
   // compile time dependencies
   implementation 'com.sample:dependency1:1.0'

   // runtime dependencies
   runtimeOnly 'com.sample:dependency2:2.0'
}

In this example, "dependency1" will be included during both compile time and runtime, but "dependency2" will only be included at runtime.