bazel-contrib / rules_jvm_external

Bazel rules to resolve, fetch and export Maven artifacts
Apache License 2.0
336 stars 256 forks source link

Suggestions on handling OS-specific activation? #712

Open dhalperi opened 2 years ago

dhalperi commented 2 years ago

We are looking at using graphviz-java, which has the following in its pom.xml: https://github.com/nidi3/graphviz-java/blob/master/graphviz-java/pom.xml#L128-L191

tl;dr: OS-specific dependencies are activated based on the operating system on which the build is processed. This seems to be making it into the maven_install.json file -- if I run on macOS, only the macOS dependency is added.

Has anyone run into this before? Presumably what I want is for all these to be added to the maven_install.json, and then have them be platform-dependent dependencies. Does anyone have advice for how to actually do this?

thomasbao12 commented 1 month ago

I think I'm having a similar issue. orc-core 1.9.1 has a dependency on hadoop-client-api, but only under the java 17 profile. See https://repo1.maven.org/maven2/org/apache/orc/orc-core/1.9.1/orc-core-1.9.1.pom

However, for this maven_install target, I see hadoop-client-api in the maven_install.json

maven_install(name = "multiversion_maven_org_apache_orc_orc_core_nohive_1_9_1", artifacts = [maven.artifact("org.apache.orc", "orc-core", "1.9.1", packaging = "jar", classifier = "nohive")], maven_install_json = "@//bazel/workspace/third_party:multiversion_maven_org_apache_orc_orc_core_nohive_1_9_1_install.json", **kwargs)

This is what the install.json looks like:

"dependencies": {
    "org.apache.hadoop:hadoop-client-api": [
      "org.xerial.snappy:snappy-java"
    ],
    "org.apache.orc:orc-core:jar:nohive": [
      "io.airlift:aircompressor",
      "org.apache.commons:commons-lang3",
      "org.apache.orc:orc-shims",
      "org.jetbrains:annotations",
      "org.slf4j:slf4j-api",
      "org.threeten:threeten-extra"
    ],
    "org.apache.orc:orc-shims": [
      "org.apache.hadoop:hadoop-client-api",
      "org.slf4j:slf4j-api"
    ]
  },