Gradle Exclude Transitive Dependency Example

By Arvind Rai, September 20, 2014

Gradle script downloads the JAR and the dependency JAR when gradle script run. This dependency is called transitive dependency. Gradle script downloads the JAR from maven central or any other location which we specify. Sometimes we come in the situation to exclude transitive dependency. The scenario can be like
1. JAR version of transitive dependency is not available
2. Dependency is not available in specified location
3. Dependency is not required in runtime or both in compile and runtime.

To exclude transitive dependency, we have two approach as below.
1. Exclude transitive dependency by configuration
2. Exclude transitive dependency by dependency

Exclude Transitive Dependency by Configuration

Excluding Transitive Dependency by Configuration is preferable way. Using configuration we can exclude transitive dependency for module and group. Find the separate example of module and group. First find the example which will use module dependency as below.