Reputation: 1027
Some Maven artifacts in addition to the main jar provide a separate test jar which contains classes to aid with writing tests that use the dependency. kafka-streams
is one example. In Gradle it's possible to depend on such a jar using classifier: "test"
(if the test jar has -test.jar
suffix) and in Maven that would be <type>test-jar</type>
. How to add a test jar to a Bazel workspace?
Upvotes: 2
Views: 916
Reputation: 1805
The Skylark maven_jar implementation supports this, with the artifact syntax of group:artifact:version:packaging:classifier
.
load("@bazel_tools//tools/build_defs/repo:maven_rules.bzl", "maven_jar")
maven_jar(
name = "org_apache_kafka_test",
artifact = "org.apache.kafka:kafka-streams:1.0.0:jar:test",
sha1 = "b275b72148aad7a59cc12f1005507d61fc0ae77b",
)
Upvotes: 4
Reputation: 4271
I think this feature is missing from maven_jar
.
I could write a rule for the main jar:
maven_jar(
name = "org_apache_kafka",
artifact = "org.apache.kafka:kafka-streams:1.0.0",
sha1 = "a6c87c367176beb7650eb2df173fd9fe6e38656f",
)
But I could not write one for the test jar, this didn't work:
maven_jar(
name = "org_apache_kafka_test",
artifact = "org.apache.kafka:kafka-streams:1.0.0-test",
sha1 = "b275b72148aad7a59cc12f1005507d61fc0ae77b",
)
I recommend filing a feature request at https://github.com/bazelbuild/bazel/issues/new .
Upvotes: 1