bazel-contrib / bazel-contrib/rules_jvm_external

Should there be an error for missing classified Jars?

Open
#443 2 comments 0 reactions 0 assignees View on GitHub
coursier-cli
Dominant language
Java
Stars
373
Forks
301
Avg merge
7d 17h
Merged PRs (30d)
3

Description

I recently used a maven_install call that looked like this:
```
def load_deps():
maven_install(
name = "parser_maven",
artifacts = [
"org.apache.commons:commons-lang3:3.4",
"junit:junit:4.13",
"org.slf4j:slf4j-simple:1.7.30",
"com.company:client:3.0.0-SNAPSHOT",
],
repositories = [
"https://artifacts/archiva/repository/snapshots/",
],
)
```
Looks good, but my compile didn't seem to work, complaining about missing classes from a transitive dependency of the com.company:client artifact. So I tried adding that artifact directly, adding this to the `artifacts` property:
```
maven.artifact(
group = "com.company.utils",
artifact = "util",
version = "2.1.2-SNAPSHOT",
classifier = "java",
),
```
This is the correct coordinate for this artifact, but I was still having the same issues. So after some troubleshooting, I found three things:
1. For the com.company.utils:util artifact the pom had been uploaded, but the classified version of the jar had not been (this was the root cause of the problem).
1. In the BUILD file for the parser_maven repo the definition for this artifact was:
```
java_library(
name = "com_company_utils_util_java",
exports = [
],
tags = ["maven_coordinates=com.company.utils:util:jar:java2:2.1.2-SNAPSHOT"],
)
```
(notice the missing "jars" property)
1. In the `external/parser_maven/v1/.../2.1.2-SNAPSHOT` directory for the artifact, I had this set of files:
1. .util-java.pom (along with the .md5 and .sha1 versions)
1. .util-java.jar.err (along with the .md5 and .sha1 versions)

So what it looked like is the pom was able to be retrieved but the classified jar was not, since it didn't exist at the time. Given that this was the case should an error have been thrown during the retrieval stage, instead of at the compile stage when the classes were missing? I wouldn't have expected the "@parser_maven//:com_company_utils_util" label to resolve properly if the requested artifact wasn't found.

Contributor guide

Open the contributing guide

Research direction

Start at the maven_install entry point and inspect the generated BUILD definition for com_company_utils_util in external/parser_maven/v1/.../2.1.2-SNAPSHOT, along with the .util-java.jar.err and POM files. Trace how a missing classified JAR is handled during retrieval and define completion as reporting the missing artifact before compilation instead of exposing a misleading resolvable label.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.