How to exclude a dependency from built JAR in Gradle?

Viewed 202

I have the current dependency specified in my build.gradle:

dependencies {
        implementation("com.thesamet.scalapb:scalapb-runtime-grpc_2.13:0.11.1")
}

And I want to exclude it from my built JAR. In sbt it would be enough with doing:

   libraryDependencies ++= Seq(
  "com.thesamet.scalapb" %% "scalapb-runtime-grpc" % "0.11.1" % Optional
)

But how can be the same done in Gradle? I have seen in some post that they use compile.exclude to exclude transitive dependencies, but that is not a transitive dependency, so not sure if just using compile.exclude would be fine (?)

1 Answers
Related