Aman Kumar Sinha
Aman Kumar Sinha

Reputation: 427

How to exclude a dependency coming from spring boot in gradle

MY project has spring boot 2.3.0.RELEASE dependency and as a result we have certain log4j dependencies like org.apache.logging.log4j:log4j-api:2.13.2 coming in our dependency through it.

I want to exclude this from our dependency tree. The problem is we have added spring dependency in ext block

buildscript {
  ext {
    springBootVersion = '2.3.0.RELEASE'
    sonarqubeVersion = '2.7.1'
    gradleOSpackage = '1.9.4'
    jfrogVersion = '2.2.4'
    asciidoctorVersion = '1.5.8.1'
  }  

When i have a dependency in implementation block I exclude the unwanted dependency like

implementation ('io.confluent:kafka-schema-registry:5.3.0') {
        exclude(group='org.slf4j',module='slf4j-loh4j12')
    }

But in this case ,I don't know how to exclude the coming log4j dependencies from spring boot.

Upvotes: 4

Views: 10752

Answers (1)

harsh tibrewal
harsh tibrewal

Reputation: 835

If it's a transitive dependency and we are sure that we want to exclude it totally, one can use configurations.all block in build.gradle file like this:

configurations.all {
  exclude group: 'org.apache.logging.log4j', module: 'log4j-api'
}

Upvotes: 4

Related Questions