Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle dependency with test classifier

I've been trying to reference an artefact without luck.

With maven I have no problem doing this:

<dependency>
    <groupId>org.apache.kafka</groupId>
    <artifactId>kafka_2.13</artifactId>
    <version>3.0.0</version>
    <classifier>test</classifier>
</dependency>

Maven selects the correct artefact.

However, with gradle, it always seems to include the artefact without the classifier, no matter what I try:

implementation 'org.apache.kafka:kafka_2.13:3.0.0:test'

I have read the gradle documentation and it suggests this syntax, maybe it has something to do with this specific artefact?

Update

My goal is to use spring-kafka-test. Our internal artefact repository is not set up to use pom resolution, which is why I need to add transitives manually.

I've ruled out the fact that it might be our internal repository by only using maven central; and I get the same results.

like image 633
epoch Avatar asked Jan 29 '26 08:01

epoch


1 Answers

I managed to include only the mentioned jar, with:

dependencies {
  implementation ('org.apache.kafka:kafka_2.13:3.0.0:test') {
    exclude group: 'org.apache.kafka' // or finer grained, if we like
  }
  ...
}

See also: How to specify a classifier in a gradle dependency's dependency?

like image 192
xerx593 Avatar answered Feb 01 '26 01:02

xerx593



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!