bazeltools / bazel-deps

Generate bazel dependencies for maven artifacts
MIT License
250 stars 121 forks source link

Issue with transitive dependency of matrix-toolkits-java #222

Closed dlaflamme closed 5 years ago

dlaflamme commented 5 years ago

I have a scala project that depends on matrix-toolkits-java 1.0.4. My project is building fine in SBT.

I specified mtj in my dependencies.yaml like this:

   com.googlecode.matrix-toolkits-java:
        mtj:
            lang: java
            version: "1.0.4"

I ran generate which completed successfully. However, when I then build the project with bazel, I get an error:

$ bazel build --sandbox_debug ...
INFO: Analysed 219 targets (0 packages loaded, 0 targets configured).
INFO: Found 219 targets...
ERROR: /home/dlaflamme/.cache/bazel/_bazel_dlaflamme/45af1ecd97eacf98be1df60cce88f37f/external/com_github_fommil_netlib_all_pom/jar/BUILD:3:1: Extracting interface @com_github_fommil_netlib_all_pom//jar:jar failed (Aborted): process-wrapper failed: error executing command
  (cd /home/dlaflamme/.cache/bazel/_bazel_dlaflamme/45af1ecd97eacf98be1df60cce88f37f/execroot/__main__ && \
  exec env - \
    PATH=/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/dlaflamme/.local/bin:/home/dlaflamme/bin:/home/dlaflamme/.local/bin:/home/dlaflamme/bin \
    TMPDIR=/tmp \
  /home/dlaflamme/.cache/bazel/_bazel_dlaflamme/45af1ecd97eacf98be1df60cce88f37f/execroot/__main__/_bin/process-wrapper '--timeout=0' '--kill_delay=15' external/bazel_tools/tools/jdk/ijar/ijar external/com_github_fommil_netlib_all_pom/jar/com_github_fommil_netlib_all_pom.jar bazel-out/k8-fastbuild/genfiles/external/com_github_fommil_netlib_all_pom/jar/_ijar/jar/external/com_github_fommil_netlib_all_pom/jar/com_github_fommil_netlib_all_pom-ijar.jar --target_label @com_github_fommil_netlib_all_pom//jar:jar) process-wrapper failed: error executing command
  (cd /home/dlaflamme/.cache/bazel/_bazel_dlaflamme/45af1ecd97eacf98be1df60cce88f37f/execroot/__main__ && \
  exec env - \
    PATH=/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/dlaflamme/.local/bin:/home/dlaflamme/bin:/home/dlaflamme/.local/bin:/home/dlaflamme/bin \
    TMPDIR=/tmp \
  /home/dlaflamme/.cache/bazel/_bazel_dlaflamme/45af1ecd97eacf98be1df60cce88f37f/execroot/__main__/_bin/process-wrapper '--timeout=0' '--kill_delay=15' external/bazel_tools/tools/jdk/ijar/ijar external/com_github_fommil_netlib_all_pom/jar/com_github_fommil_netlib_all_pom.jar bazel-out/k8-fastbuild/genfiles/external/com_github_fommil_netlib_all_pom/jar/_ijar/jar/external/com_github_fommil_netlib_all_pom/jar/com_github_fommil_netlib_all_pom-ijar.jar --target_label @com_github_fommil_netlib_all_pom//jar:jar)
file is invalid or corrupted (missing end of central directory record)
Cannot find central directory
Unable to open Zip file external/com_github_fommil_netlib_all_pom/jar/com_github_fommil_netlib_all_pom.jar: Input/output error
INFO: Elapsed time: 0.571s, Critical Path: 0.16s, Remote (0.00% of the time): [queue: 0.00%, setup: 0.00%, process: 0.00%]
INFO: 10 processes: 10 worker.
FAILED: Build did NOT complete successfully
$

Note the "unable to open zip file" error above.

The first 25 lines of the generated BUILD filed for netlib are:

[dlaflamme_exd@exdsyprea01nye bazel-root]$ head -25 3rdparty/jvm/com/github/fommil/netlib/BUILD
load("@io_bazel_rules_scala//scala:scala_import.bzl", "scala_import")
load("@io_bazel_rules_scala//scala:scala.bzl", "scala_library")
java_library(
    name = "all_pom",
    exports = [
        "//external:jar/com/github/fommil/netlib/all_pom",
        ":core",
        ":netlib_native_ref_linux_armhf_jar_natives",
        ":netlib_native_ref_linux_i686_jar_natives",
        ":netlib_native_ref_linux_x86_64_jar_natives",
        ":netlib_native_ref_osx_x86_64_jar_natives",
        ":netlib_native_ref_win_i686_jar_natives",
        ":netlib_native_ref_win_x86_64_jar_natives",
        ":netlib_native_system_linux_armhf_jar_natives",
        ":netlib_native_system_linux_i686_jar_natives",
        ":netlib_native_system_linux_x86_64_jar_natives",
        ":netlib_native_system_osx_x86_64_jar_natives",
        ":netlib_native_system_win_i686_jar_natives",
        ":netlib_native_system_win_x86_64_jar_natives"
    ],
    visibility = [
        "//3rdparty/jvm:__subpackages__"
    ]
)

I found that if I removed the following line, the build would work:

"//external:jar/com/github/fommil/netlib/all_pom",

Why is this? Is this a bug in bazel-deps or in netlib's maven setup? Or something else?

Is removing that line correct or should I modify it somehow?

mtj 1.0.4 is here: https://mvnrepository.com/artifact/com.googlecode.matrix-toolkits-java/mtj/1.0.4

johnynek commented 5 years ago

see #220 -- I think this may be a version of the same issue: maven pom dependencies are not well supported. I'm sorry.

I would welcome a PR here, but I have not had time to investigate much myself.

This does not seem to come up too much since Stripe hasn't hit it yet, but I guess it is a landmine waiting for us when we do.

I imagine it is not too much work to support since coursier CLI seems to work with pom dependencies, but I have not looked at the code they have to handle this.

dgrnbrg commented 5 years ago

Hey, I ran into this issue and solved it with the patch in the PR I just opened. Thanks for building this awesome dependency manager!