bazel-contrib / bazel-contrib/rules_jvm_external

artifact from //:defs.bzl doesn't handle test jars

Open
#488 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
373
Forks
301
Avg merge
6d 3h
Merged PRs (30d)
5

Description

When specifying dependencies for JVM build targets using `artifact` from `defs.bzl`, it does not appear to have a mechanism to specify a test jar. Ideally there would be a parallel to what `maven.artifact` provides so that maven style coordinates can be used throughout. As an example a test jar can be referenced using maven.artifact as follows:
`maven.artifact("org.apache.flink", "flink-streaming-java_2.11", FLINK_VERSION, classifier="tests"),`.

I have worked around the issue with the following solution however it would be preferable to consistently use maven coordinates throughout the workspace:
```
java_junit5_test(
name = "test",
srcs = glob(["*.java"]),
test_package = "com.example.foobar",
deps = [
artifact("org.apache.flink:flink-streaming-java_2.11"),
"@maven//:org_apache_flink_flink_streaming_java_2_11_tests",
... etc
],
)
```

The following 3 examples are what I could see as solutions:
```
# use tests type (maven style coordinate specification of classifier)
artifact("org.apache.flink:flink-streaming-java_2.11:tests"),

# use explicit flag that matches maven.artifact
artifact("org.apache.flink", "flink-streaming-java_2.11", FLINK_VERSION, classifier="tests"),

# use include_tests which pulls creates dependencies on both jar and the test jar.
artifact("org.apache.flink:flink-streaming-java_2.11", include_tests=True),
```

Example maven artifacts:
https://repo1.maven.org/maven2/org/apache/flink/flink-streaming-java_2.11/1.11.2/

Contributor guide

Open the contributing guide

Research direction

Start from the artifact entry point in defs.bzl and compare its dependency handling with maven.artifact, especially the classifier example in the issue. Done means artifact can consistently reference the Maven test jar for the provided Flink coordinates without the separate @maven dependency workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.