bazel-contrib / bazel-contrib/rules_jvm_external

Exclusions defined in dependencyManagement don't apply transitively

Open
#233 3 comments 0 reactions 0 assignees View on GitHub
coursier-cli type: bug
Dominant language
Java
Stars
373
Forks
301
Avg merge
6d 3h
Merged PRs (30d)
5

Description

I believe that this is a manifestation of https://github.com/coursier/coursier/issues/853 in rules_jvm_external.

`org.apache.axis2:axis2-kernel:1.5.1` ([pom](https://repo.maven.apache.org/maven2/org/apache/axis2/axis2-kernel/1.5.1/axis2-kernel-1.5.1.pom)) contains a [dependencyManagement](https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Management) block which defines a transitive exclusion on `xml-apis:xml-apis` via `org.apache.ws.commons.axiom:axiom-api:1.2.8`. However, Bazel projects using rules_jvm_external to integrate `axis2-kernel` still end up with `xml-apis` in the dependency graph and on the classpath.

## Steps to reproduce
```console
$ cat WORKSPACE
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

RULES_JVM_EXTERNAL_TAG = "2.7"
RULES_JVM_EXTERNAL_SHA = "f04b1466a00a2845106801e0c5cec96841f49ea4e7d1df88dc8e4bf31523df74"

http_archive(
name = "rules_jvm_external",
strip_prefix = "rules_jvm_external-%s" % RULES_JVM_EXTERNAL_TAG,
sha256 = RULES_JVM_EXTERNAL_SHA,
url = "https://github.com/bazelbuild/rules_jvm_external/archive/%s.zip" % RULES_JVM_EXTERNAL_TAG,
)

load("@rules_jvm_external//:defs.bzl", "maven_install")

maven_install(
artifacts = [
"org.apache.axis2:axis2-kernel:1.5.1",
],
repositories = [
"https://jcenter.bintray.com/",
"https://maven.google.com",
"https://repo1.maven.org/maven2",
],
)
$ cat BUILD.bazel
java_library(
name = "java_test_deps",
exports = [
"@maven//:org_apache_axis2_axis2_kernel",
],
)
$ bazel cquery --noimplicit_deps 'deps(:java_test_deps)' | grep xml.apis
@maven//:xml_apis_xml_apis (b67bdc290fb31b127eacf7a9889db436)
```

Contributor guide

Open the contributing guide

Research direction

Start with the WORKSPACE and BUILD.bazel reproduction, then run the provided bazel cquery command to confirm that xml_apis_xml_apis remains in the graph. Trace how rules_jvm_external processes the axis2-kernel POM's dependencyManagement exclusions and compare the behavior with coursier issue #853. Done means the exclusion is applied transitively and the xml-apis artifact no longer appears in the dependency graph or classpath.

Written by the indexing model from the issue text.

Assessment

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