3

I am trying to exclude a transitive dependency in gradle

    implementation (('org.apache.kafka:kafka-streams:2.3.0'), {
        exclude 'org.rocksdb:rocksdbjni:5.18.3'
    })

I am seeing this error

  • What went wrong: A problem occurred evaluating project

Could not find method exclude() for arguments [org.rocksdb:rocksdbjni:5.18.3] on DefaultExternalModuleDependency{group='org.apache.kafka', name='kafka-streams', version='2.3.0', configuration='default'} of type org.gradle.api.internal.artifacts.dependencies.DefaultExternalModuleDependency.

I am using gradle 5.6.1

mihirg
  • 915
  • 2
  • 13
  • 28
  • Does this answer your question? [How do I exclude all instances of a transitive dependency when using Gradle?](https://stackoverflow.com/questions/21764128/how-do-i-exclude-all-instances-of-a-transitive-dependency-when-using-gradle) – Egor Jul 13 '20 at 03:46
  • no, I am explicitly looking to get this example working. The solutions in the link above deal with "compile", which is no longer the recommended way to use gradle – mihirg Jul 13 '20 at 03:57
  • Why the double parentheses? Also please provide a minimal complete build.gradle file, as the cause of the error might be in surrounding lines. – tkruse Jul 13 '20 at 04:40

2 Answers2

2

ref https://docs.gradle.org/current/userguide/dependency_downgrade_and_exclude.html#sec:excluding-transitive-deps

groovy:

implementation('org.apache.kafka:kafka-streams:2.3.0') {
        exclude group: 'org.apache.kafka', module: 'kafka-streams'
    }

Kotlin:

implementation("org.apache.kafka:kafka-streams:2.3.0") {
        exclude(group = "org.apache.kafka", module = "kafka-streams")
    }

As you can see the exclude can only support group: , module: args - not the single string format g:m:v.

PrasadU
  • 2,154
  • 1
  • 9
  • 10
0
implementation ('org.apache.kafka:kafka-streams:2.3.0'){
   //transitive dependency:org.rocksdb:rocksdbjni:5.18.3
   exclude group: 'org.rocksdb', module: 'rocksdbjni'
}
DalusC
  • 391
  • 1
  • 12