bazel-contrib / bazel-contrib/rules_jvm_external

java_export dependency scope

Open
#714 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
373
Forks
301
Avg merge
7d 17h
Merged PRs (30d)
3

Description

Hey there,

I'm looking for some advice on how to set the Maven scope (classifier) for individual dependencies included into a target? The use-case here is to generate poms that contain both production and test dependencies, but scope the test dependencies so that they are not included in the production jar. From the documentation, I can see that I should be able to set the 5-element coordinates using `artifact`, but I think something is wrong with the parsing there. It also doesn't seem to be possible to set the scope without also setting the version and packaging, neither of which I want to specify.

Currently, when dependencies are templated into the POM from this BUILD:

```bazel
deps = artifact("org.whatever:greatlibrary")
```

they look something like:

```xml

org.whatever
greatlibrary
1.2.3

```

Where the `version` is automatically determined by our repository-wide pinned Maven dependencies.

I'd like to be able to do something like:

```bazel
deps = artifact("org.whatever:greatlibrary", classifier = "test")
```

to generate:

```xml

org.whatever
greatlibrary
1.2.3
test

```

Also, I could be mistaken, but I think there a few different bugs in the coordinate parsing/stripping logic. When I pass a 5-element coordinate, it parses the 4th element as the version instead of the 5th.

Contributor guide

Open the contributing guide

Research direction

Start by tracing the java_export artifact() entry point and its coordinate parsing and POM templating behavior, using the BUILD and generated dependency examples in the issue. Reproduce both the classifier/scope case and the five-element coordinate case; done means scope can be set without replacing the pinned version or packaging, and the fifth coordinate element is parsed correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system
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.