bazel-contrib / bazel-contrib/rules_jvm_external
fetching jar with classifier creates circular deps
- Dominant language
- Java
- Stars
- 373
- Forks
- 301
- Avg merge
- 7d 17h
- Merged PRs (30d)
- 3
Description
Let me preface this issue by saying I believe the issue I'm having is due to rules_jvm_external handling of maven artifact classifiers, however it's very likely I may have done something wrong.
Repro:
Download the aspos-words trial java API via these install instructions:
https://products.aspose.com/words/java
```
AsposeJavaAPI
Aspose Java API
https://repository.aspose.com/repo/
com.aspose
aspose-words
20.5
jdk17
```
Using this `maven_install` rule:
```
maven_install(
artifacts = [
maven.artifact(
group = "com.aspose",
artifact = "aspose-words",
version = "20.5",
classifier = "jdk17",
),
],
repositories = [
"https://repository.aspose.com/repo/",
"https://repo.maven.apache.org/maven2/",
"https://repo1.maven.org/maven2",
],
)
```
Then:
```
$ bazel build @maven//:com_aspose_aspose_words_jdk17
ERROR: /home/erick/.cache/bazel/_bazel_erick/51f94dff9e41d9ddccec66e7fa0aa208/external/maven/BUILD:9:11: in jvm_import rule @maven//:com_aspose_aspose_words_jdk17: cycle in dependency graph:
.-> @maven//:com_aspose_aspose_words_jdk17
| @maven//:com_aspose_aspose_words_shaping_harfbuzz_plugin
`-- @maven//:com_aspose_aspose_words_jdk17
This cycle occurred because of a configuration option
ERROR: Analysis of target '@maven//:com_aspose_aspose_words_jdk17' failed; build aborted
INFO: Elapsed time: 11.317s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (4 packages loaded, 60 targets configured)
```
Here is the associated pom.xml for the artifact:
https://repository.aspose.com/repo/com/aspose/aspose-words/20.5/aspose-words-20.5.pom
This is a portion of the generated BUILD file from `maven_install`:
```
jvm_import(
name = "com_aspose_aspose_words_jdk17",
jars = ["v1/https/repository.aspose.com/repo/com/aspose/aspose-words/20.5/aspose-words-20.5-jdk17.jar"],
deps = [
... redacted ...
":com_aspose_aspose_words_shaping_harfbuzz_plugin",
":com_aspose_aspose_words_javadoc",
... redacted ...
],
tags = ["maven_coordinates=com.aspose:aspose-words:jar:jdk17:20.5"],
)
alias(
name = "com_aspose_aspose_words_jdk17_20_5",
actual = "com_aspose_aspose_words_jdk17",
)
jvm_import(
name = "com_aspose_aspose_words_shaping_harfbuzz_plugin",
jars = ["v1/https/repository.aspose.com/repo/com/aspose/aspose-words/20.5/aspose-words-20.5-shaping-harfbuzz-plugin.jar"],
deps = [
... redacted ...
":com_aspose_aspose_words_jdk17",
":com_aspose_aspose_words_javadoc",
```
Manually removing the ":com_aspose_aspose_words_jdk17" from the :com_aspose_aspose_words_shaping_harfbuzz_plugin target and the javadoc deps from both targets succeeds.
When I look at the POM I am led to believe that maven_install is getting confused by the jdk17 classifier and associates all depdendencies in the POM as dependencies of eachother? I don't have a better way to explain it - sorry for the rough speculation.
My reasoning is the list of directDependencies in the `dep-tree.json` file for the `aspose-words-20.5-jdk17` and `shaping-harfbuzz-plugin.jar` looks wrong:
```
"file": "v1/https/repository.aspose.com/repo/com/aspose/aspose-words/20.5/aspose-words-20.5-jdk17.jar",
"directDependencies": [
"org.jogamp.jogl:jogl-all-main:2.3.2",
"com.aspose:aspose-words:jar:jdk17:20.5",
"org.jogamp.gluegen:gluegen-rt-main:2.3.2",
"com.aspose:aspose-words:jar:shaping-harfbuzz-plugin:20.5",
"com.aspose:aspose-words:jar:javadoc:20.5"
],
....
"file": "v1/https/repository.aspose.com/repo/com/aspose/aspose-words/20.5/aspose-words-20.5-shaping-harfbuzz-plugin.jar",
"directDependencies": [
"org.jogamp.jogl:jogl-all-main:2.3.2",
"com.aspose:aspose-words:jar:jdk17:20.5",
"org.jogamp.gluegen:gluegen-rt-main:2.3.2",
"com.aspose:aspose-words:jar:shaping-harfbuzz-plugin:20.5",
"com.aspose:aspose-words:jar:javadoc:20.5"
],
```
---
second issue:
The `com_aspose_aspose_words_javadoc` target fails to get downloaded or defined - even if I include an explicit additional artifact in the `maven_install` declaration:
```
maven.artifact(
group = "com.aspose",
artifact = "aspose-words",
version = "20.5",
classifier = "javadoc",
),
```
I'm not sure if this is related to the main bug.
Contributor guide
Research direction
Start with the supplied Aspose POM, the maven_install declaration, and the generated BUILD and dep-tree.json entries for the jdk17 and shaping-harfbuzz-plugin artifacts. Reproduce the Bazel cycle and inspect how classifier dependencies are recorded. Done means the classifier artifacts no longer acquire circular dependencies and the explicitly requested javadoc target is downloaded and defined correctly.
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