3

I have a dependency that transitively includes a runtime dependency org.springframework.boot:spring-boot-starter-log4j2 which I want to exclude.

I have tried:

dependencies {
    "implementation" ("com.meanwhileinhell.common:my-lib:${commonVersion}") {
        exclude("org.springframework.boot:spring-boot-starter-log4j2")
    }
}

and

dependencies {
    configurations {
        all {
            exclude("org.springframework.boot:spring-boot-starter-log4j2")
        }
    }
}

and also, moving the configurations {... out of the dependencies block.

The first seems to exclude the compile dependency ok, but the runtime dependency still remains.

How do I remove this dependency in its entirety?

EDIT----------------

I've managed to find a bit of a sledgehammer approach that has worked for me in this instance, but not a great, long term solution. This will stop Gradle from resolving any transitive dependencies for the dependency.

dependencies {
    "implementation" ("com.meanwhileinhell.common:my-lib:${commonVersion}") {
        isTransitive = false
    }
}
MeanwhileInHell
  • 6,780
  • 17
  • 57
  • 106

0 Answers0